psteitz 2004/06/17 21:59:06 Modified: math/src/java/org/apache/commons/math/util DefaultTransformer.java TransformerMap.java package.html Log: Formatting only. Eliminated tabs. Revision Changes Path 1.15 +12 -12 jakarta-commons/math/src/java/org/apache/commons/math/util/DefaultTransformer.java Index: DefaultTransformer.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/util/DefaultTransformer.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- DefaultTransformer.java 1 Jun 2004 21:35:13 -0000 1.14 +++ DefaultTransformer.java 18 Jun 2004 04:59:06 -0000 1.15 @@ -42,18 +42,18 @@ */ public double transform(Object o) throws MathException{ - if (o == null) { - throw new MathException("Conversion Exception in Transformation, Object is null"); - } + if (o == null) { + throw new MathException("Conversion Exception in Transformation, Object is null"); + } - if (o instanceof Number) { - return ((Number)o).doubleValue(); - } + if (o instanceof Number) { + return ((Number)o).doubleValue(); + } - try { - return new Double(o.toString()).doubleValue(); - } catch (Exception e) { - throw new MathException("Conversion Exception in Transformation: " + e.getMessage(), e); - } + try { + return new Double(o.toString()).doubleValue(); + } catch (Exception e) { + throw new MathException("Conversion Exception in Transformation: " + e.getMessage(), e); + } } } 1.14 +112 -112 jakarta-commons/math/src/java/org/apache/commons/math/util/TransformerMap.java Index: TransformerMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/util/TransformerMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- TransformerMap.java 1 Jun 2004 21:35:13 -0000 1.13 +++ TransformerMap.java 18 Jun 2004 04:59:06 -0000 1.14 @@ -35,117 +35,117 @@ /** Serializable version identifier */ static final long serialVersionUID = -942772950698439883L; - /** - * A default Number Transformer for Numbers and numeric Strings. - */ - private NumberTransformer defaultTransformer = null; - - /** - * The internal Map. - */ - private Map map = null; - - /** - * - */ - public TransformerMap() { - map = new HashMap(); - defaultTransformer = new DefaultTransformer(); - } - - /** - * Tests if a Class is present in the TransformerMap. - * @param key Class to check - * @return true|false - */ - public boolean containsClass(Class key) { - return map.containsKey(key); - } - - /** - * Tests if a NumberTransformer is present in the TransformerMap. - * @param value NumberTransformer to check - * @return true|false - */ - public boolean containsTransformer(NumberTransformer value) { - return map.containsValue(value); - } - - /** - * Returns the Transformer that is mapped to a class - * if mapping is not present, this returns null. - * @param key The Class of the object - * @return the mapped NumberTransformer or null. - */ - public NumberTransformer getTransformer(Class key) { - return (NumberTransformer) map.get(key); - } - - /** - * Sets a Class to Transformer Mapping in the Map. If - * the Class is already present, this overwrites that - * mapping. - * @param key The Class - * @param transformer The NumberTransformer - * @return the replaced transformer if one is present - */ - public Object putTransformer(Class key, NumberTransformer transformer) { - return map.put(key, transformer); - } - - /** - * Removes a Class to Transformer Mapping in the Map. - * @param key The Class - * @return the removed transformer if one is present or - * null if none was present. - */ - public Object removeTransformer(Class key) { - return map.remove(key); - } - - /** - * Clears all the Class to Transformer mappings. - */ - public void clear() { - map.clear(); - } - - /** - * Returns the Set of Classes used as keys in the map. - * @return Set of Classes - */ - public Set classes() { - return map.keySet(); - } - - /** - * Returns the Set of NumberTransformers used as values - * in the map. - * @return Set of NumberTransformers - */ - public Collection transformers() { - return map.values(); - } - - /** - * Attempts to transform the Object against the map of - * NumberTransformers. Otherwise it returns Double.NaN. - * - * @see org.apache.commons.math.util.NumberTransformer#transform(java.lang.Object) - */ - public double transform(Object o) throws MathException { - double value = Double.NaN; - - if (o instanceof Number || o instanceof String) { - value = defaultTransformer.transform(o); - } else { - NumberTransformer trans = getTransformer(o.getClass()); - if (trans != null) { - value = trans.transform(o); - } - } + /** + * A default Number Transformer for Numbers and numeric Strings. + */ + private NumberTransformer defaultTransformer = null; + + /** + * The internal Map. + */ + private Map map = null; + + /** + * + */ + public TransformerMap() { + map = new HashMap(); + defaultTransformer = new DefaultTransformer(); + } + + /** + * Tests if a Class is present in the TransformerMap. + * @param key Class to check + * @return true|false + */ + public boolean containsClass(Class key) { + return map.containsKey(key); + } + + /** + * Tests if a NumberTransformer is present in the TransformerMap. + * @param value NumberTransformer to check + * @return true|false + */ + public boolean containsTransformer(NumberTransformer value) { + return map.containsValue(value); + } + + /** + * Returns the Transformer that is mapped to a class + * if mapping is not present, this returns null. + * @param key The Class of the object + * @return the mapped NumberTransformer or null. + */ + public NumberTransformer getTransformer(Class key) { + return (NumberTransformer) map.get(key); + } + + /** + * Sets a Class to Transformer Mapping in the Map. If + * the Class is already present, this overwrites that + * mapping. + * @param key The Class + * @param transformer The NumberTransformer + * @return the replaced transformer if one is present + */ + public Object putTransformer(Class key, NumberTransformer transformer) { + return map.put(key, transformer); + } + + /** + * Removes a Class to Transformer Mapping in the Map. + * @param key The Class + * @return the removed transformer if one is present or + * null if none was present. + */ + public Object removeTransformer(Class key) { + return map.remove(key); + } + + /** + * Clears all the Class to Transformer mappings. + */ + public void clear() { + map.clear(); + } + + /** + * Returns the Set of Classes used as keys in the map. + * @return Set of Classes + */ + public Set classes() { + return map.keySet(); + } + + /** + * Returns the Set of NumberTransformers used as values + * in the map. + * @return Set of NumberTransformers + */ + public Collection transformers() { + return map.values(); + } + + /** + * Attempts to transform the Object against the map of + * NumberTransformers. Otherwise it returns Double.NaN. + * + * @see org.apache.commons.math.util.NumberTransformer#transform(java.lang.Object) + */ + public double transform(Object o) throws MathException { + double value = Double.NaN; + + if (o instanceof Number || o instanceof String) { + value = defaultTransformer.transform(o); + } else { + NumberTransformer trans = getTransformer(o.getClass()); + if (trans != null) { + value = trans.transform(o); + } + } - return value; - } + return value; + } } 1.6 +2 -2 jakarta-commons/math/src/java/org/apache/commons/math/util/package.html Index: package.html =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/util/package.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- package.html 26 Apr 2004 18:28:16 -0000 1.5 +++ package.html 18 Jun 2004 04:59:06 -0000 1.6 @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - <!-- $Revision$ $Date$ --> - <body>Convience routines and common data structure used throughout the commons-math library.</body> + <!-- $Revision$ $Date$ --> + <body>Convience routines and common data structure used throughout the commons-math library.</body> </html>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]