diff --git a/.gitignore b/.gitignore index 645a374..a6fcc0a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ */*/*/*/target # Inore some artifact dirs; +vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/auto vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/tomcat.* # Ignore leftovers of really failed release build diff --git a/todo.txt b/todo.txt index c0706de..1751146 100644 --- a/todo.txt +++ b/todo.txt @@ -1,11 +1,9 @@ == TODO == -- xml file as argument - x4o template - swing readonly field editor - order by list and edit. - vasc AUTO ID -- textarea size in xml & swing. - new NULL vs "" setting global+per entity - date format list and edit per field. - readonly field icm auto fill field from code/xml @@ -13,11 +11,7 @@ - page sum line - total sum line - graphs support -- mongo backend paging -- meta model backend paging - mongo missing field == string gives; VascBackendProxySort$1.compare(VascBackendProxySort.java:102) -- disable i18n -- load FILE resource bundle (in xml?) - make event channels work - auto text converts - Plugin validation diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java index 7e80e8e..140645c 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java @@ -74,12 +74,41 @@ public class MetaModelVascBackend extends AbstractVascBackend { return dataContext; } - public List execute(VascBackendState state) throws VascException { + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable() + */ + @Override + public boolean isPageable() { + return true; + } + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState) + */ + @Override + public long fetchTotalExecuteSize(VascBackendState state) { UpdateableDataContext dataContext = getUpdateableDataContext(); Schema schema = dataContext.getDefaultSchema(); Table t = schema.getTableByName(table); - - Object qWhere = dataContext.query().from(t).select(t.getColumns()); + Query q = createFilterQuery(state,t,true); + DataSet ds = dataContext.executeQuery(q); + if (ds.next()==false) { + ds.close(); + return -1; + } + Row row = ds.getRow(); + Number result = (Number)row.getValue(0); + ds.close(); + return result.longValue(); + } + + private Query createFilterQuery(VascBackendState state,Table t,boolean count) { + Object qWhere = null; + if (count==false) { + qWhere = getUpdateableDataContext().query().from(t).select(t.getColumns()); + } else { + qWhere = getUpdateableDataContext().query().from(t).selectCount(); + } Iterator keys = state.getDataParameterKeys().iterator(); boolean first = true; while (keys.hasNext()) { @@ -120,9 +149,19 @@ public class MetaModelVascBackend extends AbstractVascBackend { } first = false; } - - Query q = ((SatisfiedQueryBuilder)qWhere).toQuery(); + return q; + } + + public List execute(VascBackendState state) throws VascException { + UpdateableDataContext dataContext = getUpdateableDataContext(); + Schema schema = dataContext.getDefaultSchema(); + Table t = schema.getTableByName(table); + Query q = createFilterQuery(state,t,false); + if (isPageable()) { + q.setFirstRow(state.getPageIndex()); + q.setMaxRows(state.getPageSize()); + } DataSet ds = dataContext.executeQuery(q); List result = new ArrayList(50); while (ds.next()) { diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java index 005a603..f26200a 100644 --- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java @@ -60,16 +60,43 @@ public class MongodbVascBackend extends AbstractVascBackend { logger = Logger.getLogger(MongodbVascBackend.class.getName()); } - public List execute(VascBackendState state) throws VascException { + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable() + */ + @Override + public boolean isPageable() { + return true; + } + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState) + */ + @Override + public long fetchTotalExecuteSize(VascBackendState state) { DBCollection coll = getDBCollection(); + DBObject query = createFilterQuery(state); + long result = coll.count(query); + return result; + } + + private DBObject createFilterQuery(VascBackendState state) { DBObject query = new BasicDBObject(); for (String key:state.getDataParameterKeys()) { Object value = state.getDataParameter(key); query.put(key, value); logger.finer("Setting query parameter key: '"+key+"' value: '"+value+"'"); } + return query; + } + + public List execute(VascBackendState state) throws VascException { + DBCollection coll = getDBCollection(); + DBObject query = createFilterQuery(state); DBCursor cur = coll.find(query); - //cur.count(); + if (isPageable()) { + cur.limit(state.getPageSize()); + cur.skip(state.getPageIndex()); + } List result = new ArrayList(cur.count()); while (cur.hasNext()) { DBObject row = cur.next(); diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/pom.xml index 3979717..304e768 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/pom.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/pom.xml @@ -30,7 +30,7 @@ net.forwardfire.vasc.demo vasc-demo-tech-web ${project.version} - war + net.forwardfire.vasc @@ -67,6 +67,16 @@ vasc-backend-jdbc ${project.version} + + net.forwardfire.vasc.lib + vasc-lib-i18n + ${project.version} + + + net.forwardfire.vasc.test + vasc-test-i18n + ${project.version} + org.jdesktop.bsaf bsaf diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TechUI.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TechUI.java index 7846c20..7d039fb 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TechUI.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TechUI.java @@ -53,7 +53,6 @@ public class TechUI extends SingleFrameApplication { static public void main(String[] args) { Application.launch(TechUI.class, args); - } /** diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/components/JMainPanel.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/components/JMainPanel.java index a736b3e..3b88626 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/components/JMainPanel.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/components/JMainPanel.java @@ -27,6 +27,17 @@ import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -47,6 +58,8 @@ import net.forwardfire.vasc.demo.tech.ui.VascManager; import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration; import net.forwardfire.vasc.frontends.swing.SwingPanelTabbed; import net.forwardfire.vasc.impl.DefaultVascFactory; +import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle_en; +import net.forwardfire.vasc.test.i18n.VascBundleCheckEntryKeys; public class JMainPanel extends JPanel { @@ -123,7 +136,7 @@ public class JMainPanel extends JPanel { if (vascNode != null) { if (vascNode.type == VascTreeNodeType.ENTRY) { VascEntry ee = vascManager.getVascController().getVascEntryController().getVascEntryById(vascNode.id).clone(); - DefaultVascFactory.fillVascEntryFrontend(ee, vascManager.getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null)); + DefaultVascFactory.fillVascEntryFrontend(ee, vascManager.getVascController(), DefaultVascFactory.getDefaultVascFrontendData("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("en"))); spi.createNewVascView(ee); } } @@ -260,10 +273,85 @@ public class JMainPanel extends JPanel { root.add(entries); SwingUtilities.updateComponentTreeUI(vascTree); + + + // todo move + Map keys = new HashMap(300); + VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle")); + for (String veId:vascManager.getVascController().getVascEntryController().getVascEntryIds()) { + VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(veId); + keys.putAll(checker.generateMissingKeys(ve)); + } + if (keys.isEmpty()==false) { + Properties p = new Properties(); + File dataDir = new File("auto/data"); + + if (dataDir.exists()==false) { + dataDir.mkdirs(); + } + File resourceFile = new File("auto/data/vasc-bundle.properties"); + if (resourceFile.exists()) { + readPropertiesFile(p,resourceFile); + } + for (String key:keys.keySet()) { + p.put(key, keys.get(key)); + } + writePropertiesFile(p,resourceFile); + + new RootApplicationBundle_en().reload(); + RootApplicationBundle_en.clearCache(); + } } public JTabbedPane getTabPane() { return tabPane; } + protected void writePropertiesFile(Properties p,File file) { + try { + writePropertiesStream(p,new FileOutputStream(file)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + + protected void readPropertiesFile(Properties p,File file) { + try { + readPropertiesStream(p,new FileInputStream(file)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + protected void writePropertiesStream(Properties p,OutputStream out) { + try { + p.store(out, "Saved by vasc auto i18n."); + } catch (Exception e) { + throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); + } finally { + if (out!=null) { + try { + out.close(); + } catch (IOException e) { + } + } + } + } + + protected void readPropertiesStream(Properties p,InputStream in) { + try { + p.load(in); + } catch (Exception e) { + throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); + } finally { + if (in!=null) { + try { + in.close(); + } catch (IOException e) { + } + } + } + } + } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/resources/META-INF/root-bundle.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/resources/META-INF/root-bundle.properties new file mode 100644 index 0000000..a9c0585 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/resources/META-INF/root-bundle.properties @@ -0,0 +1,8 @@ + +# bundle list to merge and load +bundle1.uri=net.forwardfire.vasc.demo.tech.ui.resources.TechUI + +bundle2.uri=auto/data/vasc-bundle.properties +bundle2.type=FILE +bundle2.optional=true + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/.project b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/.project index e8219c3..3753a0c 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/.project +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/.project @@ -21,12 +21,12 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/VascFacesController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/VascFacesController.java index 02bf0bc..7a6c83c 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/VascFacesController.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/VascFacesController.java @@ -25,7 +25,6 @@ package net.forwardfire.vasc.demo.tech.web.beans; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import java.util.ResourceBundle; import javax.faces.context.FacesContext; @@ -60,10 +59,7 @@ public class VascFacesController extends AbstractJSFVascFacesControllerBase { @Override public VascFrontendData getNewVascFrontendData() { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - // MergedResourceBundle bundle = new MergedResourceBundle(); - // bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale)); - - VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(ResourceBundle.getBundle("net/forwardfire/vasc/demo/tech/ui/resources/TechUI")); + VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",locale); vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { private static final long serialVersionUID = 1L; public VascFrontendEventType[] getEventTypes() { diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml index d5f0080..b914b7c 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml @@ -158,6 +158,7 @@ vasc-demo-tech + org.richfaces.CONTROL_SKINNING @@ -188,12 +189,10 @@ templateFile /jsp/includes/vasc-template.jsf - diff --git a/vasc-lib/pom.xml b/vasc-lib/pom.xml index 71fc322..aa06537 100644 --- a/vasc-lib/pom.xml +++ b/vasc-lib/pom.xml @@ -7,6 +7,7 @@ .. vasc-lib + net.forwardfire.vasc.lib pom vasc-lib vasc-lib diff --git a/vasc-lib/vasc-lib-i18n/pom.xml b/vasc-lib/vasc-lib-i18n/pom.xml index 324fa94..8755940 100644 --- a/vasc-lib/vasc-lib-i18n/pom.xml +++ b/vasc-lib/vasc-lib-i18n/pom.xml @@ -2,7 +2,7 @@ 4.0.0 vasc-lib - net.forwardfire.vasc + net.forwardfire.vasc.lib 0.3.5-SNAPSHOT .. diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java new file mode 100644 index 0000000..b16b4f9 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java @@ -0,0 +1,92 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n; + +import java.util.List; +import java.util.Locale; + +import net.forwardfire.vasc.lib.i18n.config.BundleConfig; +import net.forwardfire.vasc.lib.i18n.config.BundleConfigParser; + +/** + * AbstractRootApplicationBundle adds the logic to auto init the MergeableResourceBundle. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +abstract public class AbstractRootApplicationBundle extends MergeableResourceBundle { + + private List applicationSupportedLocales = null; + private List bundleConfigs = null; + + /** + * The method needs to be implemented by the language class bundle of this. + * @return + */ + abstract public SupportedBundleLocale getSupportedBundleLocale(); + + /** + * @see java.util.ResourceBundle#getLocale() + */ + @Override + public Locale getLocale() { + return getSupportedBundleLocale().toLocale(); + } + + /** + * @see com.mbuyu.m4n.i18n.MergeableResourceBundle#init() + */ + @Override + protected void init() { + clear(); + BundleConfigParser config = new BundleConfigParser(); + config.parseConfig(); + applicationSupportedLocales = config.getApplicationSupportedLocales(); + bundleConfigs = config.getBundleConfigs(); + for (BundleConfig bc:bundleConfigs) { + addBundleData(config.loadBundleConfig(bc,getLocale())); + } + } + + /** + * Reloads the config and the bundles. + */ + public void reload() { + init(); + } + + /** + * Returns an collection of BundleConfig objects which are loaded. + * @return + */ + public List getBundleConfigs() { + return bundleConfigs; + } + + /** + * @return the applicationSupportedLocales + */ + public List getApplicationSupportedLocales() { + return applicationSupportedLocales; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java new file mode 100644 index 0000000..8a68a39 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java @@ -0,0 +1,104 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n; + +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.logging.Logger; + +/** + * MergeableResourceBundle is an ResourceBundle which can merge different bundles into one. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class MergeableResourceBundle extends ResourceBundle { + + private Logger logger = null; + private Map bundleData = null; + + /** + * Creates an new MergeableResourceBundle instance. + */ + public MergeableResourceBundle() { + logger = Logger.getLogger(MergeableResourceBundle.class.getName()); + bundleData = new HashMap(500); + init(); + } + + /** + * Protected init method to hook on the lazy init loading of bundles. + */ + protected void init() { + } + + /** + * Protected method to clear the bundle data. + */ + protected void clear() { + logger.fine("Clearing bundle data current size: "+bundleData.size()); + bundleData.clear(); + } + + /** + * @see java.util.ResourceBundle#handleGetObject(java.lang.String) + */ + @Override + protected Object handleGetObject(String key) { + return bundleData.get(key); + } + + /** + * @see java.util.ResourceBundle#getKeys() + */ + @Override + public Enumeration getKeys() { + return Collections.enumeration(bundleData.keySet()); + } + + /** + * Add all data from map to bundleData. + * @param dataMap + */ + public void addBundleData(Map dataMap) { + int startSize = bundleData.size(); + bundleData.putAll(dataMap); + logger.fine("Adding bundle data: "+dataMap.size()+" orgSize: "+startSize+" newSize: "+bundleData.size()); + } + + /** + * Add all data from ResourceBundle to bundleData. + * @param bundle + */ + public void addBundleData(ResourceBundle bundle) { + int startSize = bundleData.size(); + for (String key:bundle.keySet()) { + String value = bundle.getString(key); + bundleData.put(key, value); + } + logger.fine("Adding bundle data: "+bundle.keySet().size()+" orgSize: "+startSize+" newSize: "+bundleData.size()); + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/SupportedBundleLocale.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/SupportedBundleLocale.java new file mode 100644 index 0000000..a16f4fe --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/SupportedBundleLocale.java @@ -0,0 +1,73 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n; + +import java.util.Locale; + +/** + * SupportedBundleLocale defines all the supported locale's of the RootApplicationBundle. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +public enum SupportedBundleLocale { + + en, + de, + fr, + pt, + it, + ru, + nl, + es, + pl, + by, + da, + ro, + sv; + + /** + * The default locale if an unsupported locale is requested. + */ + public static final SupportedBundleLocale DEFAULT_LOCALE = en; + + /** + * The locale object of this language. + */ + private Locale locale = null; + + /** + * Private constructor for enum. + */ + private SupportedBundleLocale() { + locale = new Locale(name()); + } + + /** + * The locale object of this enum language. + * @return + */ + public Locale toLocale() { + return locale; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java new file mode 100644 index 0000000..153b753 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle is the fallback if not supported locale bundle is found. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.DEFAULT_LOCALE; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java new file mode 100644 index 0000000..362561e --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_by extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.by; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java new file mode 100644 index 0000000..389cc8a --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_da extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.da; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java new file mode 100644 index 0000000..c3113b1 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_de extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.de; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java new file mode 100644 index 0000000..88d9ab4 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_en extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.en; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java new file mode 100644 index 0000000..b97b6f8 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_es extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.es; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java new file mode 100644 index 0000000..947a718 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_fr extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.fr; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java new file mode 100644 index 0000000..efac0d0 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_it extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.it; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java new file mode 100644 index 0000000..333d298 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_nl extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.nl; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java new file mode 100644 index 0000000..a455c93 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_pl extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.pl; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java new file mode 100644 index 0000000..4dfe40a --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_pt extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.pt; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java new file mode 100644 index 0000000..d97c342 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_ro extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.ro; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java new file mode 100644 index 0000000..166f4f9 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_ru extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.ru; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java new file mode 100644 index 0000000..86460e3 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.bundle; + +import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; + +/** + * RootApplicationBundle_XX loads this language bundle. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class RootApplicationBundle_sv extends AbstractRootApplicationBundle { + + @Override + public SupportedBundleLocale getSupportedBundleLocale() { + return SupportedBundleLocale.sv; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java new file mode 100644 index 0000000..76c1cce --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java @@ -0,0 +1,138 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.config; + +/** + * BundleConfig holds the config to load one bundle. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +public class BundleConfig { + + private String name = null; + private String uri = null; + private String exclude = null; + private BundleURIType uriType = BundleURIType.RESOURCE; + private BundleFormat format = BundleFormat.BUNDLE; + private boolean utf8 = true; + private boolean optional = false; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the uri + */ + public String getUri() { + return uri; + } + + /** + * @param uri the uri to set + */ + public void setUri(String uri) { + this.uri = uri; + } + + /** + * @return the exclude + */ + public String getExclude() { + return exclude; + } + + /** + * @param exclude the exclude to set + */ + public void setExclude(String exclude) { + this.exclude = exclude; + } + + /** + * @return the uriType + */ + public BundleURIType getUriType() { + return uriType; + } + + /** + * @param uriType the uriType to set + */ + public void setUriType(BundleURIType uriType) { + this.uriType = uriType; + } + + /** + * @return the format + */ + public BundleFormat getFormat() { + return format; + } + + /** + * @param format the format to set + */ + public void setFormat(BundleFormat format) { + this.format = format; + } + + /** + * @return the utf8 + */ + public boolean isUtf8() { + return utf8; + } + + /** + * @param utf8 the utf8 to set + */ + public void setUtf8(boolean utf8) { + this.utf8 = utf8; + } + + /** + * @return the optional + */ + public boolean isOptional() { + return optional; + } + + /** + * @param optional the optional to set + */ + public void setOptional(boolean optional) { + this.optional = optional; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java new file mode 100644 index 0000000..2f83a63 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java @@ -0,0 +1,237 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.config; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; +import java.util.ResourceBundle.Control; +import java.util.logging.Logger; + +/** + * Loads and reads the configuration to load all resources. + * + * @author Willem Cazander + * @version 1.0 Mar 8, 2012 + */ +public class BundleConfigParser { + + private Logger logger = null; + public static final String CONFIG_RESOURCE_DEFAULT = "META-INF/root-bundle.properties"; + protected static final String BUNDLE_EXTENSION = "properties"; + protected static final Control UTF8_CONTROL = new UTF8Control(); + protected List applicationSupportedLocales = null; + protected List bundlesConfigs = null; + + public BundleConfigParser() { + logger = Logger.getLogger(BundleConfigParser.class.getName()); + applicationSupportedLocales = new ArrayList(10); + bundlesConfigs = new ArrayList(10); + } + + public void parseConfig() { + bundlesConfigs.clear(); + applicationSupportedLocales.clear(); + Properties properties = new Properties(); + readPropertiesResource(properties,CONFIG_RESOURCE_DEFAULT); + parseProperties(properties); + } + + public List getApplicationSupportedLocales() { + return applicationSupportedLocales; + } + + public List getBundleConfigs() { + return bundlesConfigs; + } + + public Map loadBundleConfig(BundleConfig bundle,Locale locale) { + Properties properties = new Properties(); + try { + switch (bundle.getUriType()) { + default: + case RESOURCE: + readPropertiesBundle(properties,bundle,locale); + break; + case URL: + readPropertiesStream(properties,new URL(bundle.getUri()).openStream()); + break; + case FILE: + readPropertiesFile(properties,new File(bundle.getUri())); + break; + } + } catch (Exception e) { + if (bundle.isOptional()) { + logger.info("Could not load optional bundle with uri: "+bundle.getUri()+" message: "+e.getMessage()); + } else { + throw new RuntimeException(e); + } + } + Map result = new HashMap(100); + for (Object keyObject:properties.keySet()) { + String key = (String)keyObject; + if (bundle.getExclude()!=null && key.matches(bundle.getExclude())) { + logger.finest("Excluding key: "+key+" from bundle: "+bundle.getName()); + continue; + } + String value = properties.getProperty(key); + result.put(key,value); + } + logger.info("Loaded "+bundle.getName()+" with total keys: "+result.size()); + return result; + } + + protected void readPropertiesFile(Properties p,File file) { + logger.info("Reading bundle file: "+file.getAbsoluteFile()); + try { + readPropertiesStream(p,new FileInputStream(file)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + protected void readPropertiesBundle(Properties p,BundleConfig bundle,Locale locale) { + ResourceBundle bundleReal = null; + if (bundle.isUtf8()) { + bundleReal = ResourceBundle.getBundle(bundle.getUri(),locale,UTF8_CONTROL); + } else { + bundleReal = ResourceBundle.getBundle(bundle.getUri(),locale); + } + for (String key:bundleReal.keySet()) { + String value = bundleReal.getString(key); + p.put(key, value); + } + } + + protected void readPropertiesResource(Properties p,String resource) { + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = p.getClass().getClassLoader(); // fallback + } + readPropertiesStream(p,cl.getResourceAsStream(resource)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource: "+resource+" error: "+e.getMessage(),e); + } + } + + protected void readPropertiesStream(Properties p,InputStream in) { + try { + p.load(in); + } catch (Exception e) { + throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); + } finally { + if (in!=null) { + try { + in.close(); + } catch (IOException e) { + } + } + } + } + + protected void parseProperties(Properties p) { + Map bundles = new HashMap(10); + for (Object keyO:p.keySet()) { + String keyFull = (String)keyO; + String value = p.getProperty(keyFull); + if (keyFull.contains(".")==false) { + continue; + } + String keyConfig = keyFull.substring(0,keyFull.indexOf('.')); + String keyField = keyFull.substring(keyFull.indexOf('.')+1,keyFull.length()); + + if ("locale".equals(keyConfig) && "true".equalsIgnoreCase(value)) { + applicationSupportedLocales.add(new Locale(keyField)); + continue; + } + + BundleConfig c = bundles.get(keyConfig); + if (c==null) { + c = new BundleConfig(); + c.setName(keyConfig); + bundles.put(keyConfig,c); + } + if ("uri".equals(keyField)) { + c.setUri(value); + } else if ("type".equals(keyField)) { + c.setUriType(BundleURIType.valueOf(value)); + } else if ("exclude".equals(keyField)) { + c.setExclude(value); + } else if ("format".equals(keyField)) { + c.setFormat(BundleFormat.valueOf(value)); + } else if ("optional".equals(keyField)) { + c.setOptional(new Boolean(value)); + } else if ("utf8".equals(keyField)) { + c.setUtf8(new Boolean(value)); + } + } + bundlesConfigs.addAll(bundles.values()); + } + + protected static class UTF8Control extends Control { + public ResourceBundle newBundle + (String baseName, Locale locale, String format, ClassLoader loader, boolean reload) + throws IllegalAccessException, InstantiationException, IOException + { + // The below code is copied from default Control#newBundle() implementation. + // Only the PropertyResourceBundle line is changed to read the file as UTF-8. + String bundleName = toBundleName(baseName, locale); + String resourceName = toResourceName(bundleName, BUNDLE_EXTENSION); + ResourceBundle bundle = null; + InputStream stream = null; + if (reload) { + URL url = loader.getResource(resourceName); + if (url != null) { + URLConnection connection = url.openConnection(); + if (connection != null) { + connection.setUseCaches(false); + stream = connection.getInputStream(); + } + } + } else { + stream = loader.getResourceAsStream(resourceName); + } + if (stream != null) { + try { + bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); + } finally { + stream.close(); + } + } + return bundle; + } + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleFormat.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleFormat.java new file mode 100644 index 0000000..196b2ed --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleFormat.java @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.config; + +/** + * BundleFormat lists the supported bundle format types. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +public enum BundleFormat { + + BUNDLE, + BUNDLE_ONE_FILE, + X18N; +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleURIType.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleURIType.java new file mode 100644 index 0000000..c982aa5 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleURIType.java @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.lib.i18n.config; + +/** + * BundleURIType lists the supported uri types to fetch the bundle. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +public enum BundleURIType { + + RESOURCE, + URL, + FILE; +} diff --git a/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java b/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java new file mode 100644 index 0000000..44b10c4 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java @@ -0,0 +1,46 @@ +package net.forwardfire.vasc.lib.i18n; + +import java.util.Locale; +import java.util.ResourceBundle; + +import net.forwardfire.vasc.lib.i18n.config.BundleConfigParser; + +import junit.framework.TestCase; + +/** + * Test some keys and loading options. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +public class RootBundleTest extends TestCase { + + public void testParser() { + BundleConfigParser p = new BundleConfigParser(); + p.parseConfig(); + assertEquals(2,p.getBundleConfigs().size()); + assertEquals(2,p.getApplicationSupportedLocales().size()); + } + + public void testValues_en() { + ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("en")); + assertEquals(6,bundle.keySet().size()); + assertEquals("key1_en",bundle.getString("bundle1.key1")); + assertEquals("key2_en",bundle.getString("bundle1.key2")); + assertEquals("key3_en",bundle.getString("bundle1.key3")); + assertEquals("key1_en",bundle.getString("bundle2.key1")); + assertEquals("key2_en",bundle.getString("bundle2.key2")); + assertEquals("key3_en",bundle.getString("bundle2.key3")); + } + + public void testValues_nl() { + ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("nl")); + assertEquals(6,bundle.keySet().size()); + assertEquals("key1_nl",bundle.getString("bundle1.key1")); + assertEquals("key2_nl",bundle.getString("bundle1.key2")); + assertEquals("key3_nl",bundle.getString("bundle1.key3")); + assertEquals("key1_nl",bundle.getString("bundle2.key1")); + assertEquals("key2_nl",bundle.getString("bundle2.key2")); + assertEquals("key3_nl",bundle.getString("bundle2.key3")); + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties new file mode 100644 index 0000000..76a2be5 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties @@ -0,0 +1,22 @@ + +# We only suport 2 languages. +locale.nl=true +locale.en=true + +# bundle list to merge and load +bundle1.uri=net.forwardfire.vasc.lib.i18n.resources.TestBundle1 +bundle2.uri=net.forwardfire.vasc.lib.i18n.resources.TestBundle2 + +# TODO: +# +# bundle2.type=RESOURCE +# bundle2.exclude=yoyo.* +# bundle2.format=PROPERTIES +# bundle2.utf8=true +# bundle2.optional=false +# +# bundle3.uri=http://foo.bar/some/path/bundle.properties +# bundle3.type=URL +# +# bundle4=/tmp/bundle.properties +# bundle4.type=FILE \ No newline at end of file diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties new file mode 100644 index 0000000..e742510 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties @@ -0,0 +1,4 @@ +# Test bundle +bundle1.key1 = key1_en +bundle1.key2 = key2_en +bundle1.key3 = key3_en diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties new file mode 100644 index 0000000..59d2987 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties @@ -0,0 +1,4 @@ +# Test bundle +bundle1.key1 = key1_nl +bundle1.key2 = key2_nl +bundle1.key3 = key3_nl diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties new file mode 100644 index 0000000..e5f317e --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties @@ -0,0 +1,4 @@ +# Test bundle +bundle2.key1 = key1_en +bundle2.key2 = key2_en +bundle2.key3 = key3_en diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties new file mode 100644 index 0000000..0ab610d --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties @@ -0,0 +1,4 @@ +# Test bundle +bundle2.key1 = key1_nl +bundle2.key2 = key2_nl +bundle2.key3 = key3_nl diff --git a/vasc-test/pom.xml b/vasc-test/pom.xml index f2019e1..2cf5005 100644 --- a/vasc-test/pom.xml +++ b/vasc-test/pom.xml @@ -7,10 +7,12 @@ .. vasc-test + net.forwardfire.vasc.test pom vasc-test vasc-test vasc-test-frontend-data + vasc-test-i18n \ No newline at end of file diff --git a/vasc-test/vasc-test-i18n/.project b/vasc-test/vasc-test-i18n/.project new file mode 100644 index 0000000..fdce8c1 --- /dev/null +++ b/vasc-test/vasc-test-i18n/.project @@ -0,0 +1,23 @@ + + + vasc-test-i18n + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-test/vasc-test-i18n/pom.xml b/vasc-test/vasc-test-i18n/pom.xml new file mode 100644 index 0000000..cea826f --- /dev/null +++ b/vasc-test/vasc-test-i18n/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + + vasc-test + net.forwardfire.vasc.test + 0.3.5-SNAPSHOT + .. + + vasc-test-i18n + vasc-test-i18n + vasc-test-i18n + + + net.forwardfire.vasc + vasc-core + ${project.version} + + + \ No newline at end of file diff --git a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java new file mode 100644 index 0000000..42c2da7 --- /dev/null +++ b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java @@ -0,0 +1,171 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.test.i18n; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascLinkEntry; +import net.forwardfire.vasc.core.actions.VascAction; + + +/** + * Parses the Vasc annotations and generates all i18n keys for you. + * + * @author Willem Cazander + * @version 1.0 Mar 23, 2009 + */ +public class VascBundleCheckEntryKeys { + + private ResourceBundle resourceBundle = null; + private String imagePrefix = null; + private String imagePostfix = null; + + public VascBundleCheckEntryKeys(ResourceBundle resourceBundle) { + imagePrefix = "resources/images/models/"; + imagePostfix = ".png"; + this.resourceBundle=resourceBundle; + } + + public Map collectVascKeys(VascEntry ve) { + Map keys = new HashMap(300); + keys.put(ve.getName(), ve.getId()); + keys.put(ve.getImage(), ve.getId()); + keys.put(ve.getListDescription(), ve.getId()); + keys.put(ve.getListImage(), imagePrefix+ve.getId()+imagePostfix); + keys.put(ve.getEditDescription(), ve.getId()); + keys.put(ve.getEditImage(), imagePrefix+ve.getId()+imagePostfix); + keys.put(ve.getDeleteDescription(), ve.getId()); + keys.put(ve.getDeleteImage(), imagePrefix+ve.getId()+imagePostfix); + keys.put(ve.getCreateDescription(), ve.getId()); + keys.put(ve.getCreateImage(), imagePrefix+ve.getId()+imagePostfix); + for (VascEntryField vef:ve.getVascEntryFields()) { + keys.put(vef.getName(), vef.getId()); + keys.put(vef.getImage(), vef.getId()); + keys.put(vef.getDescription(), vef.getId()); + } + for (VascEntryFieldSet s:ve.getVascEntryFieldSets()) { + keys.put(s.getName(), s.getId()); + keys.put(s.getDescription(), s.getId()); + keys.put(s.getImage(), s.getId()); + } + for (VascEntryField vef:ve.getListOptions()) { + keys.put(vef.getName(), vef.getId()); + keys.put(vef.getImage(), vef.getId()); + keys.put(vef.getDescription(), vef.getId()); + } + for (VascLinkEntry vef:ve.getVascLinkEntries()) { + keys.put(vef.getName(), vef.getId()); + } + for (VascAction a:ve.getGlobalActions()) { + keys.put(a.getName(), a.getId()); + keys.put(a.getDescription(), a.getId()); + keys.put(a.getImage(), a.getId()); + } + for (VascAction a:ve.getRowActions()) { + keys.put(a.getName(), a.getId()); + keys.put(a.getDescription(), a.getId()); + keys.put(a.getImage(), a.getId()); + } + for (VascAction a:ve.getColumnActions()) { + keys.put(a.getName(), a.getId()); + keys.put(a.getDescription(), a.getId()); + keys.put(a.getImage(), a.getId()); + } + return keys; + } + + + public Map generateMissingKeys(VascEntry ve) { + Map keys = collectVascKeys(ve); + List keysResult = new ArrayList(keys.keySet()); + keysResult.removeAll(resourceBundle.keySet()); + Collections.sort(keysResult); + Map data = new HashMap(300); + for (String key:keysResult) { + data.put(key, keys.get(key)); + } + return data; + } + + public Map generateRemovedKeys(VascEntry ve) { + Map keys = collectVascKeys(ve); + List keysResult = new ArrayList(resourceBundle.keySet()); + keysResult.removeAll(keys.keySet()); + Collections.sort(keysResult); + Map data = new HashMap(300); + for (String key:keysResult) { + data.put(key, keys.get(key)); + } + return data; + } + + /** + * @return the resourceBundle + */ + public ResourceBundle getResourceBundle() { + return resourceBundle; + } + + /** + * @param resourceBundle the resourceBundle to set + */ + public void setResourceBundle(ResourceBundle resourceBundle) { + this.resourceBundle = resourceBundle; + } + + /** + * @return the imagePrefix + */ + public String getImagePrefix() { + return imagePrefix; + } + + /** + * @param imagePrefix the imagePrefix to set + */ + public void setImagePrefix(String imagePrefix) { + this.imagePrefix = imagePrefix; + } + + /** + * @return the imagePostfix + */ + public String getImagePostfix() { + return imagePostfix; + } + + /** + * @param imagePostfix the imagePostfix to set + */ + public void setImagePostfix(String imagePostfix) { + this.imagePostfix = imagePostfix; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascBundleKeyGenerator.java b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleKeyGenerator.java similarity index 98% rename from vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascBundleKeyGenerator.java rename to vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleKeyGenerator.java index 8a6e293..325332b 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascBundleKeyGenerator.java +++ b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleKeyGenerator.java @@ -20,7 +20,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.annotations; +package net.forwardfire.vasc.test.i18n; import java.lang.reflect.Method; import java.util.ArrayList; @@ -30,6 +30,8 @@ import java.util.List; import java.util.Map; import java.util.ResourceBundle; +import net.forwardfire.vasc.annotations.VascAnnotationParser; + /** * Parses the Vasc annotations and generates all i18n keys for you. *