|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.i18n.java; import java.io.IOException; import java.text.MessageFormat; import org.netbeans.modules.i18n.I18nUtil; import org.netbeans.modules.i18n.ResourceHolder; import org.netbeans.modules.properties.BundleStructure; import org.netbeans.modules.properties.Element; import org.netbeans.modules.properties.PropertiesDataObject; import org.netbeans.modules.properties.PropertiesStructure; import org.netbeans.modules.properties.UtilConvert; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileSystem; import org.openide.filesystems.Repository; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; /** * Resource holder java sources. Now supports .properties bundle files only. * * @author Peter Zavadsky */ public class JavaResourceHolder extends ResourceHolder { /** Constructor. */ public JavaResourceHolder() { super(new Class[] {PropertiesDataObject.class}); } /** Implements superclass abstract method. /* Gets all keys which are stored in underlying resource object. */ public String[] getAllKeys() { if(resource == null) return new String[0]; return ((PropertiesDataObject)resource).getBundleStructure().getKeys(); } /** Implements superclass abstract method. Gets value for specified key. * @return value for key or null if such key os not stored in resource */ public String getValueForKey(String key) { if(resource == null) return null; Element.ItemElem item = getItem(key); return item == null ? null : item.getValue(); } /** Implemenst superclass abstract method. Gets comment for specified key. * @return value for key or null if such key os not stored in resource */ public String getCommentForKey(String key) { if(resource == null) return null; Element.ItemElem item = getItem(key); return item == null ? null : item.getComment(); } /** Helper method. */ private Element.ItemElem getItem(String key) { BundleStructure bundleStructure = ((PropertiesDataObject)resource).getBundleStructure(); if (bundleStructure == null) return null; // Get item from the first file entry which contains the key. // Is looks in default (=primary) entry first. for(int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.