diff options
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java')
-rw-r--r-- | moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java | 165 |
1 files changed, 82 insertions, 83 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java index 7842f14..1eec502 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java @@ -21,7 +21,6 @@ * that you distribute must include a readable copy of the "NOTICE" text file. */ - package at.gv.egovernment.moa.spss.server.invoke; import java.util.ArrayList; @@ -30,14 +29,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import iaik.server.modules.xml.Base64Transformation; -import iaik.server.modules.xml.Canonicalization; -import iaik.server.modules.xml.EnvelopedSignatureTransformation; -import iaik.server.modules.xml.Transformation; -import iaik.server.modules.xml.XPath2Transformation; -import iaik.server.modules.xml.XPathTransformation; -import iaik.server.modules.xml.XSLTTransformation; - import at.gv.egovernment.moa.spss.MOAApplicationException; import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; import at.gv.egovernment.moa.spss.api.common.Transform; @@ -53,41 +44,49 @@ import at.gv.egovernment.moa.spss.server.iaik.xml.XPath2FilterImpl; import at.gv.egovernment.moa.spss.server.iaik.xml.XPath2TransformationImpl; import at.gv.egovernment.moa.spss.server.iaik.xml.XPathTransformationImpl; import at.gv.egovernment.moa.spss.server.iaik.xml.XSLTTransformationImpl; +import iaik.server.modules.xml.Base64Transformation; +import iaik.server.modules.xml.Canonicalization; +import iaik.server.modules.xml.EnvelopedSignatureTransformation; +import iaik.server.modules.xml.Transformation; +import iaik.server.modules.xml.XPath2Transformation; +import iaik.server.modules.xml.XPathTransformation; +import iaik.server.modules.xml.XSLTTransformation; /** - * A factory to create <code>Transformation</code> objects from + * A factory to create <code>Transformation</code> objects from * <code>Transform</code> objects. - * + * * @author Patrick Peck * @version $Id$ */ public class TransformationFactory { - /** The single instance of this class. */ private static TransformationFactory instance = null; - /** Maps <code>XPathFilter</code> filter types to - * <code>XPath2Transformation</code> filter types. */ + /** + * Maps <code>XPathFilter</code> filter types to + * <code>XPath2Transformation</code> filter types. + */ private static Map FILTER_TYPE_MAPPING; static { FILTER_TYPE_MAPPING = new HashMap(); FILTER_TYPE_MAPPING.put( - XPathFilter.INTERSECT_TYPE, - XPath2Transformation.XPath2Filter.INTERSECTION); + XPathFilter.INTERSECT_TYPE, + XPath2Transformation.XPath2Filter.INTERSECTION); FILTER_TYPE_MAPPING.put( - XPathFilter.SUBTRACT_TYPE, - XPath2Transformation.XPath2Filter.SUBTRACTION); + XPathFilter.SUBTRACT_TYPE, + XPath2Transformation.XPath2Filter.SUBTRACTION); FILTER_TYPE_MAPPING.put( - XPathFilter.UNION_TYPE, - XPath2Transformation.XPath2Filter.UNION); + XPathFilter.UNION_TYPE, + XPath2Transformation.XPath2Filter.UNION); } /** * Get the single instance of the factory. - * + * * @return TransformationFactory The single instance. */ public static synchronized TransformationFactory getInstance() { @@ -99,37 +98,36 @@ public class TransformationFactory { /** * Create a new <code>TransformationFactory</code>. - * + * * Protected to disallow multiple instances. */ protected TransformationFactory() { } /** - * Create a <code>Transformation</code> based on a - * <code>Transform</code> object. - * - * @param transform The <code>Transform</code> object to extract - * transformation data from. - * @return The transformation contained in the <code>transform</code> + * Create a <code>Transformation</code> based on a <code>Transform</code> * object. + * + * @param transform The <code>Transform</code> object to extract transformation + * data from. + * @return The transformation contained in the <code>transform</code> object. * @throws MOAApplicationException An error occured creating the - * <code>Transformation</code>. See exception message for details. + * <code>Transformation</code>. See exception + * message for details. */ public Transformation createTransformation(Transform transform) - throws MOAApplicationException { - String algorithmUri = transform.getAlgorithmURI(); + throws MOAApplicationException { + final String algorithmUri = transform.getAlgorithmURI(); if (Canonicalization.CANONICAL_XML.equals(algorithmUri) - || Canonicalization.CANONICAL_XML_WITH_COMMENTS.equals(algorithmUri)) { + || Canonicalization.CANONICAL_XML_WITH_COMMENTS.equals(algorithmUri)) { return createC14nTransformation(algorithmUri); - } else if ( - Canonicalization.EXCLUSIVE_CANONICAL_XML.equals(algorithmUri) + } else if (Canonicalization.EXCLUSIVE_CANONICAL_XML.equals(algorithmUri) || Canonicalization.EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS.equals( - algorithmUri)) { + algorithmUri)) { return createExclusiveC14nTransformation( - (ExclusiveCanonicalizationTransform) transform); + (ExclusiveCanonicalizationTransform) transform); } else if (Base64Transformation.ALL.contains(algorithmUri)) { return createBase64Transformation(); @@ -147,23 +145,24 @@ public class TransformationFactory { } /** - * Create a <code>List</code> of <code>Transformation</code>s from a + * Create a <code>List</code> of <code>Transformation</code>s from a * <code>List</code> of <code>Transform</code>s. - * - * @param transforms The <code>List</code> containing the - * <code>Transform</code>s. + * + * @param transforms The <code>List</code> containing the + * <code>Transform</code>s. * @return The <code>List</code> of <code>Transformation</code>s corresponding - * to the <code>transforms</code>. + * to the <code>transforms</code>. * @throws MOAApplicationException An error occurred building one of the - * transformations. See exception message for details. + * transformations. See exception message for + * details. */ public List createTransformationList(List transforms) - throws MOAApplicationException { - List transformationList = new ArrayList(); + throws MOAApplicationException { + final List transformationList = new ArrayList(); Iterator trIter; for (trIter = transforms.iterator(); trIter.hasNext();) { - Transform transform = (Transform) trIter.next(); + final Transform transform = (Transform) trIter.next(); transformationList.add(createTransformation(transform)); } @@ -172,7 +171,7 @@ public class TransformationFactory { /** * Create a <code>Canonicalization</code>. - * + * * @param algorithmUri The algorithm URI of the canonicalization. * @return The <code>Canonicalization</code>. */ @@ -182,20 +181,20 @@ public class TransformationFactory { /** * Create a <code>ExclusiveCanonicalization</code>. - * - * @param transform The <code>ExclusiveCanonicalizationTransform</code> - * containing the transformation data. + * + * @param transform The <code>ExclusiveCanonicalizationTransform</code> + * containing the transformation data. * @return The <code>ExclusiveCanonicalization</code>. */ private Transformation createExclusiveC14nTransformation(ExclusiveCanonicalizationTransform transform) { return new ExclusiveCanonicalizationImpl( - transform.getAlgorithmURI(), - transform.getInclusiveNamespacePrefixes()); + transform.getAlgorithmURI(), + transform.getInclusiveNamespacePrefixes()); } /** * Create a <code>Base64Transformation</code>. - * + * * @return The <code></code> */ private Transformation createBase64Transformation() { @@ -204,7 +203,7 @@ public class TransformationFactory { /** * Create an <code>EnvelopedSignatureTransformation</code>. - * + * * @return An <code>EnvelopedSignatureTransformation</code>. */ private Transformation createEnvelopedSignatureTransformation() { @@ -213,47 +212,47 @@ public class TransformationFactory { /** * Create an <code>XPathTransformation</code>. - * - * @param transform The <code>Transform</code> object containing the - * XPath transformation. - * @return An <code>XPathTransformation</code> corresponding the - * transformation given in <code>transform</code>. - * @throws MOAApplicationException An error occurred creating the - * <code>Transformation</code>. + * + * @param transform The <code>Transform</code> object containing the XPath + * transformation. + * @return An <code>XPathTransformation</code> corresponding the transformation + * given in <code>transform</code>. + * @throws MOAApplicationException An error occurred creating the + * <code>Transformation</code>. */ private Transformation createXPathTransformation(XPathTransform transform) - throws MOAApplicationException { + throws MOAApplicationException { return new XPathTransformationImpl( - transform.getXPathExpression(), - transform.getNamespaceDeclarations()); + transform.getXPathExpression(), + transform.getNamespaceDeclarations()); } /** * Create an <code>XPath2Transformation</code>. - * - * @param transform The <code>Transform</code> object containing the - * XPath filter transformation. - * @return An <code>XPath2Transformation</code> corresponding the - * transformation given in <code>transform</code>. + * + * @param transform The <code>Transform</code> object containing the XPath + * filter transformation. + * @return An <code>XPath2Transformation</code> corresponding the transformation + * given in <code>transform</code>. * @throws MOAApplicationException An error occurred creating the - * <code>Transformation</code>. + * <code>Transformation</code>. */ private Transformation createXPath2Transformation(XPathFilter2Transform transform) - throws MOAApplicationException { + throws MOAApplicationException { - XPath2TransformationImpl xpath2 = new XPath2TransformationImpl(); + final XPath2TransformationImpl xpath2 = new XPath2TransformationImpl(); Iterator iter; for (iter = transform.getFilters().iterator(); iter.hasNext();) { - XPathFilter filter = (XPathFilter) iter.next(); - String mappedFilterType = - (String) FILTER_TYPE_MAPPING.get(filter.getFilterType()); - XPath2FilterImpl mappedFilter = - new XPath2FilterImpl( - mappedFilterType, - filter.getXPathExpression(), - filter.getNamespaceDeclarations()); + final XPathFilter filter = (XPathFilter) iter.next(); + final String mappedFilterType = + (String) FILTER_TYPE_MAPPING.get(filter.getFilterType()); + final XPath2FilterImpl mappedFilter = + new XPath2FilterImpl( + mappedFilterType, + filter.getXPathExpression(), + filter.getNamespaceDeclarations()); xpath2.addXPathFilter(mappedFilter); } @@ -266,15 +265,15 @@ public class TransformationFactory { /** * Create an <code>XSLTTransformation</code>. - * + * * @param transform The <code>Transform</code> containing the XSLT stylesheet. * @return An <code>XSLTTransformation</code> corresponding the transformation - * given in <code>transform</code>. + * given in <code>transform</code>. * @throws MOAApplicationException An error occurred creating the - * <code>Transformation</code>. + * <code>Transformation</code>. */ private Transformation createXSLTTransformation(XSLTTransform transform) - throws MOAApplicationException { + throws MOAApplicationException { return new XSLTTransformationImpl(transform.getStylesheet()); } |