Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapComparator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapComparator.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapComparator.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapComparator.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -28,12 +28,12 @@ /** * MapComparator.java - * + * */ public class MapComparator implements Comparator<Map<Object, Object>> { - + public static final String module = MapComparator.class.getName(); - + private List<? extends Object> keys; /** @@ -70,9 +70,9 @@ if (key instanceof FlexibleMapAccessor) { FlexibleMapAccessor<Object> fmaKey = UtilGenerics.cast(key); ascending = fmaKey.getIsAscending(); - + //Debug.logInfo("Doing compare with a FlexibleMapAccessor [" + fmaKey.getOriginalName() + "] ascending [" + ascending + "]", module); - + o1 = fmaKey.get(UtilGenerics.<String, Object>checkMap(map1)); o2 = fmaKey.get(UtilGenerics.<String, Object>checkMap(map2)); } else { @@ -86,7 +86,7 @@ key = keyStr.substring(1); } } - + o1 = map1.get(key); o2 = map2.get(key); } @@ -94,7 +94,7 @@ if (o1 == null && o2 == null) { continue; } - + int compareResult = 0; if (o1 != null && o2 == null) { compareResult = -1; @@ -102,7 +102,7 @@ if (o1 == null && o2 != null) { compareResult = 1; } - + if (compareResult == 0) { try { // the map values in question MUST implement the Comparable interface, if not we'll throw an exception @@ -124,7 +124,7 @@ } } } - + // none of them were different, so they are equal return 0; } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapStack.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapStack.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapStack.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapStack.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -37,7 +37,7 @@ /** * Map Stack - * + * */ public class MapStack<K> implements Map<K, Object>, Reusable, LocalizedMap<Object> { @@ -81,19 +81,19 @@ protected MapStack() { super(); } - + protected List<Map<K, Object>> stackList = FastList.newInstance(); - + public void reset() { stackList = FastList.newInstance(); } - + /** Puts a new Map on the top of the stack */ public void push() { Map<K, Object> newMap = FastMap.newInstance(); this.stackList.add(0,newMap); } - + /** Puts an existing Map on the top of the stack (top meaning will override lower layers on the stack) */ public void push(Map<K, Object> existingMap) { if (existingMap == null) { @@ -101,7 +101,7 @@ } this.stackList.add(0, existingMap); } - + /** Puts an existing Map on the BOTTOM of the stack (bottom meaning will be overriden by lower layers on the stack, ie everything else already there) */ public void addToBottom(Map<K, Object> existingMap) { if (existingMap == null) { @@ -109,7 +109,7 @@ } this.stackList.add(existingMap); } - + /** Remove and returns the Map from the top of the stack; if there is only one Map on the stack it returns null and does not remove it */ public Map<K, Object> pop() { // always leave at least one Map in the List, ie never pop off the last Map @@ -119,23 +119,23 @@ return null; } } - - /** - * Creates a MapStack object that has the same Map objects on its stack; - * meant to be used to enable a - * situation where a parent and child context are operating simultaneously - * using two different MapStack objects, but sharing the Maps in common + + /** + * Creates a MapStack object that has the same Map objects on its stack; + * meant to be used to enable a + * situation where a parent and child context are operating simultaneously + * using two different MapStack objects, but sharing the Maps in common */ public MapStack<K> standAloneStack() { MapStack<K> standAlone = MapStack.create(this); return standAlone; } - /** - * Creates a MapStack object that has the same Map objects on its stack, - * but with a new Map pushed on the top; meant to be used to enable a - * situation where a parent and child context are operating simultaneously - * using two different MapStack objects, but sharing the Maps in common + /** + * Creates a MapStack object that has the same Map objects on its stack, + * but with a new Map pushed on the top; meant to be used to enable a + * situation where a parent and child context are operating simultaneously + * using two different MapStack objects, but sharing the Maps in common */ public MapStack<K> standAloneChildStack() { MapStack<K> standAloneChild = MapStack.create(this); @@ -211,7 +211,7 @@ if ("context".equals(key)) { return this; } - + // walk the stackList and for the first place it is found return true; otherwise refurn false for (Map<K, Object> curMap: this.stackList) { // only return if the curMap contains the key, rather than checking for null; this allows a null at a lower level to override a value at a higher level @@ -229,7 +229,7 @@ if ("context".equals(name)) { return this; } - + // walk the stackList and for the first place it is found return true; otherwise refurn false for (Map<K, Object> curMap: this.stackList) { // only return if the curMap contains the key, rather than checking for null; this allows a null at a lower level to override a value at a higher level @@ -254,7 +254,7 @@ Debug.logWarning("WARNING: Putting a value in a MapStack with key [context] that is not this MapStack, will be hidden by the current MapStack self-reference: " + value, module); } } - + // all write operations are local: only put in the Map on the top of the stack Map<K, Object> currentMap = this.stackList.get(0); return currentMap.put(key, value); @@ -334,14 +334,14 @@ } return Collections.unmodifiableSet(resultEntrySet); } - + public String toString() { StringBuilder fullMapString = new StringBuilder(); int curLevel = 0; for (Map<K, Object> curMap: this.stackList) { fullMapString.append("============================== Start stack level " + curLevel + "\n"); for (Map.Entry<K, Object> curEntry: curMap.entrySet()) { - + fullMapString.append("==>["); fullMapString.append(curEntry.getKey()); fullMapString.append("]:"); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedMap.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedMap.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedMap.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -38,7 +38,7 @@ /** * @see java.util.Map#keySet() - */ + */ public Set<K> keySet() { return new LinkedHashSet<K>(orderedKeys); } @@ -63,12 +63,12 @@ /** * @see java.util.Map#clear() - */ + */ public void clear() { super.clear(); orderedKeys.clear(); } - + /** * @see java.util.Map#remove(java.lang.Object) */ @@ -77,7 +77,7 @@ orderedKeys.remove(key); return super.remove(key); } - + /** * @see java.util.Map#values() */ @@ -85,7 +85,7 @@ if (orderedKeys.isEmpty()) { return null; } - + List<V> values = FastList.newInstance(); for (K key: orderedKeys) { values.add(this.get(key)); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedSet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedSet.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedSet.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedSet.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -54,7 +54,7 @@ /** * @see java.util.Collection#iterator() - */ + */ public Iterator<V> iterator() { return backedList.iterator(); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/ResourceBundleMapWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/ResourceBundleMapWrapper.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/ResourceBundleMapWrapper.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/ResourceBundleMapWrapper.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -35,7 +35,7 @@ * */ public class ResourceBundleMapWrapper implements Map<String, Object>, Serializable { - + protected MapStack<String> rbmwStack; protected ResourceBundle initialResourceBundle; protected Map<String, Object> context; @@ -51,7 +51,7 @@ this.initialResourceBundle = initialInternalRbmWrapper.getResourceBundle(); this.rbmwStack = MapStack.create(initialInternalRbmWrapper); } - + /** When creating new from a ResourceBundle the one passed to the constructor should be the most specific or local ResourceBundle, with more common ones pushed onto the stack progressively. */ public ResourceBundleMapWrapper(ResourceBundle initialResourceBundle) { @@ -61,7 +61,7 @@ this.initialResourceBundle = initialResourceBundle; this.rbmwStack = MapStack.create(new InternalRbmWrapper(initialResourceBundle)); } - + /** When creating new from a ResourceBundle the one passed to the constructor should be the most specific or local ResourceBundle, with more common ones pushed onto the stack progressively. */ public ResourceBundleMapWrapper(ResourceBundle initialResourceBundle, Map<String, Object> context) { @@ -72,7 +72,7 @@ this.rbmwStack = MapStack.create(new InternalRbmWrapper(initialResourceBundle)); this.context = context; } - + /** Puts ResourceBundle on the BOTTOM of the stack (bottom meaning will be overriden by higher layers on the stack, ie everything else already there) */ public void addBottomResourceBundle(ResourceBundle topResourceBundle) { this.rbmwStack.addToBottom(new InternalRbmWrapper(topResourceBundle)); @@ -92,7 +92,7 @@ } /** In general we don't want to use this, better to start with the more specific ResourceBundle and add layers of common ones... - * Puts ResourceBundle on the top of the stack (top meaning will override lower layers on the stack) + * Puts ResourceBundle on the top of the stack (top meaning will override lower layers on the stack) */ public void pushResourceBundle(ResourceBundle topResourceBundle) { this.rbmwStack.push(new InternalRbmWrapper(topResourceBundle)); @@ -149,18 +149,18 @@ public Collection<Object> values() { return this.rbmwStack.values(); } - + public static class InternalRbmWrapper implements Map<String, Object>, Serializable { protected ResourceBundle resourceBundle; protected Map<String, Object> topLevelMap; - + public InternalRbmWrapper(ResourceBundle resourceBundle) { if (resourceBundle == null) { throw new IllegalArgumentException("Cannot create InternalRbmWrapper with a null ResourceBundle."); } this.resourceBundle = resourceBundle; topLevelMap = new HashMap<String, Object>(); - // NOTE: this does NOT return all keys, ie keys from parent ResourceBundles, so we keep the resourceBundle object to look at when the main Map doesn't have a certain value + // NOTE: this does NOT return all keys, ie keys from parent ResourceBundles, so we keep the resourceBundle object to look at when the main Map doesn't have a certain value if (resourceBundle != null) { Enumeration<String> keyNum = resourceBundle.getKeys(); while (keyNum.hasMoreElements()) { @@ -172,7 +172,7 @@ } topLevelMap.put("_RESOURCE_BUNDLE_", resourceBundle); } - + /* (non-Javadoc) * @see java.util.Map#size() */ @@ -180,14 +180,14 @@ // this is an approximate size, won't include elements from parent bundles return topLevelMap.size() - 1; } - + /* (non-Javadoc) * @see java.util.Map#isEmpty() */ public boolean isEmpty() { return topLevelMap.isEmpty(); } - + /* (non-Javadoc) * @see java.util.Map#containsKey(java.lang.Object) */ @@ -207,14 +207,14 @@ } return false; } - + /* (non-Javadoc) * @see java.util.Map#containsValue(java.lang.Object) */ public boolean containsValue(Object arg0) { throw new RuntimeException("Not implemented for ResourceBundleMapWrapper"); } - + /* (non-Javadoc) * @see java.util.Map#get(java.lang.Object) */ @@ -243,60 +243,60 @@ */ return value; } - + /* (non-Javadoc) * @see java.util.Map#put(java.lang.Object, java.lang.Object) */ public Object put(String arg0, Object arg1) { throw new RuntimeException("Not implemented/allowed for ResourceBundleMapWrapper"); } - + /* (non-Javadoc) * @see java.util.Map#remove(java.lang.Object) */ public Object remove(Object arg0) { throw new RuntimeException("Not implemented for ResourceBundleMapWrapper"); } - + /* (non-Javadoc) * @see java.util.Map#putAll(java.util.Map) */ public void putAll(Map arg0) { throw new RuntimeException("Not implemented for ResourceBundleMapWrapper"); } - + /* (non-Javadoc) * @see java.util.Map#clear() */ public void clear() { throw new RuntimeException("Not implemented for ResourceBundleMapWrapper"); } - + /* (non-Javadoc) * @see java.util.Map#keySet() */ public Set<String> keySet() { return this.topLevelMap.keySet(); } - + /* (non-Javadoc) * @see java.util.Map#values() */ public Collection<Object> values() { return this.topLevelMap.values(); } - + /* (non-Javadoc) * @see java.util.Map#entrySet() */ public Set<Map.Entry<String, Object>> entrySet() { return this.topLevelMap.entrySet(); } - + public ResourceBundle getResourceBundle() { return this.resourceBundle; } - + /*public String toString() { return this.topLevelMap.toString(); }*/ Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -45,7 +45,7 @@ */ @SuppressWarnings("serial") public class FlexibleStringExpander implements Serializable { - + public static final String module = FlexibleStringExpander.class.getName(); public static final String openBracket = "${"; public static final String closeBracket = "}"; @@ -71,11 +71,11 @@ this.strElems = null; } } - + public boolean isEmpty() { return this.orig == null || this.orig.length() == 0; } - + public String getOriginal() { return this.orig; } @@ -84,28 +84,28 @@ * null context argument will return the original String. * @param context A context Map containing the variable values * @return The original String expanded by replacing varaible place holders. - */ + */ public String expandString(Map<String, ? extends Object> context) { return this.expandString(context, null, null); } - + /** This expands the pre-parsed String given the context passed in. A * null context argument will return the original String. * @param context A context Map containing the variable values * @param locale the current set locale * @return The original String expanded by replacing varaible place holders. - */ + */ public String expandString(Map<String, ? extends Object> context, Locale locale) { return this.expandString(context, null, locale); } - + /** This expands the pre-parsed String given the context passed in. A * null context argument will return the original String. * @param context A context Map containing the variable values * @param timeZone the current set time zone * @param locale the current set locale * @return The original String expanded by replacing varaible place holders. - */ + */ public String expandString(Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) { if (this.strElems == null || context == null) { return this.orig == null ? "" : this.orig; @@ -139,7 +139,7 @@ } return buffer.toString(); } - + /** Returns a FlexibleStringExpander instance. * @param original The original String expression * @return A FlexibleStringExpander instance @@ -164,7 +164,7 @@ } return fse; } - + /** Does on-the-fly parsing and expansion of the original String using * variable values from the passed context. A null context argument will * return the original String. @@ -175,7 +175,7 @@ public static String expandString(String original, Map<String, ? extends Object> context) { return expandString(original, context, null, null); } - + /** Does on-the-fly parsing and expansion of the original String using * variable values from the passed context. A null context argument will * return the original String. @@ -186,7 +186,7 @@ public static String expandString(String original, Map<String, ? extends Object> context, Locale locale) { return expandString(original, context, null, locale); } - + /** Does on-the-fly parsing and expansion of the original String using * variable values from the passed context. A null context argument will * return the original String. @@ -201,7 +201,7 @@ FlexibleStringExpander fse = FlexibleStringExpander.getInstance(original); return fse.expandString(context, timeZone, locale); } - + /** Protected helper method. * @param original * @return a list of parsed string elements @@ -225,7 +225,7 @@ if (end == -1) { Debug.logWarning("Found a ${ without a closing } (curly-brace) in the String: " + original, module); break; - } + } if (start > currentInd) { // append everything from the current index to the start of the var strElems.add(new ConstElem(original.substring(currentInd, start))); @@ -270,17 +270,17 @@ protected static interface StrElem extends Serializable { public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale); } - + protected static class ConstElem implements StrElem { protected final String str; protected ConstElem(String value) { this.str = value.intern(); } public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) { - buffer.append(this.str); + buffer.append(this.str); } } - + protected static class BshElem implements StrElem { protected final String str; protected BshElem(String scriptlet) { @@ -327,7 +327,7 @@ } } } - + protected static class NestedVarElem implements StrElem { protected final List<StrElem> strElems; protected int hint = 20; Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/JuelConnector.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/JuelConnector.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/JuelConnector.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/JuelConnector.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -33,11 +33,11 @@ *<p>The Unified Expression Language specification doesn't allow assignment of * values to non-existent variables (auto-vivify) - but the OFBiz scripting * languages do. This class modifies the JUEL library behavior to enable - * auto-vivify.</p> + * auto-vivify.</p> */ public class JuelConnector { protected static final String module = JuelConnector.class.getName(); - + /** Returns an <code>ExpressionFactory</code> instance. * @return A customized <code>ExpressionFactory</code> instance */ @@ -110,7 +110,7 @@ } } } - + /** Custom <code>Parser</code> class needed to implement auto-vivify. */ protected static class ExtendedParser extends Parser { public ExtendedParser(Builder context, String input) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -117,7 +117,7 @@ return this.variableMapper; } } - + protected static class BasicVariableMapper extends VariableMapper { protected final ELContext elContext; protected final Map<String, Object> variables; Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -68,9 +68,9 @@ * */ public class FreeMarkerWorker { - + public static final String module = FreeMarkerWorker.class.getName(); - + // use soft references for this so that things from Content records don't kill all of our memory, or maybe not for performance reasons... hmmm, leave to config file... public static UtilCache<String, Template> cachedTemplates = new UtilCache<String, Template>("template.ftl.general", 0, 0, false); protected static BeansWrapper defaultOfbizWrapper = BeansWrapper.getDefaultInstance(); @@ -78,7 +78,7 @@ public static Configuration makeConfiguration(BeansWrapper wrapper) { Configuration newConfig = new Configuration(); - + newConfig.setObjectWrapper(wrapper); newConfig.setSharedVariable("Static", wrapper.getStaticModels()); newConfig.setLocalizedLookup(false); @@ -109,10 +109,10 @@ loadTransforms(loader, props, newConfig); } } - + return newConfig; } - + /** * Protected helper method. */ @@ -140,7 +140,7 @@ public static void renderTemplateAtLocation(String templateLocation, Map<String, Object> context, Appendable outWriter) throws MalformedURLException, TemplateException, IOException { renderTemplate(templateLocation, context, outWriter); } - + /** * Renders a template contained in a String. * @param templateLocation A unique ID for this template - used for caching @@ -155,7 +155,7 @@ renderTemplateFromString(templateString, templateLocation, context, outWriter); } } - + /** * Renders a template from a Reader. * @param templateLocation A unique ID for this template - used for caching @@ -180,7 +180,7 @@ } } } - + return renderTemplate(template, context, outWriter); } @@ -205,7 +205,7 @@ env.process(); return env; } - + /** * Apply user settings to an Environment instance. * @param env An Environment instance @@ -228,13 +228,13 @@ public static Configuration getDefaultOfbizConfig() { return defaultOfbizConfig; } - + /** Make sure to close the reader when you're done! That's why this method is private, BTW. */ private static Reader makeReader(String templateLocation) throws IOException { if (UtilValidate.isEmpty(templateLocation)) { throw new IllegalArgumentException("FreeMarker template location null or empty"); } - + URL locationUrl = null; try { locationUrl = FlexibleLocation.resolveLocation(templateLocation); @@ -244,10 +244,10 @@ if (locationUrl == null) { throw new IllegalArgumentException("FreeMarker file not found at location: " + templateLocation); } - + InputStream locationIs = locationUrl.openStream(); Reader templateReader = new InputStreamReader(locationIs); - + String locationProtocol = locationUrl.getProtocol(); if ("file".equals(locationProtocol) && Debug.verboseOn()) { String locationFile = locationUrl.getFile(); @@ -256,7 +256,7 @@ String filename = locationFile.substring(lastSlash + 1); Debug.logVerbose("FreeMarker render: filename=" + filename + ", locationDir=" + locationDir, module); } - + return templateReader; } @@ -268,7 +268,7 @@ public static Template getTemplate(String templateLocation) throws TemplateException, IOException { return getTemplate(templateLocation, cachedTemplates, defaultOfbizConfig); } - + public static Template getTemplate(String templateLocation, UtilCache<String, Template> cache, Configuration config) throws TemplateException, IOException { Template template = (Template) cache.get(templateLocation); if (template == null) { @@ -285,7 +285,7 @@ } return template; } - + public static String getArg(Map<String, ? extends Object> args, String key, Environment env) { Map<String, ? extends Object> templateContext = UtilGenerics.checkMap(FreeMarkerWorker.getWrappedObject("context", env)); return getArg(args, key, templateContext); @@ -417,7 +417,7 @@ } else if (o instanceof BeanModel) { returnObj = ((BeanModel)o).getWrappedObject(); } - + return returnObj; } @@ -452,7 +452,7 @@ } return templateRoot; } - + public static void saveContextValues(Map<String, Object> context, String [] saveKeyNames, Map<String, Object> saveMap ) { //Map saveMap = new HashMap(); for (String key: saveKeyNames) { @@ -571,7 +571,7 @@ } return templateModelObj; } - + /** * OFBiz Template Source. This class is used by FlexibleTemplateLoader. */ @@ -583,7 +583,7 @@ public FlexibleTemplateSource(String templateLocation) { this.templateLocation = templateLocation; } - + public int hashCode() { return templateLocation.hashCode(); } @@ -597,7 +597,7 @@ return createdDate.getTime(); } } - + /** * OFBiz Template Loader. This template loader uses the FlexibleLocation * class to locate and load Freemarker templates. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/XslTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/XslTransform.java?rev=757046&r1=757045&r2=757046&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/XslTransform.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/XslTransform.java Sat Mar 21 22:46:22 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -46,7 +46,7 @@ /** * XslTransform - * + * * This utility takes an input document and a XSL stylesheet and performs the * transform, returning the output document. * The input for both the input document and stylesheet can be in one of three forms @@ -59,7 +59,7 @@ public static final String module = XslTransform.class.getName(); public static UtilCache<String, Templates> xslTemplatesCache = new UtilCache<String, Templates>("XsltTemplates", 0, 0); - public static Document transform(Map<String, Object> context, Map<String, Object> params) + public static Document transform(Map<String, Object> context, Map<String, Object> params) throws GeneralException, IOException, TransformerConfigurationException, TransformerException { Document outputDocument = null; TransformerFactory tFactory = TransformerFactory.newInstance(); @@ -88,22 +88,22 @@ transformer.setParameter(key, val); } } - + DOMResult outputResult = new DOMResult(UtilXml.makeEmptyXmlDocument()); - + String inputUrl = (String)context.get("inputUrl"); String inputString = (String)context.get("inputString"); Document inputDocument = (Document)context.get("inputDocument"); Source inputSource = getSource(inputDocument, inputUrl, inputString); - + transformer.transform(inputSource, outputResult); Node nd = outputResult.getNode(); outputDocument = (Document)nd; } - return outputDocument; + return outputDocument; } - + private static Source getSource(Document inputDocument, String inputUrl, String inputString) throws GeneralException, IOException { Source source = null; if (inputDocument != null) { |
Free forum by Nabble | Edit this page |