/** {@inheritDoc} */ public Format[] getSourceFormats() throws RuntimeException { Vector<Format> sourceFormats = new Vector<Format>(); TransformationsDocument transDoc = null; TransformationsType transType = null; java.io.InputStream in; try { in = ResourceUtil.getResourceAsStream(this.EXPLAIN_FILE_PATH + this.EXPLAIN_FILE_NAME); transDoc = TransformationsDocument.Factory.parse(in); } catch (Exception e) { this.logger.error( "An error occurred while reading transformations.xml for common publication formats.", e); throw new RuntimeException(e); } transType = transDoc.getTransformations(); TransformationType[] transformations = transType.getTransformationArray(); for (int i = 0; i < transformations.length; i++) { TransformationType transformation = transformations[i]; String name = this.util.simpleLiteralTostring(transformation.getSource().getName()); String type = this.util.simpleLiteralTostring(transformation.getSource().getType()); String encoding = this.util.simpleLiteralTostring(transformation.getSource().getEncoding()); Format sourceFormat = new Format(name, type, encoding); sourceFormats.add(sourceFormat); } sourceFormats = this.util.getRidOfDuplicatesInVector(sourceFormats); Format[] dummy = new Format[sourceFormats.size()]; return sourceFormats.toArray(dummy); }
/** {@inheritDoc} */ public Format[] getTargetFormats(Format src) throws RuntimeException { Vector<Format> targetFormats = new Vector<Format>(); TransformationsDocument transDoc = null; TransformationsType transType = null; java.io.InputStream in; try { in = ResourceUtil.getResourceAsStream(this.EXPLAIN_FILE_PATH + this.EXPLAIN_FILE_NAME); transDoc = TransformationsDocument.Factory.parse(in); } catch (Exception e) { this.logger.error( "An error occurred while reading transformations.xml for standard publication formats.", e); throw new RuntimeException(e); } transType = transDoc.getTransformations(); TransformationType[] transformations = transType.getTransformationArray(); for (TransformationType transformation : transformations) { Format source = new Format( this.util.simpleLiteralTostring(transformation.getSource().getName()), this.util.simpleLiteralTostring(transformation.getSource().getType()), this.util.simpleLiteralTostring(transformation.getSource().getEncoding())); // Only get Target if source is given source if (this.util.isFormatEqual(source, src)) { String name = this.util.simpleLiteralTostring(transformation.getTarget().getName()); String type = this.util.simpleLiteralTostring(transformation.getTarget().getType()); String encoding = this.util.simpleLiteralTostring(transformation.getTarget().getEncoding()); Format sourceFormat = new Format(name, type, encoding); targetFormats.add(sourceFormat); } } targetFormats = this.util.getRidOfDuplicatesInVector(targetFormats); Format[] dummy = new Format[targetFormats.size()]; return targetFormats.toArray(dummy); }