The native timer functions (i.e., setTimeout
,
setInterval
, clearTimeout
,
clearInterval
) are less than ideal for a testing environment
since they depend on real time to elapse. Jest can swap out timers with
functions that allow you to control the passage of time.
Great Scott!
// timerGame.js
'use strict';
function timerGame(callback) {
console.log('Ready....go!');
setTimeout(() => {
console.log('Times up -- stop!');
callback && callback();
}, 1000);
}
module.exports = timerGame;
// __tests__/timerGame-test.js
'use strict';
jest.useFakeTimers();
test('waits 1 second before ending the game', () => {
const timerGame = require('../timerGame');
timerGame();
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 1000);
});
Here we enable fake timers by calling jest.useFakeTimers();
.
This mocks out setTimeout and other timer functions with mock functions.
Another test we might want to write for this module is one that asserts that the callback is called after 1 second. To do this, we’re going to use Jest’s timer control APIs to fast-forward time right in the middle of the test:
test('calls the callback after 1 second', () => {
const timerGame = require('../timerGame');
const callback = jest.fn();
timerGame(callback);
// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
// Fast-forward until all timers have been executed
jest.runAllTimers();
// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
There are also scenarios where you might have a recursive timer – that is
a timer that sets a new timer in its own callback. For these, running all
the timers would be an endless loop… so something like
jest.runAllTimers()
is not desirable. For these cases you
might use jest.runOnlyPendingTimers()
:
// infiniteTimerGame.js
'use strict';
function infiniteTimerGame(callback) {
console.log('Ready....go!');
setTimeout(() => {
console.log('Times up! 10 seconds before the next game starts...');
callback && callback();
// Schedule the next game in 10 seconds
setTimeout(() => {
infiniteTimerGame(callback);
}, 10000);
}, 1000);
}
module.exports = infiniteTimerGame;
// __tests__/infiniteTimerGame-test.js
'use strict';
jest.useFakeTimers();
describe('infiniteTimerGame', () => {
test('schedules a 10-second timer after 1 second', () => {
const infiniteTimerGame = require('../infiniteTimerGame');
const callback = jest.fn();
infiniteTimerGame(callback);
// At this point in time, there should have been a single call to
// setTimeout to schedule the end of the game in 1 second.
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 1000);
// Fast forward and exhaust only currently pending timers
// (but not any new timers that get created during that process)
jest.runOnlyPendingTimers();
// At this point, our 1-second timer should have fired it's callback
expect(callback).toBeCalled();
// And it should have created a new timer to start the game over in
// 10 seconds
expect(setTimeout).toHaveBeenCalledTimes(2);
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 10000);
});
});
runTimersToTime
to
advanceTimersByTime
in Jest 22.0.0
Another possibility is use jest.advanceTimersByTime(msToRun)
.
When this API is called, all timers are advanced by
msToRun
milliseconds. All pending “macro-tasks” that have
been queued via setTimeout() or setInterval(), and would be executed
during this timeframe, will be executed. Additionally if those macro-tasks
schedule new macro-tasks that would be executed within the same time
frame, those will be executed until there are no more macro-tasks
remaining in the queue that should be run within msToRun milliseconds.
// timerGame.js
'use strict';
function timerGame(callback) {
console.log('Ready....go!');
setTimeout(() => {
console.log('Times up -- stop!');
callback && callback();
}, 1000);
}
module.exports = timerGame;
it('calls the callback after 1 second via advanceTimersByTime', () => {
const timerGame = require('../timerGame');
const callback = jest.fn();
timerGame(callback);
// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
// Fast-forward until all timers have been executed
jest.advanceTimersByTime(1000);
// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
Lastly, it may occasionally be useful in some tests to be able to clear
all of the pending timers. For this, we have
jest.clearAllTimers()
.
The code for this example is available at examples/timer.


Are you looking for a mobile phone charging business or a mobile phone charging franchise?
Find out more about our mobile phone charging business opportunity today!
Want to jump to a particular section? Introduction, Package, FAQ or Cost
Are you looking for a mobile phone charging business or a mobile phone charging franchise? Find out more about our business opportunity today!
Already proven successful in the USA & Asia and now "Readymade Business 4 U" has introduced them here in the UK & Ireland...
As with all our products, they have been tried & tested, and with hundreds already out there, they're proving themselves as a great mobile phone charging business. Our product is the latest and most profitable charging station in its class, in the UK today! Areas available but selling fast, so jump on board at the beginning before it?s too late. We offer the same back-up, support and professional set-up of your business, as we do with all of our business models.
"Professional and with the minimum of fuss – we'll have you up and running within weeks"
If you love the ease of vending and simply wish to collect your revenue along with our unique advertising twist, to add even more income, then this business model is for you!
THE PRODUCT
Mobile phone charging vending is currently very successful in the Far East and the United States. Now it's here proving the same in the UK & Ireland. Our advertising screens are a totally new and unique concept to hit these shores, and not just another vending model. What make these machines unique when it comes to vending is;
"You can get involved"
This gives you the potential to make a serious income and not having to have hundreds of machines to do so. We currently have operators with only 5 machines making £3,000.00 per month & more!
"If they can do it, so can you with our help"
The only phones our Mobile Phone Charging Stations won't charge are the old ones that nobody really has anymore. All our charging stations can be upgraded at anytime, simply and easily if new phones arrive. Simply plug in your phone, enter £1 and you're away!
Customers can use their phones immediately if they have an emergency call to make. While their phone is charging they will be starring at a very lucrative advertising screen. These adverts are on a constant rotation and are seen by potentially thousands of people per week, passing through these busy premises we install them in.
"Making you money from day one"
THE BUSINESS
Our Mobile Phone Business Model is unique because it has 3 potential income streams, vending, advertising and commission!!
Mobile Phone Charging Stations are located and installed by us, in local venues in your chosen area, near you. You will probably know your area better than we do, so if you wish (optional) nominate any sites, venues, you would like your stations to be installed in, and we will approach these sites on your behalf, and do our best to place them there. If not, don't worry, just sit back and let our specialist team do their work. We have access to all the business data in your area. So, you do not have to approach them, we'll do everything for you!
Everyone has run out of charge at one point or another while out and about. Imagine having 5, 10 or 20 of these stations in and around your local area, all collecting £1 per charge every time someone is running low, or runs out of charge. Not only will our Mobile Phone Charging Stations offer you the traditional ease of collecting your vending revenue, but they also have digital advertising screens, which bring you the unique opportunity of a greater additional income.
You can significantly increase your revenue by selling advertising space on your Mobile Phone Charging Stations.
"Selling the advertising space is easy"
Local businesses will pay you to advertise on your stations, charging them just £5, £10 or £20 per month, depending how many stations you have. It's so cheap to advertise on these stations, there is no real reason not to advertise, especially because so many people can view these adverts in busy premises.
"Think about it"
How many people will pass through busy pubs, clubs, shopping centres, etc on a weekly basis? Hundreds, even thousands depending on the venue and how many venues you have! There are literally billions of mobile phone users around the world.
It's much cheaper to advertise with you on your stations, than say, your local newspaper classifieds. So, you can easily sell your advertising space to local businesses, even without any experience, as we will show you how to do it. All you have to do is pick up the phone and let them know what you can offer them!
"An excellent, cheap form of advertising"
Potentially thousands of people will see these adverts each week. The adverts show on a constant rotational basis, 24/7 if the venue is open that long.
"Your charging stations will also advertise for advertisers"
mobile phone charging business modelWe will upload adverts onto your Mobile Phone Charging Stations, these adverts will advertise for new advertisers! Obviously, it makes sense to do this so your charging stations are working for you day and night to generate more advertisers.
If you feel like you wish to operate your own business, with very little effort, but for maximum rewards or even if you've been interested in mobile phone franchises in the past...
"Then this business model is for you!"
It only requires a little extra effort at the beginning, but has massive potential.
"Join our already successful operators"
- We locate the premises for you & fully site of all your charging stations in busy places local to you.
- We supply advertisers to start your business off from day one (dependant on package chosen - Please note: Advertisers supplied are on a free trial basis with the potential to become paid advertisers).
- On-going commission payments of up to £1,000 (Optional)
- Fully liability insurance and warranted machines for 12 months.
- 0844/0843 digital answering system (Never miss a call)
- No royalties to pay…ever!
- FREE Affiliate program membership, earn £££'s
- Full training & on-going support.
"Royalty FREE forever! You keep all the money"
EARNING POTENTIAL
Our figures are based on 100 adverts sold and an average of £100 per month in charging revenue, per machine. So, all you need to decide is how much advertising you wish to sell to generate the income you need and our Mobile Phone Charging Stations will take care of the rest!
"This is what makes our Mobile Phone Charging Stations so unique"
| 2 x MACHINE POTENTIAL INCOME | |
| Advertising Revenue | £10 p/m for 100 adverts = £1,000 p/m |
| Charging Revenue | £100 p/m, per station = £200 p/m |
| Total Revenue | £1,200 per month |
| 3 x MACHINE POTENTIAL INCOME | |
| Advertising Revenue | £15 p/m for 100 adverts = £1,500 p/m |
| Charging Revenue | £100 p/m, per station = £300 p/m |
| Total Revenue | £1,800 per month |
| 5 x MACHINE POTENTIAL INCOME | |
| Advertising Revenue | £20 p/m for 100 adverts = £2,000 p/m |
| Charging Revenue | £100 p/m, per station = £500.00 p/m |
| Total Revenue | £2,500 per month |
| 10 x MACHINE POTENTIAL INCOME | |
| Advertising Revenue | £40 p/m for 100 adverts = £4,000 p/m |
| Charging Revenue | £100 p/m, per station = £1,000 p/m |
| Total Revenue | £5,000 per month |
| 20 x MACHINE POTENTIAL INCOME | |
| Advertising Revenue | £80 p/m for 100 adverts = £8,000 p/m |
| Charging Revenue | £100 p/m, per station = £2,000 p/m |
| Total Revenue | £10,000 per month |
Remember: Simply fill your stations with more advertisers; as local businesses need to advertise locally and at only £10 - £15 - £20 per month to advertise, your stations will be full in no time!
"Digital advertising is the future!"
Remember: Your machines will advertise for advertisers, 24/7 for you or as long as the venue is open. They will sell advertising space for you but slower than selling space yourself! But, if you do not wish to sell advertising space yourself, why not ask a person who is unemployed, or someone who is at home all day, or the odd day, if they want to earn commission for selling your ad space. They'll be glad of the money, as it's easy to sell, and this way it does not cost you anything.
"Remember": The more Mobile Phone Charging Stations you have, the more revenue you'll receive, the more advertisers you'll have and the higher premiums you can charge!
Question - Do they work and will I make money?
Answer - Yes, we know they do, but just ask yourself "would you use this machine?" and the answer is, YES! People gather round them just to try it out, others would like to know if it's safe to drive. The advertising sells, as its cheap and has a massive potential for local businesses.
Question - Why should I invest with you?
Answer - We have years of experience in this field, having installed hundreds of machines over the years! We have staff members with over 20 years experience and guarantee satisfaction. All our business models are tried and tested concepts, and your new business will be set-up professionally and with the minimum of fuss. Unlike many of our competitors, we do not charge any hidden or on-going fees whatsoever and you will own the full rights to your business!
Question - Will I get an exclusive area?
Answer - Yes, but the size will depend on how many machines you order, you decide how large your area will be, by your order. Order more machines and we will increase your area.
Question - How much commission will I have to pay the venue to host my machine?
Answer - We have a good rate of installation, without having to pay any commission. But, if they do insist, we offer them 20% of your usage (Breath test only, not advertising) revenue. We will liaise with you to make sure you're happy, if not; we can move on to another venue. Remember; certain venues are worth paying commission to, plus, you'll sell more advertising space for more money to compensate you for any loss in commission.
Question - How much power do they use?
Answer - Only 12 volts
Question - How much maintenance do they require?
Answer - Not much at all, these machines have hardly any moving parts, so they are very reliable and you only have to fill them with straws when you empty your money every few weeks, so that can't be bad.
Question - Is there any liability to me, if the customer get breathalysed by police, after using the machine?
Answer - No, the machine does not store or record the personal results, plus there is a disclaimer on all machines. Also, only the Police or authorised agents can give a breathalyser test that's legal in court.
Question – How long from application to my business will be up and running?
Answer – On average, subject to the size of your order, around 6-8 weeks, which is mainly in the location of the venues. We do not rush to get anything that comes along, we use our experience to select the venue, we believe will give you the best results.
MACHINE PRICES
Please Note: Our Mobile Phone Charging Stations are available to purchase without the full installation package if required; stations only!
Digitals starting from £795+VAT. (You install yourself)
Non-digitals - £495+VAT. (You install yourself)
"Full installation packages start from £3,995+VAT"
Minimum order is 2 x stations…
Fully sited package 2 x machines start @ £3,995 + VAT
Fully sited package 3 x machines start @ £5,990 + VAT
Fully sited package 4 x machines start @ £7,990 + VAT
Fully sited packages, we offer our most popular model, the CL10 charging station. All package deals are fully located and installed, along with full insurance, advertising, etc! (See the package).
| 5 x machines | |
| Price | £9,595 + VAT |
| 10 x machines | |
| Price | £17,995 + VAT |
| 20 x machines | |
| Price | £29,995 + VAT |
You won't have to lift a finger!

"A full package; means a full package"
We find all your locations for you and site your stations.
"You'll even have adverts to start you off"
Please note: You may, if you wish, nominate places you would like your stations to be sited and we will approach them on your behalf. If you do not wish to nominate, just leave it to us…
C6 Mobile Phone Charging Stations now available!
These stations are for people who do not wish to involve themselves with the advertising side of the business. They are much cheaper to purchase as they do not have digital screens for advertising on them. So, if you like the idea of our Mobile Phone business model, but can't afford, or simply don't wish to involve yourself in the advertising side of the business, and just want to collect revenue, then these machines are for you!.
Exactly the same installation package, just different stations that simply charge mobile phones without the advertising.
"2 x stations, fully sited packages starting from £2,595+VAT"
Install your own machines, supplied only from £495+VAT and delivery.
Minimum order is 2 stations.
Basically these machines will make you money all day from charging revenue, but if you're happy to pick-up the phone, with our help and sell local ad space, you're in the money! We will place your machines in busy places, so selling advertising space will be easy, it just takes a certain type of person, that's the only catch!
Lockable Units (NEW!)
Due to popular demand, we have now added lockable units to our product lineup!
Individual unit costs
4x compartment - (no screen) - £1,600+VAT (£1,920 total)
4x compartment - (with screen) - £1,700+VAT (£2,040 total)
6x compartment - (no screen) - £2,000+VAT (£2,400 total)
6x compartment - (with screen) - £2,100+VAT (£2,580 total)
Full package costs
| Quantity | Unit Type | Price | Total Price |
| 2x | 4 compartment | £6,545+VAT | £7,854 |
| 2x | 6 compartment | £7,395+VAT | £8,874 |
| 3x | 4 compartment | £7,820+VAT | £9,384 |
| 3x | 6 compartment | £9,095+VAT | £10,914 |
| 4x | 4 compartment | £9,095+VAT | £10,914 |
| 4x | 6 compartment | £9,520+VAT | £11,424 |
| 5x | 4 compartment | £9,995+VAT | £11,994 |
| 5x | 6 compartment | £10,995+VAT | £13,194 |


meta
`Prev `__
M
`Next `__
--------------
**meta**: /me´t@/, /may´t@/, /mee´t@/, pref.
[from analytic philosophy] One level of description up. A metasyntactic
variable is a variable in notation used to describe syntax, and
meta-language is language used to describe language. This is difficult
to explain briefly, but much hacker humor turns on deliberate confusion
between meta-levels. See `*hacker humor* <../H/hacker-humor.html>`__.
--------------
+-----------------------------+----------------------------+-----------------------------+
| `Prev `__ | `Up <../M.html>`__ | `Next `__ |
+-----------------------------+----------------------------+-----------------------------+
| mess-dos | `Home <../index.html>`__ | meta bit |
+-----------------------------+----------------------------+-----------------------------+


How to Cook Like Chip and Joanna Gaines For Thanksgiving
by Anna Monette RobertsIf you turn to Chip and Joanna Gaines for your favorite affordable home decor and lifestyle inspiration, then of course you'll want to know how the country couple do Thanksgiving. Luckily, the pair share plenty of original recipes in their quarterly magazine, The Magnolia Journal, in their Magnolia Table cookbook, and on their website. Click the links below to check out some of Chip and Joanna's most delicious-looking recipes that would be the perfect addition to your Thanksgiving menu.
Chip and Joanna Gaines's Thanksgiving Recipes
Friendsgiving Casserole With Holiday Cranberry Sauce
Homemade Thanksgiving Stuffing
Jalapeño Cornbread
Apple Cider With Mulling Spices
No-Bake Pumpkin Cheesecake


(a) As you saw on the previous page, I made a basic game of tetris as my first APW project.
The game is still a work in progress, but I am happy with what i was able to ccomplish so far.
(b) I will most likely finish the Tetris before moving on, but my big project of the year will be to build an online version of Creatr, Archie's and
My genius invention for a democratized maker solution. To accomplish this to a satifactory quality, we will need good web design, secure web structure,
a really....attractive GUI, and maybe a domain. We will work on it and see.
week ending Friday 12/11: Frontend rough-up done; database set up, problem with php between sighnup form and SQL querying
Week ending Friday 12/18: Still hung up on a bug that either can't form SQL queries or can't send queries to myphp database
Week ending Friday 1/08: Still hung up on the problem mentioned previously. New build of HTML and PHP suggests that the problem might not be with the PHP, but with the HTML form.
Week ending Friday 1/15: WE DID IT!!!! I DID IT!!!!!!  HECK YEAH! WHAT A JOURNEY. AS OF SATURDAY 1/16, I, JACOB WEINGARD, USED NODE.JS ROUTING TO SEND HTML HANDLEBARS FORM DATA TO THE MYSQL SERVER. MORE OF A NAVIGATING AROUND THE PROBLEM THAN AN ACTUAL PROBLEM FIX. OH WELL, THE THING WORKS!  IT IS ALLLLL UPHILL FROM HERE. NOW THAT I'VE SUCCESSFULLY DONE THIS, ISHOULD BE MOSTLY SET TO MAKE THE REST OF THE DATABASE CONNECTIONS. I AM UPLOADING THE PROJECT TO MY GITHUB. WOHOOOOOOOOOOOO.
Turns out SQL to Java to HTML parsing is a tad harder than expected. Working on getting profile pages to display custom information based on which user is logged in. another easy add would be adding a second database/HTML form for creating projects.
2/26: Started 14 hour tutorial on graphql with reatctjs and express. won't watch whole thing; i can only rebuild from the ground up so many times. I just expect that some of the info will be helpful. Also: Archie is closer to having a functional copy of my code. I really want to get this thing up and running. shame that programming is so hard.
3/12: This is terrible! I have made NO progress in 2.5-three months. I should call this what it is: I'm code-procrastinating. It is so very awful. I really want to do this thing, but I just haven't for a few weeks. Oh the shame! I will really try to get'r done, but with Archie leaving for bridge soon, I don't know what I will be able to do. I am starting up my super busy college process, so maybe I bit off more than I can chew on my own.
4/10: Began work on teachback topic, familiarizing myself with the C programming language. I will be building a simple project in C to make sure I understand the basics before passing them on. I have also begun to research the history of the language.
5/1: Upgraded the Creatr home page to include a beautiful lantern image I made. The image was partially optimized for web viewing.
5/7: Nothing new to report this week. Ozan might want to join the Creatr team. I want to get the profile page up and functioning or the project posting fuctional before the year's end. Project posting will be easier.


You can switch between Free Practice, Qualifying and Race to see which driver outperforms the other in which area. You can try other drivers as well!
Compare again


|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
| Interface Summary | |
|---|---|
| InstanceProvider<T> | Provides a set of available instances for a service so that a strategy can pick one of them |
| InstanceSerializer<T> | Injectable serializer for service instances |
| ServiceCacheListener | Listener for changes to a service cache |
| Class Summary | |
|---|---|
| JsonInstanceSerializer<T> | A serializer that uses Jackson to serialize/deserialize as JSON. |
| ServiceCache<T> | Maintains a cache of instances for a given named service |
| ServiceDiscoveryImpl<T> | A mechanism to register and query service instances using ZooKeeper |
| ServiceProviderImpl<T> | The main interface for Service Discovery. |
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |


The 3 signals of the torque connector are interpreted as the x-, y- and z-coordinates of a torque acting at the frame connector to which frame_b of this component is attached. Via parameter resolveInFrame it is defined, in which frame these coordinates shall be resolved:
| Types.ResolveInFrameAB. | Meaning |
|---|---|
| world | Resolve input torque in world frame |
| frame_a | Resolve input torque in frame_a |
| frame_b | Resolve input torque in frame_b (= default) |
| frame_resolve | Resolve input torque in frame_resolve (frame_resolve must be connected) |
If resolveInFrame = ResolveInFrameAB.frame_resolve, the torque coordinates are with respect to the frame, that is connected to frame_resolve.
If resolveInFrame is not ResolveInFrameAB.frame_resolve, then the position vector and the orientation object of frame_resolve must be set to constant values from the outside in order that the model remains balanced (these constant values are ignored).


Roommate finder
HOME
Locations
Parklands
Ruaraka
Jogoo Road
Kilimani
About Us
Roommate finder
Roommate finder is an online marketplace where people can find rooms listed on the website.
CONTACT US


Universities
Home
Tests
Groups
Widget
Elsevier
API
Groups
Please, select a group:
ORCID
Name
Email
{{researcher.orcid}}
{{researcher.name}}
{{researcher.email}}


public static class ResourceBundle.Control extends Object
ResourceBundle.Control
defines a set of callback methods
that are invoked by the ResourceBundle.getBundle
factory
methods during the bundle loading process. In other words, a
ResourceBundle.Control
collaborates with the factory
methods for loading resource bundles. The default implementation of
the callback methods provides the information necessary for the
factory methods to perform the default behavior.
In addition to the callback methods, the toBundleName
and toResourceName
methods are defined
primarily for convenience in implementing the callback
methods. However, the toBundleName
method could be
overridden to provide different conventions in the organization and
packaging of localized resources. The toResourceName
method is final
to avoid use of wrong resource and class
name separators.
Two factory methods, getControl(List)
and getNoFallbackControl(List)
, provide
ResourceBundle.Control
instances that implement common
variations of the default bundle loading process.
The formats returned by the getFormats
method and candidate locales returned by the getCandidateLocales
method must be consistent in all
ResourceBundle.getBundle
invocations for the same base
bundle. Otherwise, the ResourceBundle.getBundle
methods
may return unintended bundles. For example, if only
"java.class"
is returned by the getFormats
method for the first call to ResourceBundle.getBundle
and only "java.properties"
for the second call, then the
second call will return the class-based one that has been cached
during the first call.
A ResourceBundle.Control
instance must be thread-safe
if it's simultaneously used by multiple threads.
ResourceBundle.getBundle
does not synchronize to call
the ResourceBundle.Control
methods. The default
implementations of the methods are thread-safe.
Applications can specify ResourceBundle.Control
instances returned by the getControl
factory methods or
created from a subclass of ResourceBundle.Control
to
customize the bundle loading process. The following are examples of
changing the default bundle loading process.
Example 1
The following code lets ResourceBundle.getBundle
look
up only properties-based resources.
import java.util.*; import static java.util.ResourceBundle.Control.*; ... ResourceBundle bundle = ResourceBundle.getBundle("MyResources", new Locale("fr", "CH"), ResourceBundle.Control.getControl(FORMAT_PROPERTIES));Given the resource bundles in the example in the
ResourceBundle.getBundle
description, this
ResourceBundle.getBundle
call loads
MyResources_fr_CH.properties
whose parent is
MyResources_fr.properties
whose parent is
MyResources.properties
. (MyResources_fr_CH.properties
is not hidden, but MyResources_fr_CH.class
is.)
Example 2
The following is an example of loading XML-based bundles
using Properties.loadFromXML
.
ResourceBundle rb = ResourceBundle.getBundle("Messages", new ResourceBundle.Control() { public List<String> getFormats(String baseName) { if (baseName == null) throw new NullPointerException(); return Arrays.asList("xml"); } public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { if (baseName == null || locale == null || format == null || loader == null) throw new NullPointerException(); ResourceBundle bundle = null; if (format.equals("xml")) { String bundleName = toBundleName(baseName, locale); String resourceName = toResourceName(bundleName, format); InputStream stream = null; if (reload) { URL url = loader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for // reloading. connection.setUseCaches(false); stream = connection.getInputStream(); } } } else { stream = loader.getResourceAsStream(resourceName); } if (stream != null) { BufferedInputStream bis = new BufferedInputStream(stream); bundle = new XMLResourceBundle(bis); bis.close(); } } return bundle; } }); ... private static class XMLResourceBundle extends ResourceBundle { private Properties props; XMLResourceBundle(InputStream stream) throws IOException { props = new Properties(); props.loadFromXML(stream); } protected Object handleGetObject(String key) { return props.getProperty(key); } public Enumeration<String> getKeys() { ... } }
| Modifier and Type | Field and Description |
|---|---|
static List<String> |
FORMAT_CLASS
The class-only format
List containing
"java.class" . |
static List<String> |
FORMAT_DEFAULT
The default format
List , which contains the strings
"java.class" and "java.properties" , in
this order. |
static List<String> |
FORMAT_PROPERTIES
The properties-only format
List containing
"java.properties" . |
static long |
TTL_DONT_CACHE
The time-to-live constant for not caching loaded resource bundle
instances.
|
static long |
TTL_NO_EXPIRATION_CONTROL
The time-to-live constant for disabling the expiration control
for loaded resource bundle instances in the cache.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Control()
Sole constructor.
|
| Modifier and Type | Method and Description |
|---|---|
List<Locale> |
getCandidateLocales(String baseName,
Locale locale)
Returns a
List of Locale s as candidate
locales for baseName and locale . |
static ResourceBundle.Control |
getControl(List<String> formats)
|
Locale |
getFallbackLocale(String baseName,
Locale locale)
Returns a
Locale to be used as a fallback locale for
further resource bundle searches by the
ResourceBundle.getBundle factory method. |
List<String> |
getFormats(String baseName)
Returns a
List of String s containing
formats to be used to load resource bundles for the given
baseName . |
static ResourceBundle.Control |
getNoFallbackControl(List<String> formats)
Returns a
ResourceBundle.Control in which the getFormats method returns the specified
formats and the getFallbackLocale
method returns null . |
long |
getTimeToLive(String baseName,
Locale locale)
Returns the time-to-live (TTL) value for resource bundles that
are loaded under this
ResourceBundle.Control . |
boolean |
needsReload(String baseName,
Locale locale,
String format,
ClassLoader loader,
ResourceBundle bundle,
long loadTime)
Determines if the expired
bundle in the cache needs
to be reloaded based on the loading time given by
loadTime or some other criteria. |
ResourceBundle |
newBundle(String baseName,
Locale locale,
String format,
ClassLoader loader,
boolean reload)
Instantiates a resource bundle for the given bundle name of the
given format and locale, using the given class loader if
necessary.
|
String |
toBundleName(String baseName,
Locale locale)
Converts the given
baseName and locale
to the bundle name. |
String |
toResourceName(String bundleName,
String suffix)
Converts the given
bundleName to the form required
by the ClassLoader.getResource
method by replacing all occurrences of '.' in
bundleName with '/' and appending a
'.' and the given file suffix . |
public static final List<String> FORMAT_DEFAULT
List
, which contains the strings
"java.class"
and "java.properties"
, in
this order. This List
is unmodifiable.getFormats(String)
public static final List<String> FORMAT_CLASS
getFormats(String)
public static final List<String> FORMAT_PROPERTIES
getFormats(String)
public static final long TTL_DONT_CACHE
public static final long TTL_NO_EXPIRATION_CONTROL
protected Control()
public static final ResourceBundle.Control getControl(List<String> formats)
ResourceBundle.Control
in which the getFormats
method returns the specified
formats
. The formats
must be equal to
one of FORMAT_PROPERTIES
, FORMAT_CLASS
or FORMAT_DEFAULT
. ResourceBundle.Control
instances returned by this method are singletons and thread-safe.
Specifying FORMAT_DEFAULT
is equivalent to
instantiating the ResourceBundle.Control
class,
except that this method returns a singleton.
formats
- the formats to be returned by the
ResourceBundle.Control.getFormats
methodResourceBundle.Control
supporting the
specified formats
NullPointerException
- if formats
is null
IllegalArgumentException
- if formats
is unknownpublic static final ResourceBundle.Control getNoFallbackControl(List<String> formats)
ResourceBundle.Control
in which the getFormats
method returns the specified
formats
and the getFallbackLocale
method returns null
. The formats
must
be equal to one of FORMAT_PROPERTIES
, FORMAT_CLASS
or FORMAT_DEFAULT
.
ResourceBundle.Control
instances returned by this
method are singletons and thread-safe.formats
- the formats to be returned by the
ResourceBundle.Control.getFormats
methodResourceBundle.Control
supporting the
specified formats
with no fallback
Locale
supportNullPointerException
- if formats
is null
IllegalArgumentException
- if formats
is unknownpublic List<String> getFormats(String baseName)
List
of String
s containing
formats to be used to load resource bundles for the given
baseName
. The ResourceBundle.getBundle
factory method tries to load resource bundles with formats in the
order specified by the list. The list returned by this method
must have at least one String
. The predefined
formats are "java.class"
for class-based resource
bundles and "java.properties"
for properties-based ones. Strings starting
with "java."
are reserved for future extensions and
must not be used by application-defined formats.
It is not a requirement to return an immutable (unmodifiable)
List
. However, the returned List
must
not be mutated after it has been returned by
getFormats
.
The default implementation returns FORMAT_DEFAULT
so
that the ResourceBundle.getBundle
factory method
looks up first class-based resource bundles, then
properties-based ones.
baseName
- the base name of the resource bundle, a fully qualified class
nameList
of String
s containing
formats for loading resource bundles.NullPointerException
- if baseName
is nullFORMAT_DEFAULT
,
FORMAT_CLASS
,
FORMAT_PROPERTIES
public List<Locale> getCandidateLocales(String baseName, Locale locale)
List
of Locale
s as candidate
locales for baseName
and locale
. This
method is called by the ResourceBundle.getBundle
factory method each time the factory method tries finding a
resource bundle for a target Locale
.
The sequence of the candidate locales also corresponds to the runtime resource lookup path (also known as the parent chain), if the corresponding resource bundles for the candidate locales exist and their parents are not defined by loaded resource bundles themselves. The last element of the list must be a root locale if it is desired to have the base bundle as the terminal of the parent chain.
If the given locale is equal to Locale.ROOT
(the
root locale), a List
containing only the root
Locale
must be returned. In this case, the
ResourceBundle.getBundle
factory method loads only
the base bundle as the resulting resource bundle.
It is not a requirement to return an immutable (unmodifiable)
List
. However, the returned List
must not
be mutated after it has been returned by
getCandidateLocales
.
The default implementation returns a List
containing
Locale
s using the rules described below. In the
description below, L, S, C and V
respectively represent non-empty language, script, country, and
variant. For example, [L, C] represents a
Locale
that has non-empty values only for language and
country. The form L("xx") represents the (non-empty)
language value is "xx". For all cases, Locale
s whose
final component values are empty strings are omitted.
Locale
with an empty script value,
append candidate Locale
s by omitting the final component
one by one as below:
Locale.ROOT
Locale
with a non-empty script value,
append candidate Locale
s by omitting the final component
up to language, then append candidates generated from the
Locale
with country and variant restored:
Locale.ROOT
Locale
with a variant value consisting
of multiple subtags separated by underscore, generate candidate
Locale
s by omitting the variant subtags one by one, then
insert them after every occurrence of Locale
s with the
full variant value in the original list. For example, if the
the variant consists of two subtags V1 and V2:
Locale.ROOT
Locale
has the
language "zh" (Chinese) and an empty script value, either "Hans" (Simplified) or
"Hant" (Traditional) might be supplied, depending on the country.
When the country is "CN" (China) or "SG" (Singapore), "Hans" is supplied.
When the country is "HK" (Hong Kong SAR China), "MO" (Macau SAR China),
or "TW" (Taiwan), "Hant" is supplied. For all other countries or when the country
is empty, no script is supplied. For example, for Locale("zh", "CN")
, the candidate list will be:
Locale.ROOT
Locale("zh", "TW")
, the candidate list will be:
Locale.ROOT
Locale("no", "NO",
"NY")
and Locale("nn", "NO")
represent Norwegian
Nynorsk. When a locale's language is "nn", the standard candidate
list is generated up to [L("nn")], and then the following
candidates are added:
Locale.ROOT
Locale("no", "NO", "NY")
, it is first
converted to Locale("nn", "NO")
and then the above procedure is
followed.
Also, Java treats the language "no" as a synonym of Norwegian
Bokmål "nb". Except for the single case Locale("no",
"NO", "NY")
(handled above), when an input Locale
has language "no" or "nb", candidate Locale
s with
language code "no" and "nb" are interleaved, first using the
requested language, then using its synonym. For example,
Locale("nb", "NO", "POSIX")
generates the following
candidate list:
Locale.ROOT
Locale("no", "NO", "POSIX")
would generate the same list
except that locales with "no" would appear before the corresponding
locales with "nb".The default implementation uses an ArrayList
that
overriding implementations may modify before returning it to the
caller. However, a subclass must not modify it after it has
been returned by getCandidateLocales
.
For example, if the given baseName
is "Messages"
and the given locale
is
Locale("ja", "", "XX")
, then a
List
of Locale
s:
Locale("ja", "", "XX") Locale("ja") Locale.ROOTis returned. And if the resource bundles for the "ja" and ""
Locale
s are found, then the runtime resource
lookup path (parent chain) is:
Messages_ja -> Messages
baseName
- the base name of the resource bundle, a fully
qualified class namelocale
- the locale for which a resource bundle is desiredList
of candidate
Locale
s for the given locale
NullPointerException
- if baseName
or locale
is
null
public Locale getFallbackLocale(String baseName, Locale locale)
Locale
to be used as a fallback locale for
further resource bundle searches by the
ResourceBundle.getBundle
factory method. This method
is called from the factory method every time when no resulting
resource bundle has been found for baseName
and
locale
, where locale is either the parameter for
ResourceBundle.getBundle
or the previous fallback
locale returned by this method.
The method returns null
if no further fallback
search is desired.
The default implementation returns the default Locale
if the given
locale
isn't the default one. Otherwise,
null
is returned.
baseName
- the base name of the resource bundle, a fully
qualified class name for which
ResourceBundle.getBundle
has been
unable to find any resource bundles (except for the
base bundle)locale
- the Locale
for which
ResourceBundle.getBundle
has been
unable to find any resource bundles (except for the
base bundle)Locale
for the fallback search,
or null
if no further fallback search
is desired.NullPointerException
- if baseName
or locale
is null
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException
null
if there is no
resource bundle available for the given parameters. If a resource
bundle can't be instantiated due to an unexpected error, the
error must be reported by throwing an Error
or
Exception
rather than simply returning
null
.
If the reload
flag is true
, it
indicates that this method is being called because the previously
loaded resource bundle has expired.
The default implementation instantiates a
ResourceBundle
as follows.
toBundleName(baseName,
locale)
.format
is "java.class"
, the
Class
specified by the bundle name is loaded by calling
ClassLoader.loadClass(String)
. Then, a
ResourceBundle
is instantiated by calling Class.newInstance()
. Note that the reload
flag is
ignored for loading class-based resource bundles in this default
implementation.format
is "java.properties"
,
toResourceName(bundlename,
"properties")
is called to get the resource name.
If reload
is true
, load.getResource
is called
to get a URL
for creating a URLConnection
. This URLConnection
is used to
disable the
caches of the underlying resource loading layers,
and to get an
InputStream
.
Otherwise, loader.getResourceAsStream
is called to get an InputStream
. Then, a PropertyResourceBundle
is constructed with the
InputStream
.format
is neither "java.class"
nor "java.properties"
, an
IllegalArgumentException
is thrown.baseName
- the base bundle name of the resource bundle, a fully
qualified class namelocale
- the locale for which the resource bundle should be
instantiatedformat
- the resource bundle format to be loadedloader
- the ClassLoader
to use to load the bundlereload
- the flag to indicate bundle reloading; true
if reloading an expired resource bundle,
false
otherwisenull
if none could be found.NullPointerException
- if bundleName
, locale
,
format
, or loader
is
null
, or if null
is returned by
toBundleName
IllegalArgumentException
- if format
is unknown, or if the resource
found for the given parameters contains malformed data.ClassCastException
- if the loaded class cannot be cast to ResourceBundle
IllegalAccessException
- if the class or its nullary constructor is not
accessible.InstantiationException
- if the instantiation of a class fails for some other
reason.ExceptionInInitializerError
- if the initialization provoked by this method fails.SecurityException
- If a security manager is present and creation of new
instances is denied. See Class.newInstance()
for details.IOException
- if an error occurred when reading resources using
any I/O operationspublic long getTimeToLive(String baseName, Locale locale)
ResourceBundle.Control
. Positive time-to-live values
specify the number of milliseconds a bundle can remain in the
cache without being validated against the source data from which
it was constructed. The value 0 indicates that a bundle must be
validated each time it is retrieved from the cache. TTL_DONT_CACHE
specifies that loaded resource bundles are not
put in the cache. TTL_NO_EXPIRATION_CONTROL
specifies
that loaded resource bundles are put in the cache with no
expiration control.
The expiration affects only the bundle loading process by the
ResourceBundle.getBundle
factory method. That is,
if the factory method finds a resource bundle in the cache that
has expired, the factory method calls the needsReload
method to determine whether the resource
bundle needs to be reloaded. If needsReload
returns
true
, the cached resource bundle instance is removed
from the cache. Otherwise, the instance stays in the cache,
updated with the new TTL value returned by this method.
All cached resource bundles are subject to removal from the cache due to memory constraints of the runtime environment. Returning a large positive value doesn't mean to lock loaded resource bundles in the cache.
The default implementation returns TTL_NO_EXPIRATION_CONTROL
.
baseName
- the base name of the resource bundle for which the
expiration value is specified.locale
- the locale of the resource bundle for which the
expiration value is specified.TTL_NO_EXPIRATION_CONTROL
to disable the
expiration control, or TTL_DONT_CACHE
to disable
caching.NullPointerException
- if baseName
or locale
is
null
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)
bundle
in the cache needs
to be reloaded based on the loading time given by
loadTime
or some other criteria. The method returns
true
if reloading is required; false
otherwise. loadTime
is a millisecond offset since
the Calendar
Epoch.
The calling ResourceBundle.getBundle
factory method
calls this method on the ResourceBundle.Control
instance used for its current invocation, not on the instance
used in the invocation that originally loaded the resource
bundle.
The default implementation compares loadTime
and
the last modified time of the source data of the resource
bundle. If it's determined that the source data has been modified
since loadTime
, true
is
returned. Otherwise, false
is returned. This
implementation assumes that the given format
is the
same string as its file suffix if it's not one of the default
formats, "java.class"
or
"java.properties"
.
baseName
- the base bundle name of the resource bundle, a
fully qualified class namelocale
- the locale for which the resource bundle
should be instantiatedformat
- the resource bundle format to be loadedloader
- the ClassLoader
to use to load the bundlebundle
- the resource bundle instance that has been expired
in the cacheloadTime
- the time when bundle
was loaded and put
in the cachetrue
if the expired bundle needs to be
reloaded; false
otherwise.NullPointerException
- if baseName
, locale
,
format
, loader
, or
bundle
is null
public String toBundleName(String baseName, Locale locale)
baseName
and locale
to the bundle name. This method is called from the default
implementation of the newBundle
and needsReload
methods.
This implementation returns the following value:
baseName + "_" + language + "_" + script + "_" + country + "_" + variantwhere
language
, script
, country
,
and variant
are the language, script, country, and variant
values of locale
, respectively. Final component values that
are empty Strings are omitted along with the preceding '_'. When the
script is empty, the script value is omitted along with the preceding '_'.
If all of the values are empty strings, then baseName
is returned.
For example, if baseName
is
"baseName"
and locale
is
Locale("ja", "", "XX")
, then
"baseName_ja_ _XX"
is returned. If the given
locale is Locale("en")
, then
"baseName_en"
is returned.
Overriding this method allows applications to use different conventions in the organization and packaging of localized resources.
baseName
- the base name of the resource bundle, a fully
qualified class namelocale
- the locale for which a resource bundle should be
loadedNullPointerException
- if baseName
or locale
is null
public final String toResourceName(String bundleName, String suffix)
bundleName
to the form required
by the ClassLoader.getResource
method by replacing all occurrences of '.'
in
bundleName
with '/'
and appending a
'.'
and the given file suffix
. For
example, if bundleName
is
"foo.bar.MyResources_ja_JP"
and suffix
is "properties"
, then
"foo/bar/MyResources_ja_JP.properties"
is returned.bundleName
- the bundle namesuffix
- the file type suffixNullPointerException
- if bundleName
or suffix
is null
Dracula Javadoc Sample, Made with Allan Im.


Alloy models may contain "open" statements, like this one:
open util/integer
The Alloy "open" statement is roughly similar to the Java "import" or the C/C++ "include" in that it tells the tool to look at some source in another file.
Alloy will look for util/integer.als in two places:
First of all, if the module is one of the sample model that comes with Alloy 4, it will load it.
This includes all the "util" modules
such as util/ordering and util/boolean, as well as the example models such as examples/algorithms/dijkstra.
You can see the list of sample models by clicking on the File menu, then click on "open sample models".
Failing that, it will infer the location of the file based on the location of the current model and the name of the current model.
For example, let's suppose we are analyzing the model "C:\Desktop\main.als"
with the following content:
model filesystem/main open filesystem/debug as DEBUG open filesystem/library/dirmodel as DIR open filesystem/library/filemodel as FILE
The "filesystem/debug" module is on the same level as "filesystem/main", so we will infer that it is at C:\Desktop\debug.als
The dirmodel and filemodel are in a subdirectory called "library", so we will infer that they are at C:\Desktop\library\dirmodel.als and C:\Desktop\library\filemodel.als


Templatitator helps you structure your content in an object-like fashion.
Let us have a list of animals:
{
animals: [
{
animal_type: 'Dog',
name: 'Rufus',
barks: true
},
{
animal_type: 'Parrot',
name: 'Pedro',
talks: false
},
]
}
and you want to be able to add either a dog or a parrot to the list. Notice their properties are different, dog can bark and parrot can talk. What you do is you create templates for each of these animals:
{
animal_types: {
dog: {
animal_type: 'dog',
name: '',
barks: false
},
parrot: {
animal_type: 'parrot',
name: '',
talks: false
},
}
}
And then use the cool templatitator feature to enable user to select from these two animal types:
{
$animals_templatitator: '@@animal_types',
animals: []
}
Now user has a nice way to add either a parrot or a dog to his animal list:
If you just want to quickly see how this works in your project, just copy/paste this into your context file:
{
$animal_types_hidden: true,
animal_types: {
dog: {
$animal_type_type: 'title',
animal_type: 'dog',
name: '',
barks: false
},
parrot: {
$animal_type_type: 'title',
animal_type: 'parrot',
name: '',
talks: false
},
},
$animals_templatitator: '@@animal_types',
animals: [],
}
Whatever you place in global/templates folder will not be visible in admin ui, what is very convenient for storing templatitator templates, such as the animal types above.
Who wants to have a huge file with ten templates, right? You can easily split the templates into more files:
/cms/global/templates/animals/dog.js
animal_types: {
dog: {
$animal_type_type: 'title',
animal_type: 'dog',
name: '',
barks: false
},
},
/cms/global/templates/animals/parrot.js
animal_types: {
parrot: {
$animal_type_type: 'title',
animal_type: 'parrot',
name: '',
talks: false
},
},
enduro will merge both dog and parrot into single animal_types object. Since it's located in cms/global directory it will be accessible by:
{
$animals_templatitator: '@@global.animal_types',
animals: [],
}


| Top |
| GtkListStore * | gtk_list_store_new () |
| GtkListStore * | gtk_list_store_newv () |
| void | gtk_list_store_set_column_types () |
| void | gtk_list_store_set () |
| void | gtk_list_store_set_valist () |
| void | gtk_list_store_set_value () |
| void | gtk_list_store_set_valuesv () |
| gboolean | gtk_list_store_remove () |
| void | gtk_list_store_insert () |
| void | gtk_list_store_insert_before () |
| void | gtk_list_store_insert_after () |
| void | gtk_list_store_insert_with_values () |
| void | gtk_list_store_insert_with_valuesv () |
| void | gtk_list_store_prepend () |
| void | gtk_list_store_append () |
| void | gtk_list_store_clear () |
| gboolean | gtk_list_store_iter_is_valid () |
| void | gtk_list_store_reorder () |
| void | gtk_list_store_swap () |
| void | gtk_list_store_move_before () |
| void | gtk_list_store_move_after () |
GtkListStore implements GtkTreeModel, GtkTreeDragSource, GtkTreeDragDest, GtkTreeSortable and GtkBuildable.
The GtkListStore object is a list model for use with a GtkTreeView widget. It implements the GtkTreeModel interface, and consequentialy, can use all of the methods available there. It also implements the GtkTreeSortable interface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces.
The GtkListStore can accept most GObject types as a column type, though
it can’t accept all custom types. Internally, it will keep a copy of
data passed in (such as a string or a boxed pointer). Columns that
accept GObjects are handled a little differently. The
GtkListStore will keep a reference to the object instead of copying the
value. As a result, if the object is modified, it is up to the
application writer to call gtk_tree_model_row_changed()
to emit the
“row_changed” signal. This most commonly affects lists with
GdkPixbufs stored.
An example for creating a simple list store:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
enum { COLUMN_STRING, COLUMN_INT, COLUMN_BOOLEAN, N_COLUMNS }; { GtkListStore *list_store; GtkTreePath *path; GtkTreeIter iter; gint i; list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN); for (i = 0; i < 10; i++) { gchar *some_data; some_data = get_some_data (i); // Add a new row to the model gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, COLUMN_STRING, some_data, COLUMN_INT, i, COLUMN_BOOLEAN, FALSE, -1); // As the store will keep a copy of the string internally, // we free some_data. g_free (some_data); } // Modify a particular row path = gtk_tree_path_new_from_string ("4"); gtk_tree_model_get_iter (GTK_TREE_MODEL (list_store), &iter, path); gtk_tree_path_free (path); gtk_list_store_set (list_store, &iter, COLUMN_BOOLEAN, TRUE, -1); } |
Internally, the GtkListStore was implemented with a linked list with a tail pointer prior to GTK+ 2.6. As a result, it was fast at data insertion and deletion, and not fast at random data access. The GtkListStore sets the GTK_TREE_MODEL_ITERS_PERSIST flag, which means that GtkTreeIters can be cached while the row exists. Thus, if access to a particular row is needed often and your code is expected to run on older versions of GTK+, it is worth keeping the iter around.
It is important to note that only the methods
gtk_list_store_insert_with_values()
and gtk_list_store_insert_with_valuesv()
are atomic, in the sense that the row is being appended to the store and the
values filled in in a single operation with regard to GtkTreeModel signaling.
In contrast, using e.g. gtk_list_store_append()
and then gtk_list_store_set()
will first create a row, which triggers the “row-inserted” signal
on GtkListStore. The row, however, is still empty, and any signal handler
connecting to “row-inserted” on this particular store should be prepared
for the situation that the row might be empty. This is especially important
if you are wrapping the GtkListStore inside a GtkTreeModelFilter and are
using a GtkTreeModelFilterVisibleFunc. Using any of the non-atomic operations
to append rows to the GtkListStore will cause the
GtkTreeModelFilterVisibleFunc to be visited with an empty row first; the
function must be prepared for that.
The GtkListStore implementation of the GtkBuildable interface allows to specify the model columns with a <columns> element that may contain multiple <column> elements, each specifying one model column. The “type” attribute specifies the data type for the column.
Additionally, it is possible to specify content for the list store in the UI definition, with the <data> element. It can contain multiple <row> elements, each specifying to content for one row of the list model. Inside a <row>, the <col> elements specify the content for individual cells.
Note that it is probably more common to define your models in the code, and one might consider it a layering violation to specify the content of a list store in a UI definition, data, not presentation, and common wisdom is to separate the two, as far as possible.
An example of a UI Definition fragment for a list store:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<object class="GtkListStore"> <columns> <column type="gchararray"/> <column type="gchararray"/> <column type="gint"/> </columns> <data> <row> <col id="0">John</col> <col id="1">Doe</col> <col id="2">25</col> </row> <row> <col id="0">Johan</col> <col id="1">Dahlin</col> <col id="2">50</col> </row> </data> </object> |
GtkListStore * gtk_list_store_new (gint n_columns
,...
);
Creates a new list store as with n_columns
columns each of the types passed
in. Note that only types derived from standard GObject fundamental types
are supported.
As an example, gtk_list_store_new (3, G_TYPE_INT, G_TYPE_STRING,
GDK_TYPE_PIXBUF);
will create a new GtkListStore with three columns, of type
int, string and GdkPixbuf respectively.
n_columns |
number of columns in the list store |
|
... |
all GType types for the columns, from first to last |
GtkListStore * gtk_list_store_newv (gint n_columns
,GType *types
);
Non-vararg creation function. Used primarily by language bindings.
[rename-to gtk_list_store_new]
n_columns |
number of columns in the list store |
|
types |
an array of GType types for the columns, from first to last. |
[array length=n_columns] |
void gtk_list_store_set_column_types (GtkListStore *list_store
,gint n_columns
,GType *types
);
This function is meant primarily for GObjects that inherit from GtkListStore, and should only be used when constructing a new GtkListStore. It will not function after a row has been added, or a method on the GtkTreeModel interface is called.
list_store |
||
n_columns |
Number of columns for the list store |
|
types |
An array length n of GTypes. |
[array length=n_columns] |
void gtk_list_store_set (GtkListStore *list_store
,GtkTreeIter *iter
,...
);
Sets the value of one or more cells in the row referenced by iter
.
The variable argument list should contain integer column numbers,
each column number followed by the value to be set.
The list is terminated by a -1. For example, to set column 0 with type
G_TYPE_STRING
to “Foo”, you would write gtk_list_store_set (store, iter,
0, "Foo", -1)
.
The value will be referenced by the store if it is a G_TYPE_OBJECT
, and it
will be copied if it is a G_TYPE_STRING
or G_TYPE_BOXED
.
void gtk_list_store_set_valist (GtkListStore *list_store
,GtkTreeIter *iter
,va_list var_args
);
See gtk_list_store_set()
; this version takes a va_list for use by language
bindings.
list_store |
||
iter |
A valid GtkTreeIter for the row being modified |
|
var_args |
va_list of column/value pairs |
void gtk_list_store_set_value (GtkListStore *list_store
,GtkTreeIter *iter
,gint column
,GValue *value
);
Sets the data in the cell specified by iter
and column
.
The type of value
must be convertible to the type of the
column.
list_store |
||
iter |
A valid GtkTreeIter for the row being modified |
|
column |
column number to modify |
|
value |
new value for the cell |
void gtk_list_store_set_valuesv (GtkListStore *list_store
,GtkTreeIter *iter
,gint *columns
,GValue *values
,gint n_values
);
A variant of gtk_list_store_set_valist()
which
takes the columns and values as two arrays, instead of
varargs. This function is mainly intended for
language-bindings and in case the number of columns to
change is not known until run-time.
[rename-to gtk_list_store_set]
list_store |
||
iter |
A valid GtkTreeIter for the row being modified |
|
columns |
an array of column numbers. |
[array length=n_values] |
values |
an array of GValues. |
[array length=n_values] |
n_values |
the length of the |
Since: 2.12
gboolean gtk_list_store_remove (GtkListStore *list_store
,GtkTreeIter *iter
);
Removes the given row from the list store. After being removed,
iter
is set to be the next valid row, or invalidated if it pointed
to the last row in list_store
.
void gtk_list_store_insert (GtkListStore *list_store
,GtkTreeIter *iter
,gint position
);
Creates a new row at position
. iter
will be changed to point to this new
row. If position
is -1 or is larger than the number of rows on the list,
then the new row will be appended to the list. The row will be empty after
this function is called. To fill in values, you need to call
gtk_list_store_set()
or gtk_list_store_set_value()
.
list_store |
||
iter |
An unset GtkTreeIter to set to the new row. |
[out] |
position |
position to insert the new row, or -1 for last |
void gtk_list_store_insert_before (GtkListStore *list_store
,GtkTreeIter *iter
,GtkTreeIter *sibling
);
Inserts a new row before sibling
. If sibling
is NULL
, then the row will
be appended to the end of the list. iter
will be changed to point to this
new row. The row will be empty after this function is called. To fill in
values, you need to call gtk_list_store_set()
or gtk_list_store_set_value()
.
list_store |
||
iter |
An unset GtkTreeIter to set to the new row. |
[out] |
sibling |
A valid GtkTreeIter, or |
[allow-none] |
void gtk_list_store_insert_after (GtkListStore *list_store
,GtkTreeIter *iter
,GtkTreeIter *sibling
);
Inserts a new row after sibling
. If sibling
is NULL
, then the row will be
prepended to the beginning of the list. iter
will be changed to point to
this new row. The row will be empty after this function is called. To fill
in values, you need to call gtk_list_store_set()
or gtk_list_store_set_value()
.
list_store |
||
iter |
An unset GtkTreeIter to set to the new row. |
[out] |
sibling |
A valid GtkTreeIter, or |
[allow-none] |
void gtk_list_store_insert_with_values (GtkListStore *list_store
,GtkTreeIter *iter
,gint position
,...
);
Creates a new row at position
. iter
will be changed to point to this new
row. If position
is -1, or larger than the number of rows in the list, then
the new row will be appended to the list. The row will be filled with the
values given to this function.
Calling
gtk_list_store_insert_with_values (list_store, iter, position...)
has the same effect as calling
1 2 |
gtk_list_store_insert (list_store, iter, position); gtk_list_store_set (list_store, iter, ...); |
with the difference that the former will only emit a row_inserted signal,
while the latter will emit row_inserted, row_changed and, if the list store
is sorted, rows_reordered. Since emitting the rows_reordered signal
repeatedly can affect the performance of the program,
gtk_list_store_insert_with_values()
should generally be preferred when
inserting rows in a sorted list store.
list_store |
||
iter |
An unset GtkTreeIter to set to the new row, or |
[out][allow-none] |
position |
position to insert the new row, or -1 to append after existing rows |
|
... |
pairs of column number and value, terminated with -1 |
Since: 2.6
void gtk_list_store_insert_with_valuesv (GtkListStore *list_store
,GtkTreeIter *iter
,gint position
,gint *columns
,GValue *values
,gint n_values
);
A variant of gtk_list_store_insert_with_values()
which
takes the columns and values as two arrays, instead of
varargs. This function is mainly intended for
language-bindings.
list_store |
||
iter |
An unset GtkTreeIter to set to the new row, or |
[out][allow-none] |
position |
position to insert the new row, or -1 for last |
|
columns |
an array of column numbers. |
[array length=n_values] |
values |
an array of GValues. |
[array length=n_values] |
n_values |
the length of the |
Since: 2.6
void gtk_list_store_prepend (GtkListStore *list_store
,GtkTreeIter *iter
);
Prepends a new row to list_store
. iter
will be changed to point to this new
row. The row will be empty after this function is called. To fill in
values, you need to call gtk_list_store_set()
or gtk_list_store_set_value()
.
void gtk_list_store_append (GtkListStore *list_store
,GtkTreeIter *iter
);
Appends a new row to list_store
. iter
will be changed to point to this new
row. The row will be empty after this function is called. To fill in
values, you need to call gtk_list_store_set()
or gtk_list_store_set_value()
.
void
gtk_list_store_clear (GtkListStore *list_store
);
Removes all rows from the list store.
gboolean gtk_list_store_iter_is_valid (GtkListStore *list_store
,GtkTreeIter *iter
);
This function is slow. Only use it for debugging and/or testing purposes.
Checks if the given iter is a valid iter for this GtkListStore.
Since: 2.2
void gtk_list_store_reorder (GtkListStore *store
,gint *new_order
);
Reorders store
to follow the order indicated by new_order
. Note that
this function only works with unsorted stores.
store |
A GtkListStore. |
|
new_order |
an array of integers mapping the new
position of each child to its old position before the re-ordering,
i.e. |
[array zero-terminated=1] |
Since: 2.2
void gtk_list_store_swap (GtkListStore *store
,GtkTreeIter *a
,GtkTreeIter *b
);
Swaps a
and b
in store
. Note that this function only works with
unsorted stores.
Since: 2.2
void gtk_list_store_move_before (GtkListStore *store
,GtkTreeIter *iter
,GtkTreeIter *position
);
Moves iter
in store
to the position before position
. Note that this
function only works with unsorted stores. If position
is NULL
, iter
will be moved to the end of the list.
Since: 2.2
void gtk_list_store_move_after (GtkListStore *store
,GtkTreeIter *iter
,GtkTreeIter *position
);
Moves iter
in store
to the position after position
. Note that this
function only works with unsorted stores. If position
is NULL
, iter
will be moved to the start of the list.
Since: 2.2


--- layout: page title: "Developing Web Applications with Haskell and Yesod" prev: OEBPS/ch03s09.html next: OEBPS/ch04s02.html book_path: books/michael-snoyman-developing-web-applications-with-haskell-and-yesod-_oeb/ --- {% include JB/setup %} {% raw %}
Yesod uses the Shakespearean family of template languages as its standard approach to HTML, CSS, and JavaScript creation. This language family shares some common syntax, as well as overarching principles:
As little interference to the underlying language as possible, while providing conveniences where unobtrusive
Compile-time guarantees on well-formed content
Static type safety, greatly helping the prevention of XSS (cross-site scripting) attacks
Automated checking of valid URLs, whenever possible, through type-safe URLs
There is nothing inherently tying Yesod to these languages, or the other way around: each can be used independently of the other. This chapter will address these template languages on their own, while the remainder of the book will use them to enhance Yesod application development.
There are four main languages at play: Hamlet is an HTML templating language, Julius is for JavaScript, and Cassius and Lucius are both for CSS. Hamlet and Cassius are both whitespace-sensitive formats, using indentation to denote nesting. By contrast, Lucius is a superset of CSS, keeping CSS’s braces for denoting nesting. Julius is a simple passthrough language for producing JavaScript; the only added feature is variable interpolation.
$doctype 5   <title>#{pageTitle} - My Site <link rel=stylesheet href=@{Stylesheet}>
#{pageTitle}
Here is a list of your friends: $if null friends
Sorry, I lied, you don't have any friends. $else
 $forall Friend name age <- friends
#{name} (#{age} years old) ^{copyright}