/** Construct a new empty dictionary with the given initial capacity. * @param initialCapacity the initial capacity to use */ protected AbstractPropertyDictionary(int initialCapacity) { this.data = NSMutableDictionary.dictionaryWithCapacity(initialCapacity); } /** Construct a new dictionary with the given dictionary.
/** Construct a new dictionary with the given dictionary. * The dictionary <strong>is</strong> copied into a mutable dictionary. * @param data the dictionary to use */ protected AbstractPropertyDictionary(final NSDictionary data) { this.data = NSMutableDictionary.dictionaryWithDictionary(data); } /** Get the underlying dictionary
/** Get the value associated with the given key as a String * @param key the key whose associated value will be returned * @return the value associated with the key as a Java String */ public String getString(E key) { return data.objectForKey(key.getNativeValue()).toString(); }
NSMutableDictionary noteDict = NSMutableDictionary.dictionaryWithCapacity(0); noteDict.setValue_forKey(NSString.stringWithString(inNotificationName), GROWL_NOTIFICATION_NAME); noteDict.setValue_forKey(inTitle != null ? NSString.stringWithString(inTitle) : null, GROWL_NOTIFICATION_TITLE); noteDict.setValue_forKey(inDescription != null ? NSString.stringWithString(inDescription) : null, GROWL_NOTIFICATION_DESCRIPTION); noteDict.setValue_forKey(NSString.stringWithString(appName), GROWL_APP_NAME); if (inIcon != null) { noteDict.setValue_forKey(inIcon.TIFFRepresentation(), GROWL_NOTIFICATION_ICON); noteDict.setValue_forKey(NSNumber.CLASS.numberWithInt(1), GROWL_NOTIFICATION_STICKY); noteDict.setValue_forKey(NSString.stringWithString(inIdentifier), GROWL_NOTIFICATION_IDENTIFIER); noteDict.addEntriesFromDictionary(inExtraInfo);
/** Set the value associated with the given key. * @param key the key whose value will be set * @param value the value to set */ public void setValue(E key, NSObject value) { data.setValue_forKey(value, key.getNativeValue()); }
public Entry(final String spelling, final String phonemes) { this(NSMutableDictionary.dictionaryWithObjectsAndKeys( NSString.stringWithString(phonemes), DictionaryEntryProperty.Phonemes.getNativeValue(), NSString.stringWithString(spelling), DictionaryEntryProperty.Spelling.getNativeValue(), null) ); } public String getSpelling() {
/** Set the value associated with the given key. * @param key the key whose value will be set * @param value the value to set */ public void setString(E key, String value) { data.setValue_forKey(NSString.stringWithString(value), key.getNativeValue()); }
/** Construct a new voice using the given identifier * @param voiceIdentifier the voice to lookup * @throws IllegalArgumentException if the voice identified by <code>voiceIdentifier</code> is not installed */ public NSVoice (String voiceIdentifier) throws IllegalArgumentException { super(NSMutableDictionary.dictionaryWithDictionary( checkData(voiceIdentifier, NSSpeechSynthesizer.CLASS.attributesForVoice(voiceIdentifier)))); }
/** Get the value associated with the given key as an enum * @param key the key whose associated value will be returned * @param nativeEnum the class of the enum, used to resolve native values to the corresponding Java enum values * @return the value associated with the key as a Java Enum * @param <EN> the type of enum to return */ public <EN extends Enum<EN> & NativeEnum<?>> EN getEnum(Class<EN> nativeEnum, E key) { return NativeEnum.Resolver.fromNative(nativeEnum, data.objectForKey(key.getNativeValue())); }
/** Get a list of phonemes the synthesizer uses * @return information about the phonemes the synthesizer uses */ public List<NSSpeechPhonemeInfo> getPhonemeInfo() { NSArray infos = Rococoa.cast(getProperty(SpeechProperty.PhonemeSymbolsProperty), NSArray.class); List<NSSpeechPhonemeInfo> result = new ArrayList<NSSpeechPhonemeInfo>(infos.count()); for(int i=0; i < infos.count(); i++) { NSDictionary phonemeInfo = Rococoa.cast(infos.objectAtIndex(i), NSDictionary.class); result.add(new NSSpeechPhonemeInfo(NSMutableDictionary.dictionaryWithDictionary(phonemeInfo))); } return result; }
/** Get the value associated with the given key as coercing it to the given type. * @param key the key whose associated value will be returned * @param type the subclass of <code>NSObject</code> that the value associated with <code>key</code> will be coerced to * @return the value associated with the key coerced as into <code>type</code> * @param <R> the type to return */ public <R extends NSObject> R getValueAsType(E key, Class<R> type) { NSObject result = data.objectForKey(key.getNativeValue()); return result == null ? null : Rococoa.cast(result, type); }