Added i18n lib and added paging on mongo and meta backends.
This commit is contained in:
parent
fe5842768f
commit
efcbdbd519
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -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
|
||||
|
|
6
todo.txt
6
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
|
||||
|
|
|
@ -74,12 +74,41 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return dataContext;
|
||||
}
|
||||
|
||||
public List<Object> 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<String> 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<Object> 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<Object> result = new ArrayList<Object>(50);
|
||||
while (ds.next()) {
|
||||
|
|
|
@ -60,16 +60,43 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
logger = Logger.getLogger(MongodbVascBackend.class.getName());
|
||||
}
|
||||
|
||||
public List<Object> 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<Object> 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<Object> result = new ArrayList<Object>(cur.count());
|
||||
while (cur.hasNext()) {
|
||||
DBObject row = cur.next();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<groupId>net.forwardfire.vasc.demo</groupId>
|
||||
<artifactId>vasc-demo-tech-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<!-- <type>war</type> -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
|
@ -67,6 +67,16 @@
|
|||
<artifactId>vasc-backend-jdbc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<artifactId>vasc-lib-i18n</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc.test</groupId>
|
||||
<artifactId>vasc-test-i18n</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdesktop.bsaf</groupId>
|
||||
<artifactId>bsaf</artifactId>
|
||||
|
|
|
@ -53,7 +53,6 @@ public class TechUI extends SingleFrameApplication {
|
|||
|
||||
static public void main(String[] args) {
|
||||
Application.launch(TechUI.class, args);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<String,String> keys = new HashMap<String,String>(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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
@ -21,12 +21,12 @@
|
|||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -158,6 +158,7 @@
|
|||
<param-value>vasc-demo-tech</param-value>
|
||||
</context-param>
|
||||
|
||||
|
||||
<!-- Making the RichFaces skin spread to standard HTML controls -->
|
||||
<context-param>
|
||||
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
|
||||
|
@ -188,12 +189,10 @@
|
|||
<param-name>templateFile</param-name>
|
||||
<param-value>/jsp/includes/vasc-template.jsf</param-value>
|
||||
</init-param>
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>resourceBundle</param-name>
|
||||
<param-value>net/forwardfire/logstats/resources/i18n/LogstatsBundleWAR</param-value>
|
||||
<param-value>net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle</param-value>
|
||||
</init-param>
|
||||
-->
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>vasc-lib</artifactId>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<packaging>pom</packaging>
|
||||
<name>vasc-lib</name>
|
||||
<description>vasc-lib</description>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-lib</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<version>0.3.5-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
|
|
@ -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<Locale> applicationSupportedLocales = null;
|
||||
private List<BundleConfig> 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<BundleConfig> getBundleConfigs() {
|
||||
return bundleConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the applicationSupportedLocales
|
||||
*/
|
||||
public List<Locale> getApplicationSupportedLocales() {
|
||||
return applicationSupportedLocales;
|
||||
}
|
||||
}
|
|
@ -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<String,String> bundleData = null;
|
||||
|
||||
/**
|
||||
* Creates an new MergeableResourceBundle instance.
|
||||
*/
|
||||
public MergeableResourceBundle() {
|
||||
logger = Logger.getLogger(MergeableResourceBundle.class.getName());
|
||||
bundleData = new HashMap<String,String>(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<String> getKeys() {
|
||||
return Collections.enumeration(bundleData.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all data from map to bundleData.
|
||||
* @param dataMap
|
||||
*/
|
||||
public void addBundleData(Map<String,String> 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());
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<Locale> applicationSupportedLocales = null;
|
||||
protected List<BundleConfig> bundlesConfigs = null;
|
||||
|
||||
public BundleConfigParser() {
|
||||
logger = Logger.getLogger(BundleConfigParser.class.getName());
|
||||
applicationSupportedLocales = new ArrayList<Locale>(10);
|
||||
bundlesConfigs = new ArrayList<BundleConfig>(10);
|
||||
}
|
||||
|
||||
public void parseConfig() {
|
||||
bundlesConfigs.clear();
|
||||
applicationSupportedLocales.clear();
|
||||
Properties properties = new Properties();
|
||||
readPropertiesResource(properties,CONFIG_RESOURCE_DEFAULT);
|
||||
parseProperties(properties);
|
||||
}
|
||||
|
||||
public List<Locale> getApplicationSupportedLocales() {
|
||||
return applicationSupportedLocales;
|
||||
}
|
||||
|
||||
public List<BundleConfig> getBundleConfigs() {
|
||||
return bundlesConfigs;
|
||||
}
|
||||
|
||||
public Map<String,String> 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<String,String> result = new HashMap<String,String>(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<String,BundleConfig> bundles = new HashMap<String,BundleConfig>(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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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"));
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
|||
# Test bundle
|
||||
bundle1.key1 = key1_en
|
||||
bundle1.key2 = key2_en
|
||||
bundle1.key3 = key3_en
|
|
@ -0,0 +1,4 @@
|
|||
# Test bundle
|
||||
bundle1.key1 = key1_nl
|
||||
bundle1.key2 = key2_nl
|
||||
bundle1.key3 = key3_nl
|
|
@ -0,0 +1,4 @@
|
|||
# Test bundle
|
||||
bundle2.key1 = key1_en
|
||||
bundle2.key2 = key2_en
|
||||
bundle2.key3 = key3_en
|
|
@ -0,0 +1,4 @@
|
|||
# Test bundle
|
||||
bundle2.key1 = key1_nl
|
||||
bundle2.key2 = key2_nl
|
||||
bundle2.key3 = key3_nl
|
|
@ -7,10 +7,12 @@
|
|||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>vasc-test</artifactId>
|
||||
<groupId>net.forwardfire.vasc.test</groupId>
|
||||
<packaging>pom</packaging>
|
||||
<name>vasc-test</name>
|
||||
<description>vasc-test</description>
|
||||
<modules>
|
||||
<module>vasc-test-frontend-data</module>
|
||||
<module>vasc-test-i18n</module>
|
||||
</modules>
|
||||
</project>
|
23
vasc-test/vasc-test-i18n/.project
Normal file
23
vasc-test/vasc-test-i18n/.project
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vasc-test-i18n</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
19
vasc-test/vasc-test-i18n/pom.xml
Normal file
19
vasc-test/vasc-test-i18n/pom.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-test</artifactId>
|
||||
<groupId>net.forwardfire.vasc.test</groupId>
|
||||
<version>0.3.5-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>vasc-test-i18n</artifactId>
|
||||
<name>vasc-test-i18n</name>
|
||||
<description>vasc-test-i18n</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -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<String,String> collectVascKeys(VascEntry ve) {
|
||||
Map<String,String> keys = new HashMap<String,String>(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<String,String> generateMissingKeys(VascEntry ve) {
|
||||
Map<String,String> keys = collectVascKeys(ve);
|
||||
List<String> keysResult = new ArrayList<String>(keys.keySet());
|
||||
keysResult.removeAll(resourceBundle.keySet());
|
||||
Collections.sort(keysResult);
|
||||
Map<String,String> data = new HashMap<String,String>(300);
|
||||
for (String key:keysResult) {
|
||||
data.put(key, keys.get(key));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public Map<String,String> generateRemovedKeys(VascEntry ve) {
|
||||
Map<String,String> keys = collectVascKeys(ve);
|
||||
List<String> keysResult = new ArrayList<String>(resourceBundle.keySet());
|
||||
keysResult.removeAll(keys.keySet());
|
||||
Collections.sort(keysResult);
|
||||
Map<String,String> data = new HashMap<String,String>(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;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*
|
Loading…
Reference in a new issue