* Licensed 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 KIND, either express or implied.
import org.onap.aaf.misc.rosetta.marshal.DocMarshal;
public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> {
-
+
static InJson inJSON = new InJson();
InXML inXML;
static OutJson outJSON = new OutJson();
OutXML outXML;
static OutRaw outRAW = new OutRaw();
-
+
// Temporary until we write JAXB impl...
JAXBmar jaxMar;
JAXBumar jaxUmar;
-
+
private Parse<Reader,?> defaultIn;
private Out defaultOut;
private RosettaEnv env;
private TYPE outType;
private int defOption;
Marshal<T> marshal = null;
-
+
/**
* Private constructor to setup Type specific data manipulators
RosettaDF(RosettaEnv env, Schema schema, String rootNs, Class<T> cls) throws APIException {
this.env = env;
try {
- // Note: rootNs can be null, in order to derive content from Class.
+ // Note: rootNs can be null, in order to derive content from Class.
JaxInfo ji = rootNs==null?JaxInfo.build(cls):JaxInfo.build(cls,rootNs);
// Note: JAXBmar sets qname to null if not exists
jaxMar = new JAXBmar(rootNs==null?null:new QName("xmlns",rootNs),cls);
// Note: JAXBumar sets schema to null if not exists
jaxUmar = new JAXBumar(schema, cls);
-
+
defaultIn = inXML = new InXML(ji);
defaultOut = outXML = new OutXML(ji);
inType=outType=Data.TYPE.XML;
throw new APIException(e);
}
}
-
+
// @Override
public RosettaData<T> newData() {
- RosettaData<T> data = new RosettaData<T>(env, this)
+ RosettaData<T> data = new RosettaData<T>(env, this)
.in(inType)
.out(outType)
.option(defOption);
/**
* If exists, first option is "Pretty", second is "Fragment"
- *
+ *
* @param options
* @return
*/
defaultOut = getOut(type==Data.TYPE.DEFAULT?Data.TYPE.JSON:type);
return this;
}
-
+
public Parse<Reader,?> getIn(Data.TYPE type) {
switch(type) {
case DEFAULT:
return defaultIn;
}
}
-
+
public Out getOut(Data.TYPE type) {
switch(type) {
case DEFAULT:
return defaultOut;
}
}
-
+
public int logType(org.onap.aaf.misc.env.Data.TYPE ot) {
switch(ot) {
case JSON:
public RosettaDF<T> option(int option) {
defOption = option;
-
+
return this;
}
/**
* Assigning Root Marshal Object
- *
+ *
* Will wrap with DocMarshal Object if not already
- *
+ *
* @param marshal
* @return
*/
}
return this;
}
-
+
public void direct(Trans trans, T t, OutputStream os, boolean ... options) throws APIException, IOException {
Out out = getOut(outType);
TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env?