/** * Get the unmodifiable set of keys of the first section. * The set has insertion order. * * @return the keys of the first section */ public Collection<String> getKeys() { IniSection section = getSection(); return section == null ? null : section.getKeys(); }
/** * Get the first value for the key specified by the index and the section. * * @param sectionName the name of the section * @param key the key for the section * @return the value at the specified index * @throws ArrayIndexOutOfBoundsException when the index is out of bounds */ public String getValue(String sectionName, String key) { IniSection section = doGetSection(sectionName); return section == null ? null : section.get(key, 0); }
/** * Get the value for the key specified by the index for the first section. * * @param key the key * @param index the index * @return the value at the specified index * @throws ArrayIndexOutOfBoundsException when the index is out of bounds */ public String getValue(String key, int index) { IniSection section = getSection(); return section == null ? null : section.get(key, index); }
/** * Get a list of the supported translations */ private void loadSupportedTranslations() { if (translations == null) { try { URL index = ResourceUtil.getResource(Translations.class, "translations.txt"); translations = NetUtil.listByIndexFile(NetUtil.toURI(index)); } catch (IOException ex) { translations = new String[0]; } } }
/** * Creates a privileged class loader that finds resources for the calling * class that may not be in the class' package. Use this only within classes * that are directly looking up their resources. * * @return the CrossWire Class Loader */ public static CWClassLoader instance() { Class<? extends Object> resourceOwner = CallContext.getCallingClass(); return instance(resourceOwner); }
@Override public URI getUserAreaFolder(String hiddenFolderName, String visibleFolderName) { return NetUtil.lengthenURI(getUserArea(), visibleFolderName); } },
@Override public URI getUserAreaFolder(String hiddenFolderName, String visibleFolderName) { return NetUtil.lengthenURI(getUserArea(), visibleFolderName); } },
@Override public URI getUserAreaFolder(String hiddenFolderName, String visibleFolderName) { return NetUtil.lengthenURI(getUserArea(), hiddenFolderName); } };
/** * Get the number of values for a key in the first section * * @param key the key * @return the number of values for a key in the first section */ public int getValueSize(String key) { IniSection section = getSection(); return section == null ? 0 : section.size(key); }
/** * Add a value for the key. Duplicate values are not allowed. * * @param key the key for the section * @param value the value for the key * @return whether the value was added or is already present. */ public boolean addValue(String key, String value) { IniSection section = getSection(); return section == null || section.add(key, value); }
/** * List all the strings specified by the index file passed in. To be * acceptable it must be a non-0 length string, not commented with #, and * not the index file itself. * * @param index the URI to list * @return the list. * @throws IOException a problem with I/O happened */ public static String[] listByIndexFile(URI index) throws IOException { return listByIndexFile(index, new DefaultURIFilter()); }
/** * Get the values of a key of the first section. * The collection has insertion order. * Note many keys only have one value. * A key that has no values returns null. * * @param key the key * @return the keyed values or null if the key doesn't exist */ public Collection<String> getValues(String key) { IniSection section = getSection(); return section == null ? null : section.getValues(key); }
/** * Replace a value for a key. * A null for key or value is not allowed. * An empty string for a key is not allowed. * * @param key the key for the section * @param value the value for the key * @return {@code true} if the element was added or already was present */ public boolean replaceValue(String key, String value) { IniSection section = getSection(); return section == null || section.replace(key, value); }
/** * Get and load a properties file from the writable area or if that fails * from the classpath (where a default ought to be stored) * * @param subject * The name of the desired resource (without any extension) * @return The found and loaded properties file * @throws IOException * if the resource can not be loaded */ public static PropertyMap getProperties(String subject) throws IOException { return getProperties(CallContext.getCallingClass(), subject); }
/** * Generic resource URL fetcher. One way or the other we'll find it! Either * as a relative or an absolute reference. * * @param search * The name of the resource (without a leading /) to find * @return The requested resource * @throws MissingResourceException * if the resource can not be found */ public static URL getResource(String search) throws MissingResourceException { return getResource(CallContext.getCallingClass(), search); }
public int getValueSize(String sectionName, String key) { IniSection section = doGetSection(sectionName); return section == null ? 0 : section.size(key); }
@Override public URI getUserArea() { return NetUtil.lengthenURI(getUserHome(), MAC_USER_DATA_AREA); }
@Override public URI getUserArea() { return NetUtil.lengthenURI(getUserHome(), WIN32_USER_DATA_AREA); }
/** * Get the value for the key specified by the index and the section. * * @param sectionName the name of the section * @param key the key for the section * @param index the index in the list of values * @return the value at the specified index * @throws ArrayIndexOutOfBoundsException when the index is out of bounds */ public String getValue(String sectionName, String key, int index) { IniSection section = doGetSection(sectionName); return section == null ? null : section.get(key, index); }
/** * Get the first value for the key in the first section. * * @param key the key * @return the value at the specified index * @throws ArrayIndexOutOfBoundsException when the index is out of bounds */ public String getValue(String key) { IniSection section = getSection(); return section == null ? null : section.get(key); }