summaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-07 12:21:34 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-07 12:22:50 -0500
commit4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch)
treea36d03227b63a3e60346d6c3ca87b061087dae85 /misc
parent824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff)
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473 Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'misc')
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java94
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java806
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java30
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Data.java108
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java6
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java16
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java14
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Env.java156
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java42
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java96
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java50
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java78
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java146
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java196
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java40
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java114
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java78
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Store.java148
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java400
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java28
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java154
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java56
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java2
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java60
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java350
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java46
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java580
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java78
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java58
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java94
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java126
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java10
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java526
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java478
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java186
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java198
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java374
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java346
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java50
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java78
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java40
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java22
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java28
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java524
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java70
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java54
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java618
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java134
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java128
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java70
-rw-r--r--misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java62
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java60
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java146
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java70
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java202
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java64
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java30
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java192
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java302
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java94
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java108
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java52
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java202
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java202
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java64
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java90
-rw-r--r--misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java102
-rw-r--r--misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java92
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java240
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java866
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java2
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java408
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java94
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java148
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java92
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java56
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java26
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java42
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java384
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java28
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java368
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java34
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java24
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java112
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java34
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java288
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java676
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java378
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java506
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java78
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java188
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java94
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java110
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java20
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java16
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java16
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java16
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java54
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java18
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java16
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java46
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java100
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java168
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java416
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java408
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java190
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java84
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java60
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java236
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java118
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java146
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java80
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java454
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java106
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java70
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java16
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java96
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java18
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java18
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java174
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java2
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java12
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java28
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java52
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java524
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java98
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java206
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java246
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java54
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java418
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java128
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java326
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java4
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java20
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java28
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java14
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java40
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java20
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java10
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java42
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java396
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java134
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java46
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java342
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java38
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java40
146 files changed, 11011 insertions, 11011 deletions
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java b/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java
index bf1d357f..4aa1451e 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java
@@ -35,55 +35,55 @@ package org.onap.aaf.misc.env;
*
*/
public class APIException extends Exception {
-
- private Object payload = null;
-
- /**
- * @param t
- */
- public APIException(Throwable t) {
- super(t);
- }
-
- /**
- * @param string
- */
- public APIException(String string) {
- super(string);
- }
+
+ private Object payload = null;
+
+ /**
+ * @param t
+ */
+ public APIException(Throwable t) {
+ super(t);
+ }
+
+ /**
+ * @param string
+ */
+ public APIException(String string) {
+ super(string);
+ }
- /**
- * @param errorMessage
- * @param t
- */
- public APIException(String errorMessage, Throwable t) {
- super(errorMessage,t);
- }
+ /**
+ * @param errorMessage
+ * @param t
+ */
+ public APIException(String errorMessage, Throwable t) {
+ super(errorMessage,t);
+ }
- /**
- * Return payload, or null if none was set. Type is up to the calling
- * System.
- *
- * @return Object
- */
- public Object getPayload() {
- return payload;
- }
+ /**
+ * Return payload, or null if none was set. Type is up to the calling
+ * System.
+ *
+ * @return Object
+ */
+ public Object getPayload() {
+ return payload;
+ }
- /**
- * Set a specific payload into this Exception, which doesn't necessarily
- * inherit from Throwable.
- *
- * @param payload
- * @return APIException
- */
- public APIException setPayload(Object payload) {
- this.payload = payload;
- return this;
- }
+ /**
+ * Set a specific payload into this Exception, which doesn't necessarily
+ * inherit from Throwable.
+ *
+ * @param payload
+ * @return APIException
+ */
+ public APIException setPayload(Object payload) {
+ this.payload = payload;
+ return this;
+ }
- /**
- * Java expected serial ID
- */
- private static final long serialVersionUID = 3505343458251445169L;
+ /**
+ * Java expected serial ID
+ */
+ private static final long serialVersionUID = 3505343458251445169L;
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java
index 78615018..d72222e8 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java
@@ -54,425 +54,425 @@ import org.xml.sax.SAXException;
* @param <T>
*/
public class BaseDataFactory {
- private static final Object LOCK = new Object();
- /**
- * Generate a Schema Object for use in validation based on FileNames.
- *
- * WARNING: The java.xml.binding code requires YOU to figure out what order the
- * files go in. If there is an import from A in B, then you must list A first.
- *
- * @param err
- * @param filenames
- * @return
- * @throws APIException
- */
- public static Schema genSchema(Store env, String ... filenames) throws APIException {
- String schemaDir = env.get(
- env.staticSlot(EnvFactory.SCHEMA_DIR),
- EnvFactory.DEFAULT_SCHEMA_DIR);
- File dir = new File(schemaDir);
- if(!dir.exists())throw new APIException("Schema Directory " + schemaDir + " does not exist. You can set this with " + EnvFactory.SCHEMA_DIR + " property");
- FileInputStream[] fis = new FileInputStream[filenames.length];
- Source[] sources = new Source[filenames.length];
- File f;
- for(int i=0; i<filenames.length; ++i) {
- if(!(f=new File(schemaDir + File.separatorChar + filenames[i])).exists()) {
- if(!f.exists()) throw new APIException("Cannot find " + f.getName() + " for schema validation");
- }
- try {
- fis[i]=new FileInputStream(f);
- } catch (FileNotFoundException e) {
- throw new APIException(e);
- }
- sources[i]= new StreamSource(fis[i]);
- }
- try {
- //Note: SchemaFactory is not reentrant or very thread safe either... see docs
- synchronized(LOCK) { // SchemaFactory is not reentrant
- return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
- .newSchema(sources);
- }
- } catch (SAXException e) {
- throw new APIException(e);
- } finally {
- for(FileInputStream d : fis) {
- try {
- d.close();
- } catch (IOException e) {
- // Never mind... we did our best
- }
- }
- }
+ private static final Object LOCK = new Object();
+ /**
+ * Generate a Schema Object for use in validation based on FileNames.
+ *
+ * WARNING: The java.xml.binding code requires YOU to figure out what order the
+ * files go in. If there is an import from A in B, then you must list A first.
+ *
+ * @param err
+ * @param filenames
+ * @return
+ * @throws APIException
+ */
+ public static Schema genSchema(Store env, String ... filenames) throws APIException {
+ String schemaDir = env.get(
+ env.staticSlot(EnvFactory.SCHEMA_DIR),
+ EnvFactory.DEFAULT_SCHEMA_DIR);
+ File dir = new File(schemaDir);
+ if(!dir.exists())throw new APIException("Schema Directory " + schemaDir + " does not exist. You can set this with " + EnvFactory.SCHEMA_DIR + " property");
+ FileInputStream[] fis = new FileInputStream[filenames.length];
+ Source[] sources = new Source[filenames.length];
+ File f;
+ for(int i=0; i<filenames.length; ++i) {
+ if(!(f=new File(schemaDir + File.separatorChar + filenames[i])).exists()) {
+ if(!f.exists()) throw new APIException("Cannot find " + f.getName() + " for schema validation");
+ }
+ try {
+ fis[i]=new FileInputStream(f);
+ } catch (FileNotFoundException e) {
+ throw new APIException(e);
+ }
+ sources[i]= new StreamSource(fis[i]);
+ }
+ try {
+ //Note: SchemaFactory is not reentrant or very thread safe either... see docs
+ synchronized(LOCK) { // SchemaFactory is not reentrant
+ return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
+ .newSchema(sources);
+ }
+ } catch (SAXException e) {
+ throw new APIException(e);
+ } finally {
+ for(FileInputStream d : fis) {
+ try {
+ d.close();
+ } catch (IOException e) {
+ // Never mind... we did our best
+ }
+ }
+ }
- }
+ }
- public static QName getQName(Class<?> clss) throws APIException {
- // Obtain the Necessary info for QName from Requirement
- XmlRootElement xre = clss.getAnnotation(XmlRootElement.class);
- if(xre==null)throw new APIException(clss.getName() + " does not have an XmlRootElement annotation");
- Package pkg = clss.getPackage();
- XmlSchema xs = pkg.getAnnotation(XmlSchema.class);
- if(xs==null) throw new APIException(clss.getName() + " package-info does not have an XmlSchema annotation");
- return new QName(xs.namespace(),xre.name());
- }
+ public static QName getQName(Class<?> clss) throws APIException {
+ // Obtain the Necessary info for QName from Requirement
+ XmlRootElement xre = clss.getAnnotation(XmlRootElement.class);
+ if(xre==null)throw new APIException(clss.getName() + " does not have an XmlRootElement annotation");
+ Package pkg = clss.getPackage();
+ XmlSchema xs = pkg.getAnnotation(XmlSchema.class);
+ if(xs==null) throw new APIException(clss.getName() + " package-info does not have an XmlSchema annotation");
+ return new QName(xs.namespace(),xre.name());
+ }
- /////////////////////////////////////////////
- // Native Type Converters
- /////////////////////////////////////////////
-// /**
-// * StringStringifier
-// *
-// * Support the Native Type String.. just return it back
-// *
-// * @author Jonathan
-// *
-// */
-// public static class StringStringifier extends NullLifeCycle implements Stringifier<String> {
-// /* (non-Javadoc)
-// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
-// */
-// public String stringify(Env env, String input) throws APIException {
-// return input;
-// }
-// };
+ /////////////////////////////////////////////
+ // Native Type Converters
+ /////////////////////////////////////////////
+// /**
+// * StringStringifier
+// *
+// * Support the Native Type String.. just return it back
+// *
+// * @author Jonathan
+// *
+// */
+// public static class StringStringifier extends NullLifeCycle implements Stringifier<String> {
+// /* (non-Javadoc)
+// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
+// */
+// public String stringify(Env env, String input) throws APIException {
+// return input;
+// }
+// };
//
-// /**
-// * StringObjectifier
-// *
-// * Support the Native Type String.. just return it back
-// *
-// * @author Jonathan
-// *
-// */
-// public static class StringObjectifier extends NullLifeCycle implements Objectifier<String> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public String objectify(Env env, String input) throws APIException {
-// return input;
-// }
+// /**
+// * StringObjectifier
+// *
+// * Support the Native Type String.. just return it back
+// *
+// * @author Jonathan
+// *
+// */
+// public static class StringObjectifier extends NullLifeCycle implements Objectifier<String> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public String objectify(Env env, String input) throws APIException {
+// return input;
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public String newInstance() throws APIException {
-// return "";
-// }
-// };
-//
-// /**
-// * LongStringifier
-// *
-// * Support the Native Type Long.. use Long parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class LongStringifier extends NullLifeCycle implements Stringifier<Long> {
-// public String stringify(Env env, Long input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * LongObjectifier
-// *
-// * Support the Native Type Long.. use Long parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class LongObjectifier extends NullLifeCycle implements Objectifier<Long> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public Long objectify(Env env, String input) throws APIException {
-// try {
-// return new Long(input);
-// } catch (Exception e) {
-// APIException ae = new APIException("Cannot create a \"Long\" from [" + input + ']');
-// ae.initCause(e);
-// throw ae;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public String newInstance() throws APIException {
+// return "";
+// }
+// };
+//
+// /**
+// * LongStringifier
+// *
+// * Support the Native Type Long.. use Long parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class LongStringifier extends NullLifeCycle implements Stringifier<Long> {
+// public String stringify(Env env, Long input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * LongObjectifier
+// *
+// * Support the Native Type Long.. use Long parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class LongObjectifier extends NullLifeCycle implements Objectifier<Long> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public Long objectify(Env env, String input) throws APIException {
+// try {
+// return new Long(input);
+// } catch (Exception e) {
+// APIException ae = new APIException("Cannot create a \"Long\" from [" + input + ']');
+// ae.initCause(e);
+// throw ae;
+// }
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public Long newInstance() throws APIException {
-// return 0L;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public Long newInstance() throws APIException {
+// return 0L;
+// }
+// }
//
-// /**
-// * IntegerStringifier
-// *
-// * Support the Native Integer.. use Integer parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class IntegerStringifier extends NullLifeCycle implements Stringifier<Integer> {
-// /* (non-Javadoc)
-// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
-// */
-// public String stringify(Env env, Integer input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * IntegerObjectifier
-// *
-// * Support the Native Integer.. use Integer parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class IntegerObjectifier extends NullLifeCycle implements Objectifier<Integer> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public Integer objectify(Env env, String input) throws APIException {
-// try {
-// return new Integer(input);
-// } catch (Exception e) {
-// APIException ae = new APIException("Cannot create a \"Integer\" from [" + input + ']');
-// ae.initCause(e);
-// throw ae;
-// }
-// }
+// /**
+// * IntegerStringifier
+// *
+// * Support the Native Integer.. use Integer parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class IntegerStringifier extends NullLifeCycle implements Stringifier<Integer> {
+// /* (non-Javadoc)
+// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
+// */
+// public String stringify(Env env, Integer input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * IntegerObjectifier
+// *
+// * Support the Native Integer.. use Integer parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class IntegerObjectifier extends NullLifeCycle implements Objectifier<Integer> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public Integer objectify(Env env, String input) throws APIException {
+// try {
+// return new Integer(input);
+// } catch (Exception e) {
+// APIException ae = new APIException("Cannot create a \"Integer\" from [" + input + ']');
+// ae.initCause(e);
+// throw ae;
+// }
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public Integer newInstance() throws APIException {
-// return 0;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public Integer newInstance() throws APIException {
+// return 0;
+// }
+// }
//
-// /**
-// * ShortStringifier
-// *
-// * Support the Native Short.. use Short parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class ShortStringifier extends NullLifeCycle implements Stringifier<Short> {
-// public String stringify(Env env, Short input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * ShortObjectifier
-// *
-// * Support the Native Short.. use Short parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class ShortObjectifier extends NullLifeCycle implements Objectifier<Short> {
-// public Short objectify(Env env, String input) throws APIException {
-// try {
-// return new Short(input);
-// } catch (Exception e) {
-// APIException ae = new APIException("Cannot create a \"Short\" from [" + input + ']');
-// ae.initCause(e);
-// throw ae;
-// }
-// }
+// /**
+// * ShortStringifier
+// *
+// * Support the Native Short.. use Short parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class ShortStringifier extends NullLifeCycle implements Stringifier<Short> {
+// public String stringify(Env env, Short input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * ShortObjectifier
+// *
+// * Support the Native Short.. use Short parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class ShortObjectifier extends NullLifeCycle implements Objectifier<Short> {
+// public Short objectify(Env env, String input) throws APIException {
+// try {
+// return new Short(input);
+// } catch (Exception e) {
+// APIException ae = new APIException("Cannot create a \"Short\" from [" + input + ']');
+// ae.initCause(e);
+// throw ae;
+// }
+// }
//
-// public Short newInstance() throws APIException {
-// return 0;
-// }
-// }
-//
-// /**
-// * ByteStringifier
-// *
-// * Support the Native Byte.. use Byte parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class ByteStringifier extends NullLifeCycle implements Stringifier<Byte> {
-// /* (non-Javadoc)
-// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
-// */
-// public String stringify(Env env, Byte input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * ByteObjectifier
-// *
-// * Support the Native Byte.. use Byte parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class ByteObjectifier extends NullLifeCycle implements Objectifier<Byte> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public Byte objectify(Env env, String input) throws APIException {
-// try {
-// return new Byte(input);
-// } catch (Exception e) {
-// APIException ae = new APIException("Cannot create a \"Byte\" from [" + input + ']');
-// ae.initCause(e);
-// throw ae;
-// }
-// }
+// public Short newInstance() throws APIException {
+// return 0;
+// }
+// }
+//
+// /**
+// * ByteStringifier
+// *
+// * Support the Native Byte.. use Byte parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class ByteStringifier extends NullLifeCycle implements Stringifier<Byte> {
+// /* (non-Javadoc)
+// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
+// */
+// public String stringify(Env env, Byte input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * ByteObjectifier
+// *
+// * Support the Native Byte.. use Byte parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class ByteObjectifier extends NullLifeCycle implements Objectifier<Byte> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public Byte objectify(Env env, String input) throws APIException {
+// try {
+// return new Byte(input);
+// } catch (Exception e) {
+// APIException ae = new APIException("Cannot create a \"Byte\" from [" + input + ']');
+// ae.initCause(e);
+// throw ae;
+// }
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public Byte newInstance() throws APIException {
-// return 0;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public Byte newInstance() throws APIException {
+// return 0;
+// }
+// }
//
-// /**
-// * CharacterStringifier
-// *
-// * Support the Native Character.. use Character parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class CharacterStringifier extends NullLifeCycle implements Stringifier<Character> {
-// /* (non-Javadoc)
-// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
-// */
-// public String stringify(Env env, Character input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * CharacterObjectifier
-// *
-// * Support the Native Character.. use Character parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class CharacterObjectifier extends NullLifeCycle implements Objectifier<Character> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public Character objectify(Env env, String input) throws APIException {
-// int length = input.length();
-// if(length<1 || length>1) {
-// throw new APIException("String [" + input + "] does not represent a single Character");
-// }
-// return input.charAt(0);
-// }
+// /**
+// * CharacterStringifier
+// *
+// * Support the Native Character.. use Character parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class CharacterStringifier extends NullLifeCycle implements Stringifier<Character> {
+// /* (non-Javadoc)
+// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
+// */
+// public String stringify(Env env, Character input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * CharacterObjectifier
+// *
+// * Support the Native Character.. use Character parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class CharacterObjectifier extends NullLifeCycle implements Objectifier<Character> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public Character objectify(Env env, String input) throws APIException {
+// int length = input.length();
+// if(length<1 || length>1) {
+// throw new APIException("String [" + input + "] does not represent a single Character");
+// }
+// return input.charAt(0);
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public Character newInstance() throws APIException {
-// return 0;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public Character newInstance() throws APIException {
+// return 0;
+// }
+// }
//
-// /**
-// * FloatStringifier
-// *
-// * Support the Native Float.. use Float parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class FloatStringifier extends NullLifeCycle implements Stringifier<Float> {
-// /* (non-Javadoc)
-// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
-// */
-// public String stringify(Env env, Float input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * FloatObjectifier
-// *
-// * Support the Native Float.. use Float parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class FloatObjectifier extends NullLifeCycle implements Objectifier<Float> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public Float objectify(Env env, String input) throws APIException {
-// try {
-// return new Float(input);
-// } catch (Exception e) {
-// APIException ae = new APIException("Cannot create a \"Float\" from [" + input + ']');
-// ae.initCause(e);
-// throw ae;
-// }
-// }
+// /**
+// * FloatStringifier
+// *
+// * Support the Native Float.. use Float parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class FloatStringifier extends NullLifeCycle implements Stringifier<Float> {
+// /* (non-Javadoc)
+// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
+// */
+// public String stringify(Env env, Float input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * FloatObjectifier
+// *
+// * Support the Native Float.. use Float parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class FloatObjectifier extends NullLifeCycle implements Objectifier<Float> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public Float objectify(Env env, String input) throws APIException {
+// try {
+// return new Float(input);
+// } catch (Exception e) {
+// APIException ae = new APIException("Cannot create a \"Float\" from [" + input + ']');
+// ae.initCause(e);
+// throw ae;
+// }
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public Float newInstance() throws APIException {
-// return 0.0f;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public Float newInstance() throws APIException {
+// return 0.0f;
+// }
+// }
//
-// /**
-// * DoubleStringifier
-// *
-// * Support the Native Double.. use Double parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class DoubleStringifier extends NullLifeCycle implements Stringifier<Double> {
-// /* (non-Javadoc)
-// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
-// */
-// public String stringify(Env env, Double input) throws APIException {
-// return input.toString();
-// }
-// }
-//
-// /**
-// * DoubleObjectifier
-// *
-// * Support the Native Double.. use Double parse functions
-// *
-// * @author Jonathan
-// *
-// */
-// public static class DoubleObjectifier extends NullLifeCycle implements Objectifier<Double> {
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
-// */
-// public Double objectify(Env env, String input) throws APIException {
-// try {
-// return new Double(input);
-// } catch (Exception e) {
-// APIException ae = new APIException("Cannot create a \"Double\" from [" + input + ']');
-// ae.initCause(e);
-// throw ae;
-// }
-// }
+// /**
+// * DoubleStringifier
+// *
+// * Support the Native Double.. use Double parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class DoubleStringifier extends NullLifeCycle implements Stringifier<Double> {
+// /* (non-Javadoc)
+// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object)
+// */
+// public String stringify(Env env, Double input) throws APIException {
+// return input.toString();
+// }
+// }
+//
+// /**
+// * DoubleObjectifier
+// *
+// * Support the Native Double.. use Double parse functions
+// *
+// * @author Jonathan
+// *
+// */
+// public static class DoubleObjectifier extends NullLifeCycle implements Objectifier<Double> {
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String)
+// */
+// public Double objectify(Env env, String input) throws APIException {
+// try {
+// return new Double(input);
+// } catch (Exception e) {
+// APIException ae = new APIException("Cannot create a \"Double\" from [" + input + ']');
+// ae.initCause(e);
+// throw ae;
+// }
+// }
//
-// /* (non-Javadoc)
-// * @see com.att.env.Objectifier#newObject()
-// */
-// public Double newInstance() throws APIException {
-// return 0.0;
-// }
-// }
+// /* (non-Javadoc)
+// * @see com.att.env.Objectifier#newObject()
+// */
+// public Double newInstance() throws APIException {
+// return 0.0;
+// }
+// }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java
index 2423ed62..c64cfff2 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java
@@ -34,19 +34,19 @@ package org.onap.aaf.misc.env;
* @param <T>
*/
public interface Creatable<T> {
- /**
- * Return the timestamp (Unix long) when this object was created.<p>
- * This can be used to see if the object is out of date in certain
- * circumstances, or perhaps has already been notified in others.
- *
- * @return long
- */
- public abstract long created();
-
- /**
- * Allow LifeCycle aware process to signal this element as destroyed.
- *
- * @param env
- */
- public abstract void destroy(Env env);
+ /**
+ * Return the timestamp (Unix long) when this object was created.<p>
+ * This can be used to see if the object is out of date in certain
+ * circumstances, or perhaps has already been notified in others.
+ *
+ * @return long
+ */
+ public abstract long created();
+
+ /**
+ * Allow LifeCycle aware process to signal this element as destroyed.
+ *
+ * @param env
+ */
+ public abstract void destroy(Env env);
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java
index 155dfc71..4c64e5de 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java
@@ -42,7 +42,7 @@ import java.io.Writer;
* the "options" available on several functions control the output of this particular call. When
* blank, they will default to the DataFactory defaults. When present, they override this
* particular call.
- * The available options are "pretty" (for XML and JSON) and "fragment" (XML only concept), which drops
+ * The available options are "pretty" (for XML and JSON) and "fragment" (XML only concept), which drops
* the "<?xml ...?>" header so you can create larger XML documents from the output.
*
* @author Jonathan
@@ -50,64 +50,64 @@ import java.io.Writer;
* @param <T>
*/
public interface Data<T> {
- static enum TYPE {XML,JSON,JAXB,RAW,DEFAULT};
- // can & with 0xFFFF;
-// public static final int XML = 0x1;
-// public static final int JSON = 0x2;
-// public static final int JAXB = 0x4;
-// public static final int RAW = 0x1000;
-
- // can & with 0xF00000;
- public static final int PRETTY = 0x100000;
- public static final int FRAGMENT = 0x200000;
+ static enum TYPE {XML,JSON,JAXB,RAW,DEFAULT};
+ // can & with 0xFFFF;
+// public static final int XML = 0x1;
+// public static final int JSON = 0x2;
+// public static final int JAXB = 0x4;
+// public static final int RAW = 0x1000;
+
+ // can & with 0xF00000;
+ public static final int PRETTY = 0x100000;
+ public static final int FRAGMENT = 0x200000;
- /**
- * Respond with the String if it exists, or marshal the String and pass the result back.
- *
- * However, use the Env the Data Object was created with.
- *
- * @return String
- * @throws APIException
- */
- public String asString() throws APIException;
+ /**
+ * Respond with the String if it exists, or marshal the String and pass the result back.
+ *
+ * However, use the Env the Data Object was created with.
+ *
+ * @return String
+ * @throws APIException
+ */
+ public String asString() throws APIException;
- /**
- * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String
- * and pass the result back.<p>
- *
- * However, use the Env the Data Object was created with.
- *
- * @return T
- * @throws APIException
- */
- public T asObject() throws APIException;
+ /**
+ * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String
+ * and pass the result back.<p>
+ *
+ * However, use the Env the Data Object was created with.
+ *
+ * @return T
+ * @throws APIException
+ */
+ public T asObject() throws APIException;
- /**
- * Set a particular option on an existing Out
- *
- * if int is negative, it should remove the option
- * @param option
- */
- public Data<T> option(int option);
+ /**
+ * Set a particular option on an existing Out
+ *
+ * if int is negative, it should remove the option
+ * @param option
+ */
+ public Data<T> option(int option);
- public Data<T> to(OutputStream os) throws APIException, IOException;
- public Data<T> to(Writer writer) throws APIException, IOException;
-
- public Data<T> load(T t) throws APIException;
- public Data<T> load(String str) throws APIException;
- public Data<T> load(InputStream is) throws APIException;
- public Data<T> load(Reader rdr) throws APIException;
-
- public Data<T> in(TYPE type);
- public Data<T> out(TYPE type);
- /**
- * Return the Class Type supported by this DataObject
- *
- * @return {@literal Class<T>}
- */
- public Class<T> getTypeClass();
+ public Data<T> to(OutputStream os) throws APIException, IOException;
+ public Data<T> to(Writer writer) throws APIException, IOException;
+
+ public Data<T> load(T t) throws APIException;
+ public Data<T> load(String str) throws APIException;
+ public Data<T> load(InputStream is) throws APIException;
+ public Data<T> load(Reader rdr) throws APIException;
+
+ public Data<T> in(TYPE type);
+ public Data<T> out(TYPE type);
+ /**
+ * Return the Class Type supported by this DataObject
+ *
+ * @return {@literal Class<T>}
+ */
+ public Class<T> getTypeClass();
- public void direct(InputStream input, OutputStream output) throws APIException, IOException;
+ public void direct(InputStream input, OutputStream output) throws APIException, IOException;
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java
index a9595a55..6735e9a6 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java
@@ -23,8 +23,8 @@ package org.onap.aaf.misc.env;
public interface DataFactory<T> {
- public abstract Data<T> newData();
- public abstract Data<T> newData(Env trans); // and Env or Trans object
- public abstract Class<T> getTypeClass();
+ public abstract Data<T> newData();
+ public abstract Data<T> newData(Env trans); // and Env or Trans object
+ public abstract Class<T> getTypeClass();
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java
index bc29c318..48d55e0a 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java
@@ -23,12 +23,12 @@ package org.onap.aaf.misc.env;
public interface Decryptor {
- public String decrypt(String tag);
-
- public static final Decryptor NULL = new Decryptor() {
- @Override
- public String decrypt(String tag) {
- return tag;
- }
- };
+ public String decrypt(String tag);
+
+ public static final Decryptor NULL = new Decryptor() {
+ @Override
+ public String decrypt(String tag) {
+ return tag;
+ }
+ };
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java
index ad7409d0..1925f65e 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java
@@ -23,12 +23,12 @@ package org.onap.aaf.misc.env;
public interface Encryptor {
- public String encrypt(String data);
+ public String encrypt(String data);
- public static final Encryptor NULL = new Encryptor() {
- @Override
- public String encrypt(String data) {
- return data;
- }
- };
+ public static final Encryptor NULL = new Encryptor() {
+ @Override
+ public String encrypt(String data) {
+ return data;
+ }
+ };
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java
index e4b6aaa2..f709a434 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java
@@ -46,91 +46,91 @@ package org.onap.aaf.misc.env;
*
*/
public interface Env {
- /**
- * Very Severe Error may cause program to abort
- */
- public LogTarget fatal();
-
- /**
- * Severe Error, but program might continue running
- */
- public LogTarget error();
+ /**
+ * Very Severe Error may cause program to abort
+ */
+ public LogTarget fatal();
+
+ /**
+ * Severe Error, but program might continue running
+ */
+ public LogTarget error();
- /**
- * Required Audit statements
- * @return
- */
- public LogTarget audit();
+ /**
+ * Required Audit statements
+ * @return
+ */
+ public LogTarget audit();
- /**
- * Initialization steps... Allows a Logger to separate startup info
- * @return
- */
- public LogTarget init();
+ /**
+ * Initialization steps... Allows a Logger to separate startup info
+ * @return
+ */
+ public LogTarget init();
- /**
- * Potentially harmful situations
- * @return
- */
- public LogTarget warn();
-
- /**
- * Course Grained highlights of program progress
- * @return
- */
- public LogTarget info();
-
- /**
- * Fine-grained informational events useful for debugging
- * @return
- */
- public LogTarget debug();
-
- /**
- * Finest grained Informational events... more detailed than Debug
- * @return
- */
- public LogTarget trace();
+ /**
+ * Potentially harmful situations
+ * @return
+ */
+ public LogTarget warn();
+
+ /**
+ * Course Grained highlights of program progress
+ * @return
+ */
+ public LogTarget info();
+
+ /**
+ * Fine-grained informational events useful for debugging
+ * @return
+ */
+ public LogTarget debug();
+
+ /**
+ * Finest grained Informational events... more detailed than Debug
+ * @return
+ */
+ public LogTarget trace();
- /**
- * Basic and Common Audit info...
- *
- * Note Apps can define, but should use Integers after 0x1F. They can combine with "&"
- */
- public static final int REMOTE = 0x01;
- public static final int XML = 0x02;
- public static final int JSON = 0x04;
- public static final int SUB = 0x08;
- public static final int CHECKPOINT = 0x10;
- public static final int ALWAYS = 0x20; // Mark as a line to print, even in WARN+ mode
+ /**
+ * Basic and Common Audit info...
+ *
+ * Note Apps can define, but should use Integers after 0x1F. They can combine with "&"
+ */
+ public static final int REMOTE = 0x01;
+ public static final int XML = 0x02;
+ public static final int JSON = 0x04;
+ public static final int SUB = 0x08;
+ public static final int CHECKPOINT = 0x10;
+ public static final int ALWAYS = 0x20; // Mark as a line to print, even in WARN+ mode
-
- /**
- * Start a Time Trail with differentiation by flag. This can be Defined By above flags or combined with
- * app flag definitions
- *
- * @param string
- * @param flag
- * @return
- */
- public TimeTaken start(String name, int flag);
-
- public String setProperty(String tag, String value);
- public String getProperty(String tag);
- public String getProperty(String tag, String deflt);
-
- /**
- * Passwords should be encrypted on the disk. Use this method to apply decryption before
- * using. The Implementation should give ways to decrypt
- *
- * @param tag
- * @return
- */
- public Decryptor decryptor();
-
- public Encryptor encryptor();
+
+ /**
+ * Start a Time Trail with differentiation by flag. This can be Defined By above flags or combined with
+ * app flag definitions
+ *
+ * @param string
+ * @param flag
+ * @return
+ */
+ public TimeTaken start(String name, int flag);
+
+ public String setProperty(String tag, String value);
+ public String getProperty(String tag);
+ public String getProperty(String tag, String deflt);
+
+ /**
+ * Passwords should be encrypted on the disk. Use this method to apply decryption before
+ * using. The Implementation should give ways to decrypt
+ *
+ * @param tag
+ * @return
+ */
+ public Decryptor decryptor();
+
+ public Encryptor encryptor();
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java
index a530073e..09db36f4 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java
@@ -25,28 +25,28 @@ import javax.xml.namespace.QName;
import javax.xml.validation.Schema;
public interface EnvJAXB extends EnvStore<TransJAXB> {
- /**
- * Obtain a DataInterface from this Environment
- *
- * @param <T>
- * @param classes
- * @return
- * @throws APIException
- */
- public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException;
+ /**
+ * Obtain a DataInterface from this Environment
+ *
+ * @param <T>
+ * @param classes
+ * @return
+ * @throws APIException
+ */
+ public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException;
- /**
- * Obtain a DataInterface from this Environment, with Validating Schema
- *
- * @param <T>
- * @param classes
- * @return
- * @throws APIException
- */
- public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException;
+ /**
+ * Obtain a DataInterface from this Environment, with Validating Schema
+ *
+ * @param <T>
+ * @param classes
+ * @return
+ * @throws APIException
+ */
+ public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException;
- public<T> DataFactory<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException;
+ public<T> DataFactory<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException;
- public<T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException;
-
+ public<T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException;
+
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java
index 0e645da2..b2cebb55 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java
@@ -24,57 +24,57 @@ package org.onap.aaf.misc.env;
import java.util.Map;
public interface EnvProps extends Env {
- public interface EnvProperty {
- public String getProperty(String input);
- };
+ public interface EnvProperty {
+ public String getProperty(String input);
+ };
- /**
- * Obtain a Property (String) based on a Key. Implementor decides how
- * that works, i.e. from a complex set of Configurations, or just
- * "System" (Java standard)
- *
- * @param key
- * @return APIException
- */
- public String getProperty(String key);
+ /**
+ * Obtain a Property (String) based on a Key. Implementor decides how
+ * that works, i.e. from a complex set of Configurations, or just
+ * "System" (Java standard)
+ *
+ * @param key
+ * @return APIException
+ */
+ public String getProperty(String key);
- /**
- * Obtain a Property (String) based on a Key. Implementor decides how
- * that works, i.e. from a complex set of Configurations, or just
- * "System" (Java standard)
- *
- * If Property Value is null, then default will be used.
- * @param key
- * @return APIException
- */
- public String getProperty(String tag, String defaultValue);
+ /**
+ * Obtain a Property (String) based on a Key. Implementor decides how
+ * that works, i.e. from a complex set of Configurations, or just
+ * "System" (Java standard)
+ *
+ * If Property Value is null, then default will be used.
+ * @param key
+ * @return APIException
+ */
+ public String getProperty(String tag, String defaultValue);
- /**
- * Set a Property (String) based on a Key accessible to all in Env. Implementor decides how
- * that works, i.e. from a complex set of Configurations, or just
- * "System" (Java standard)
- *
- * @param key
- * @return APIException
- */
- public String setProperty(String key, String value);
-
- /**
- * Get the SubProperties based on key.
- *
- * use "false" to remove prefix, "true" to leave prefix in.
- *
- * @param key
- * @return APIException
- * Given a known property set (or in this case, properties starting with key),
- * return map of all properties with appropriate key names
- */
- public Map<String, String> getSubProperties(String key, boolean includePrefix);
+ /**
+ * Set a Property (String) based on a Key accessible to all in Env. Implementor decides how
+ * that works, i.e. from a complex set of Configurations, or just
+ * "System" (Java standard)
+ *
+ * @param key
+ * @return APIException
+ */
+ public String setProperty(String key, String value);
+
+ /**
+ * Get the SubProperties based on key.
+ *
+ * use "false" to remove prefix, "true" to leave prefix in.
+ *
+ * @param key
+ * @return APIException
+ * Given a known property set (or in this case, properties starting with key),
+ * return map of all properties with appropriate key names
+ */
+ public Map<String, String> getSubProperties(String key, boolean includePrefix);
- /**
- * Get all of the properties in the Environment
- * @return
- */
- public Map<String, String> getProperties();
+ /**
+ * Get all of the properties in the Environment
+ * @return
+ */
+ public Map<String, String> getProperties();
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java
index e3e74305..70b4adde 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java
@@ -25,30 +25,30 @@ import java.io.InputStream;
import java.io.Reader;
public interface IOObjectifier<T> extends Objectifier<T> {
- /**
- * Marshal to Object T from a Reader, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return T
- * @throws APIException
- */
- public abstract T objectify(Env env, Reader rdr) throws APIException;
-
- /**
- * Marshal to Object T from an InputStream, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return T
- * @throws APIException
- */
- public abstract T objectify(Env env, InputStream is) throws APIException;
+ /**
+ * Marshal to Object T from a Reader, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return T
+ * @throws APIException
+ */
+ public abstract T objectify(Env env, Reader rdr) throws APIException;
+
+ /**
+ * Marshal to Object T from an InputStream, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return T
+ * @throws APIException
+ */
+ public abstract T objectify(Env env, InputStream is) throws APIException;
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java
index 57d85472..4329fcbc 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java
@@ -28,47 +28,47 @@ import java.io.Writer;
* Allow Extended IO interface usage without muddying up the Stringifier Interface
*/
public interface IOStringifier<T> extends Stringifier<T> {
- /**
- * Marshal from an Object T onto a Writer, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startTime(<string>, Env.XML)" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return String
- * @throws APIException
- */
- public abstract void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException;
-
- /**
- * Marshal from a String to an Object T, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return String
- * @throws APIException
- */
- public abstract void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException;
+ /**
+ * Marshal from an Object T onto a Writer, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startTime(<string>, Env.XML)" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return String
+ * @throws APIException
+ */
+ public abstract void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException;
+
+ /**
+ * Marshal from a String to an Object T, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return String
+ * @throws APIException
+ */
+ public abstract void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException;
- /**
- * Set Pretty XML, where possible
- *
- * @param pretty
- * @throws APIException
- */
- public abstract IOStringifier<T> pretty(boolean pretty);
+ /**
+ * Set Pretty XML, where possible
+ *
+ * @param pretty
+ * @throws APIException
+ */
+ public abstract IOStringifier<T> pretty(boolean pretty);
- /**
- * Set Generate Fragment
- *
- * @param fragment
- * @throws APIException
- */
- public abstract IOStringifier<T> asFragment(boolean fragment);
+ /**
+ * Set Generate Fragment
+ *
+ * @param fragment
+ * @throws APIException
+ */
+ public abstract IOStringifier<T> asFragment(boolean fragment);
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java b/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java
index 5124f6b5..75f3b701 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java
@@ -43,81 +43,81 @@ import org.onap.aaf.misc.env.util.RefreshableThreadObject;
*
*/
public interface LifeCycle {
- /**
- * The Service using LifeCycle Elements is required to call this method at
- * the appropriate startup time. This is better for services than a simple
- * static call, because the exact moment of starting can be determined
- * programatically.
- * <p>
- *
- * An excellent use is to establish security credentials with a backend
- * after appropriate configurations have been read and available as part of
- * the {@link Env} Object.
- *
- * @param env
- * @throws APIException
- */
- public abstract void servicePrestart(Env env) throws APIException;
+ /**
+ * The Service using LifeCycle Elements is required to call this method at
+ * the appropriate startup time. This is better for services than a simple
+ * static call, because the exact moment of starting can be determined
+ * programatically.
+ * <p>
+ *
+ * An excellent use is to establish security credentials with a backend
+ * after appropriate configurations have been read and available as part of
+ * the {@link Env} Object.
+ *
+ * @param env
+ * @throws APIException
+ */
+ public abstract void servicePrestart(Env env) throws APIException;
- /**
- * Many cases of implementations are not thread safe, and mechanisms must be
- * derived to accomodate them by holding per Thread.
- * <p>
- *
- * {@link ThreadLocal} is a valuable resource, but start up times within the
- * thread, depending on what it is, can be substantial.
- * <p>
- *
- * Use ThreadPrestart to do all that is possible before actually performing
- * work, i.e. inside of a client transaction.
- *
- * @param env
- * @throws APIException
- */
- public abstract void threadPrestart(Env env) throws APIException;
+ /**
+ * Many cases of implementations are not thread safe, and mechanisms must be
+ * derived to accomodate them by holding per Thread.
+ * <p>
+ *
+ * {@link ThreadLocal} is a valuable resource, but start up times within the
+ * thread, depending on what it is, can be substantial.
+ * <p>
+ *
+ * Use ThreadPrestart to do all that is possible before actually performing
+ * work, i.e. inside of a client transaction.
+ *
+ * @param env
+ * @throws APIException
+ */
+ public abstract void threadPrestart(Env env) throws APIException;
- /**
- * The Service will call this when (service-defined) configurations change.
- * <p>
- *
- * This mechanism allows the Service to recognize events, such as file
- * changes, and pass on the event to all LifeCycle implementors.
- * <p>
- *
- * The code should take the opportunity to evaluate configuration and change
- * as necessary.
- * <p>
- *
- * <h2>IMPORTANT:</h2>
- * The LifeCycle implementor cannot guarantee it will not be in the middle
- * of a transaction, so it would behoove the implementor to construct
- * content that does not affect anything until finished, then apply to an
- * appropriate atomic action (i.e. setting an Object to a field), or even
- * synchronizing.
- *
- * If you are using Java's "ThreadLocal", consider
- * {@link RefreshableThreadObject}, because it implements LifeCycle, and
- * responds to the refresh command.
- *
- * @param env
- * @throws APIException
- */
- public abstract void refresh(Env env) throws APIException;
+ /**
+ * The Service will call this when (service-defined) configurations change.
+ * <p>
+ *
+ * This mechanism allows the Service to recognize events, such as file
+ * changes, and pass on the event to all LifeCycle implementors.
+ * <p>
+ *
+ * The code should take the opportunity to evaluate configuration and change
+ * as necessary.
+ * <p>
+ *
+ * <h2>IMPORTANT:</h2>
+ * The LifeCycle implementor cannot guarantee it will not be in the middle
+ * of a transaction, so it would behoove the implementor to construct
+ * content that does not affect anything until finished, then apply to an
+ * appropriate atomic action (i.e. setting an Object to a field), or even
+ * synchronizing.
+ *
+ * If you are using Java's "ThreadLocal", consider
+ * {@link RefreshableThreadObject}, because it implements LifeCycle, and
+ * responds to the refresh command.
+ *
+ * @param env
+ * @throws APIException
+ */
+ public abstract void refresh(Env env) throws APIException;
- /**
- * Parallel to threadPrestart, threadDestroy tells the implementor that the
- * service is ending this particular thread, and to take this opportunity to
- * close out any content specific to this thread that can be closed.
- *
- * @param env
- * @throws APIException
- */
- public abstract void threadDestroy(Env env) throws APIException;
+ /**
+ * Parallel to threadPrestart, threadDestroy tells the implementor that the
+ * service is ending this particular thread, and to take this opportunity to
+ * close out any content specific to this thread that can be closed.
+ *
+ * @param env
+ * @throws APIException
+ */
+ public abstract void threadDestroy(Env env) throws APIException;
- /**
- * Parallel to servicePrestart, serviceDestroy tells the implementor that
- * the service is ending, and to take this opportunity to close out any
- * content under it's control that can or should be closed explicitly.
- */
- public abstract void serviceDestroy(Env env) throws APIException;
+ /**
+ * Parallel to servicePrestart, serviceDestroy tells the implementor that
+ * the service is ending, and to take this opportunity to close out any
+ * content under it's control that can or should be closed explicitly.
+ */
+ public abstract void serviceDestroy(Env env) throws APIException;
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java
index 8915becf..aa74edc9 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java
@@ -32,7 +32,7 @@ import org.onap.aaf.misc.env.util.Chrono;
* Implement for any Logging Library of your choice, and for any logging string Format desired.
*
* Included are several Static Implementations for various uses:
- * NULL: Does nothing with Logging Messages
+ * NULL: Does nothing with Logging Messages
* SYSOUT: Writes messages in general form to System Out
* SYSERR: Writes messages in general form to System Err
*
@@ -40,103 +40,103 @@ import org.onap.aaf.misc.env.util.Chrono;
*
*/
public interface LogTarget {
- public abstract void log(Object... msgs);
- public abstract void log(Throwable e, Object ... msgs);
- public abstract boolean isLoggable();
- public abstract void printf(String fmt, Object ... vars);
-
- // A Convenient LogTarget to insert when a NO-OP is desired.
- public static final LogTarget NULL = new LogTarget() {
- public void log(Object ... msgs) {
- }
-
- public void log(Throwable t, Object ... msgs) {
- }
-
- public boolean isLoggable() {
- return false;
- }
-
- @Override
- public void printf(String fmt, Object ... vars) {
- }
- };
-
- // A Convenient LogTarget to write to the Console
- public static final LogTarget SYSOUT = new LogTarget() {
- public void log(Object ... msgs) {
- PrintStream out = System.out;
- out.print(org.onap.aaf.misc.env.util.Chrono.dateFmt.format(new Date()));
- out.print(": ");
- for(Object str : msgs) {
- if(str!=null) {
- out.print(str.toString());
- out.print(' ');
- } else {
- out.print("null ");
- }
- }
- out.println();
- }
-
- public void log(Throwable t, Object ... msgs) {
- PrintStream out = System.out;
- out.print(Chrono.dateFmt.format(new Date()));
- out.print(": ");
- for(Object str : msgs) {
- out.print(str.toString());
- out.print(' ');
- }
- out.println();
- t.printStackTrace(out);
- out.println();
- }
-
- public boolean isLoggable() {
- return true;
- }
-
- @Override
- public void printf(String fmt, Object ... vars) {
- log(String.format(fmt,vars));
- }
- };
-
- // A Convenient LogTarget to write to the Console
- public static final LogTarget SYSERR = new LogTarget() {
- public void log(Object ... msgs) {
- PrintStream out = System.err;
- out.print(Chrono.dateFmt.format(new Date()));
- out.print(": ");
- for(Object str : msgs) {
- out.print(str.toString());
- out.print(' ');
- }
- out.println();
- out.flush();
- }
-
- public void log(Throwable t, Object ... msgs) {
- PrintStream out = System.err;
- out.print(Chrono.dateFmt.format(new Date()));
- out.print(": ");
- for(Object str : msgs) {
- out.print(str.toString());
- out.print(' ');
- }
- out.println();
- t.printStackTrace(out);
- }
-
- public boolean isLoggable() {
- return true;
- }
- @Override
- public void printf(String fmt, Object ... vars) {
- log(String.format(fmt,vars));
- }
-
- };
+ public abstract void log(Object... msgs);
+ public abstract void log(Throwable e, Object ... msgs);
+ public abstract boolean isLoggable();
+ public abstract void printf(String fmt, Object ... vars);
+
+ // A Convenient LogTarget to insert when a NO-OP is desired.
+ public static final LogTarget NULL = new LogTarget() {
+ public void log(Object ... msgs) {
+ }
+
+ public void log(Throwable t, Object ... msgs) {
+ }
+
+ public boolean isLoggable() {
+ return false;
+ }
+
+ @Override
+ public void printf(String fmt, Object ... vars) {
+ }
+ };
+
+ // A Convenient LogTarget to write to the Console
+ public static final LogTarget SYSOUT = new LogTarget() {
+ public void log(Object ... msgs) {
+ PrintStream out = System.out;
+ out.print(org.onap.aaf.misc.env.util.Chrono.dateFmt.format(new Date()));
+ out.print(": ");
+ for(Object str : msgs) {
+ if(str!=null) {
+ out.print(str.toString());
+ out.print(' ');
+ } else {
+ out.print("null ");
+ }
+ }
+ out.println();
+ }
+
+ public void log(Throwable t, Object ... msgs) {
+ PrintStream out = System.out;
+ out.print(Chrono.dateFmt.format(new Date()));
+ out.print(": ");
+ for(Object str : msgs) {
+ out.print(str.toString());
+ out.print(' ');
+ }
+ out.println();
+ t.printStackTrace(out);
+ out.println();
+ }
+
+ public boolean isLoggable() {
+ return true;
+ }
+
+ @Override
+ public void printf(String fmt, Object ... vars) {
+ log(String.format(fmt,vars));
+ }
+ };
+
+ // A Convenient LogTarget to write to the Console
+ public static final LogTarget SYSERR = new LogTarget() {
+ public void log(Object ... msgs) {
+ PrintStream out = System.err;
+ out.print(Chrono.dateFmt.format(new Date()));
+ out.print(": ");
+ for(Object str : msgs) {
+ out.print(str.toString());
+ out.print(' ');
+ }
+ out.println();
+ out.flush();
+ }
+
+ public void log(Throwable t, Object ... msgs) {
+ PrintStream out = System.err;
+ out.print(Chrono.dateFmt.format(new Date()));
+ out.print(": ");
+ for(Object str : msgs) {
+ out.print(str.toString());
+ out.print(' ');
+ }
+ out.println();
+ t.printStackTrace(out);
+ }
+
+ public boolean isLoggable() {
+ return true;
+ }
+ @Override
+ public void printf(String fmt, Object ... vars) {
+ log(String.format(fmt,vars));
+ }
+
+ };
}; \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java
index 039855e1..30c9c1da 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java
@@ -32,26 +32,26 @@ package org.onap.aaf.misc.env;
* the creation of an uninitialized object.
*/
public interface Objectifier<T> extends LifeCycle {
- /**
- * Marshal to Object T from a String, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return T
- * @throws APIException
- */
- public abstract T objectify(Env env, String input) throws APIException;
+ /**
+ * Marshal to Object T from a String, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return T
+ * @throws APIException
+ */
+ public abstract T objectify(Env env, String input) throws APIException;
- /**
- * Create a new object of type T. This is often more efficiently done with
- * the underlying XML (or other) Library.
- * @return T
- * @throws APIException
- */
- public abstract T newInstance() throws APIException;
+ /**
+ * Create a new object of type T. This is often more efficiently done with
+ * the underlying XML (or other) Library.
+ * @return T
+ * @throws APIException
+ */
+ public abstract T newInstance() throws APIException;
-
+
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java
index f79d12d4..33a65752 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java
@@ -40,63 +40,63 @@ package org.onap.aaf.misc.env;
* Slot's are used to store and retrieve data in the transaction's State object.
*/
public final class Slot {
-
- /*
- * The name of the Slot.
- */
- private final String key;
-
- /*
- * The index of the State's local map associated with this Slot.
- */
- final int slot;
-
- /**
- * Constructs a new Slot.
- *
- * @param index
- * The index of State's local map this Slot is associated with.
- * @param name
- * The name of the Slot's key.
- */
- Slot(int index, String name) {
- slot = index;
- key = name;
- }
-
- /**
- * Debug method only to print key=slot pairs.
- */
- public String toString() {
- return key + '=' + slot;
- }
-
- /**
- * Returns the name of this Slot's key.
- *
- * @return
- * The name of this Slot's key.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Put an Object into the slot on the State
- * @param state
- * @param obj
- */
- public void put(Object[] state, Object obj) {
- state[slot]=obj;
- }
+
+ /*
+ * The name of the Slot.
+ */
+ private final String key;
+
+ /*
+ * The index of the State's local map associated with this Slot.
+ */
+ final int slot;
+
+ /**
+ * Constructs a new Slot.
+ *
+ * @param index
+ * The index of State's local map this Slot is associated with.
+ * @param name
+ * The name of the Slot's key.
+ */
+ Slot(int index, String name) {
+ slot = index;
+ key = name;
+ }
+
+ /**
+ * Debug method only to print key=slot pairs.
+ */
+ public String toString() {
+ return key + '=' + slot;
+ }
+
+ /**
+ * Returns the name of this Slot's key.
+ *
+ * @return
+ * The name of this Slot's key.
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Put an Object into the slot on the State
+ * @param state
+ * @param obj
+ */
+ public void put(Object[] state, Object obj) {
+ state[slot]=obj;
+ }
- /**
- * Get an Object from the slot on the State
- * @param state
- * @param obj
- */
- public Object get(Object[] state) {
- return state[slot];
- }
+ /**
+ * Get an Object from the slot on the State
+ * @param state
+ * @param obj
+ */
+ public Object get(Object[] state) {
+ return state[slot];
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java b/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java
index 35bad1ba..0bff6a06 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java
@@ -41,45 +41,45 @@ package org.onap.aaf.misc.env;
*/
public final class StaticSlot {
- /*
- * The name of the StaticSlot.
- */
- private final String key;
-
- /*
- * The index of the Organizer's static map associated with this StaticSlot.
- */
- final int slot;
-
- /**
- * Constructs a new StaticSlot.
- *
- * @param index
- * The index of Organizer's static map this StaticSlot is associated with.
- * @param name
- * The name of the StaticSlot's key.
- */
- StaticSlot(int index, String name) {
- slot = index;
- key = name;
- }
-
- /**
- * Debug method only to print key=slot pairs.
- */
- public String toString() {
- return key + '=' + slot;
- }
-
- /**
- * Returns the name of this StaticSlot's key.
- *
- * @return
- * The name of this StaticSlot's key.
- */
- public String getKey() {
- return key;
- }
+ /*
+ * The name of the StaticSlot.
+ */
+ private final String key;
+
+ /*
+ * The index of the Organizer's static map associated with this StaticSlot.
+ */
+ final int slot;
+
+ /**
+ * Constructs a new StaticSlot.
+ *
+ * @param index
+ * The index of Organizer's static map this StaticSlot is associated with.
+ * @param name
+ * The name of the StaticSlot's key.
+ */
+ StaticSlot(int index, String name) {
+ slot = index;
+ key = name;
+ }
+
+ /**
+ * Debug method only to print key=slot pairs.
+ */
+ public String toString() {
+ return key + '=' + slot;
+ }
+
+ /**
+ * Returns the name of this StaticSlot's key.
+ *
+ * @return
+ * The name of this StaticSlot's key.
+ */
+ public String getKey() {
+ return key;
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java
index 43f5f521..8c810783 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java
@@ -24,85 +24,85 @@ package org.onap.aaf.misc.env;
import java.util.List;
public interface Store {
- /**
- * Returns the Slot assigned to the supplied name.
- *
- * @param name
- * The name of the Slot to acquire.
- * @return
- * The Slot associated with the supplied name.
- */
- public abstract Slot slot(String name);
+ /**
+ * Returns the Slot assigned to the supplied name.
+ *
+ * @param name
+ * The name of the Slot to acquire.
+ * @return
+ * The Slot associated with the supplied name.
+ */
+ public abstract Slot slot(String name);
- /**
- * Returns the existing Slot associated with the supplied name, or null if it doesn't exist.
- *
- * @param name
- * The name of the Slot to get.
- * @return
- * The Slot assigned to the supplied name, or null if it doesn't exist.
- *
- */
- public abstract Slot existingSlot(String name);
+ /**
+ * Returns the existing Slot associated with the supplied name, or null if it doesn't exist.
+ *
+ * @param name
+ * The name of the Slot to get.
+ * @return
+ * The Slot assigned to the supplied name, or null if it doesn't exist.
+ *
+ */
+ public abstract Slot existingSlot(String name);
- /**
- * Returns the names used while creating Slots in a List
- *
- * @return
- */
- public abstract List<String> existingSlotNames();
+ /**
+ * Returns the names used while creating Slots in a List
+ *
+ * @return
+ */
+ public abstract List<String> existingSlotNames();
- /**
- * Returns the StaticSlot assigned to the supplied name.
- *
- * @param name
- * The name of the StaticSlot to acquire.
- * @return
- * The StaticSlot associated with the supplied name.
- */
- public abstract StaticSlot staticSlot(String name);
+ /**
+ * Returns the StaticSlot assigned to the supplied name.
+ *
+ * @param name
+ * The name of the StaticSlot to acquire.
+ * @return
+ * The StaticSlot associated with the supplied name.
+ */
+ public abstract StaticSlot staticSlot(String name);
- /**
- * Returns the names used while creating Static Slots in a List
- *
- * @return
- */
- public abstract List<String> existingStaticSlotNames();
-
- /**
- * Store the supplied value in the StaticSlot of the Organizer's static state.
- *
- * @param slot
- * The StaticSlot used to store the object.
- * @param value
- * The object to store.
- */
- public abstract void put(StaticSlot slot, Object value);
+ /**
+ * Returns the names used while creating Static Slots in a List
+ *
+ * @return
+ */
+ public abstract List<String> existingStaticSlotNames();
+
+ /**
+ * Store the supplied value in the StaticSlot of the Organizer's static state.
+ *
+ * @param slot
+ * The StaticSlot used to store the object.
+ * @param value
+ * The object to store.
+ */
+ public abstract void put(StaticSlot slot, Object value);
- /**
- * Returns an Object from the Organizer's static state, or the Default if null
- *
- * @param slot
- * The StaticSlot to retrieve the data from.
- * @return
- * The Object located in the supplied StaticSlot of the Organizer's static state.
- */
- public abstract<T> T get(StaticSlot slot, T dflt);
+ /**
+ * Returns an Object from the Organizer's static state, or the Default if null
+ *
+ * @param slot
+ * The StaticSlot to retrieve the data from.
+ * @return
+ * The Object located in the supplied StaticSlot of the Organizer's static state.
+ */
+ public abstract<T> T get(StaticSlot slot, T dflt);
- /**
- * Returns an Object from the Organizer's static state
- *
- * @param slot
- * The StaticSlot to retrieve the data from.
- * @return
- * The Object located in the supplied StaticSlot of the Organizer's static state.
- */
- public abstract<T> T get(StaticSlot slot);
+ /**
+ * Returns an Object from the Organizer's static state
+ *
+ * @param slot
+ * The StaticSlot to retrieve the data from.
+ * @return
+ * The Object located in the supplied StaticSlot of the Organizer's static state.
+ */
+ public abstract<T> T get(StaticSlot slot);
-// /**
-// * Transfer (targeted) Args to Slots
-// *
-// * Transfer Strings with format "tag=value" into Static Slots
-// */
-// public abstract void transfer(String args[], String ... tagss);
+// /**
+// * Transfer (targeted) Args to Slots
+// *
+// * Transfer Strings with format "tag=value" into Static Slots
+// */
+// public abstract void transfer(String args[], String ... tagss);
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java b/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java
index 685bfb6e..b8a8e03a 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java
@@ -36,205 +36,205 @@ import java.util.Properties;
public class StoreImpl implements Store {
- /*
- * The re-adjustment factor for growing the Static State array.
- */
- private static final int growSize = 10;
-
- /*
- * The index reference for Slot assignment.
- */
- private int local;
-
- /*
- * The index reference for StaticSlot assignment.
- */
- private int stat;
-
- /*
- * The name/slot map for local (transaction specific) State.
- */
- private HashMap<String, Slot> localMap;
-
- /*
- * The name/slot map for Static State.
- */
- private HashMap<String, StaticSlot> staticMap;
-
- private Object[] staticState;
-
- public StoreImpl() {
- staticState = new Object[growSize];
- staticMap = new HashMap<>();
- localMap = new HashMap<>();
- }
-
- public StoreImpl(String tag) {
- staticState = new Object[growSize];
- staticMap = new HashMap<>();
- localMap = new HashMap<>();
- }
-
-
- public StoreImpl(String tag, String[] args) {
- staticState = new Object[growSize];
- staticMap = new HashMap<>();
- localMap = new HashMap<>();
-
- if(tag!=null) {
- String tequals = tag + '=';
- for(String arg : args) {
- if(arg.startsWith(tequals) && !arg.equals(tequals)) { // needs to have something after =
- Properties props = new Properties();
- for(String f : Split.split(File.pathSeparatorChar,arg.substring(tequals.length()))) {
- moreProps(new File(f),props);
- }
- for(Entry<Object, Object> es : props.entrySet()) {
- put(staticSlot(es.getKey().toString()),es.getValue());
- }
- }
- }
- }
-
- // Make sure properties on command line override those in Props
- propsFromArgs(tag,args);
- }
-
- public StoreImpl(String tag, Properties props) {
- staticState = new Object[growSize];
- staticMap = new HashMap<>();
- localMap = new HashMap<>();
-
- if(tag!=null) {
- String fname = props.getProperty(tag);
- if(fname!=null) {
- for(String f : Split.split(File.pathSeparatorChar,fname)) {
- if(!moreProps(new File(f),props)) {
- System.err.println("Unable to load Properties from " + f);
- }
- }
- }
- }
-
- for(Entry<Object, Object> es : props.entrySet()) {
- put(staticSlot(es.getKey().toString()),es.getValue());
- }
- }
-
- public void propsFromArgs(String tag, String[] args) {
- if(tag!=null) {
- for(String arg : args) {
- String sarg[] = Split.split('=',arg);
- if(sarg.length==2) {
- if(tag.equals(sarg[0])) {
- for(String fname : Split.split(File.pathSeparatorChar,sarg[1])) {
- moreProps(new File(fname),null /* no target */);
- }
- }
- put(staticSlot(sarg[0]),sarg[1]);
- }
- }
- }
- }
-
- private boolean moreProps(File f, Properties target) {
- if(f.exists()) {
- Properties props = new Properties();
- try {
- FileInputStream fis = new FileInputStream(f);
- try {
- props.load(fis);
- if(target!=null) {
- target.load(fis);
- }
- } finally {
- fis.close();
- }
- } catch(IOException e) {
- System.err.println(e);
- }
- for(Entry<Object, Object> es : props.entrySet()) {
- put(staticSlot(es.getKey().toString()),es.getValue());
- }
- return true;
- } else {
- return false;
- }
- }
-
- public Object[] newTransState() {
- return new Object[local];
- }
-
- /* (non-Javadoc)
- * @see com.att.env.Store#slot(java.lang.String)
- */
- public synchronized Slot slot(String name) {
- name = name == null ? "" : name.trim();
- Slot slot = localMap.get(name);
- if (slot == null) {
- slot = new Slot(local++, name);
- localMap.put(name, slot);
- }
- return slot;
- }
-
-
- /* (non-Javadoc)
- * @see com.att.env.Store#existingSlot(java.lang.String)
- */
- public Slot existingSlot(String name) {
- return localMap.get(name);
- }
-
- /* (non-Javadoc)
- * @see com.att.env.Store#existingSlotNames()
- */
- public List<String> existingSlotNames() {
- return new ArrayList<>(localMap.keySet());
- }
-
- /* (non-Javadoc)
- * @see com.att.env.Store#staticSlot(java.lang.String)
- */
- public synchronized StaticSlot staticSlot(String name) {
- name = name == null ? "" : name.trim();
- StaticSlot slot = staticMap.get(name);
- if (slot == null) {
- if (stat%growSize == 0) {
- Object[] temp = staticState;
- staticState = new Object[temp.length+growSize];
- System.arraycopy(temp, 0, staticState, 0, temp.length);
- }
- slot = new StaticSlot(stat++, name);
- staticMap.put(name, slot);
- }
- return slot;
- }
-
- /* (non-Javadoc)
- * @see com.att.env.Store#put(com.att.env.StaticSlot, java.lang.Object)
- */
- public void put(StaticSlot slot, Object value) {
- staticState[slot.slot] = value;
- }
-
- /* (non-Javadoc)
- * @see com.att.env.Store#get(com.att.env.StaticSlot T defaultObject)
- */
- @SuppressWarnings("unchecked")
- public<T> T get(StaticSlot sslot,T dflt) {
- T t = (T)staticState[sslot.slot];
- return t==null?dflt:t;
- }
-
- @SuppressWarnings("unchecked")
- public <T> T get(StaticSlot sslot) {
- return (T)staticState[sslot.slot];
- }
-
- public List<String> existingStaticSlotNames() {
- return new ArrayList<>(staticMap.keySet());
- }
+ /*
+ * The re-adjustment factor for growing the Static State array.
+ */
+ private static final int growSize = 10;
+
+ /*
+ * The index reference for Slot assignment.
+ */
+ private int local;
+
+ /*
+ * The index reference for StaticSlot assignment.
+ */
+ private int stat;
+
+ /*
+ * The name/slot map for local (transaction specific) State.
+ */
+ private HashMap<String, Slot> localMap;
+
+ /*
+ * The name/slot map for Static State.
+ */
+ private HashMap<String, StaticSlot> staticMap;
+
+ private Object[] staticState;
+
+ public StoreImpl() {
+ staticState = new Object[growSize];
+ staticMap = new HashMap<>();
+ localMap = new HashMap<>();
+ }
+
+ public StoreImpl(String tag) {
+ staticState = new Object[growSize];
+ staticMap = new HashMap<>();
+ localMap = new HashMap<>();
+ }
+
+
+ public StoreImpl(String tag, String[] args) {
+ staticState = new Object[growSize];
+ staticMap = new HashMap<>();
+ localMap = new HashMap<>();
+
+ if(tag!=null) {
+ String tequals = tag + '=';
+ for(String arg : args) {
+ if(arg.startsWith(tequals) && !arg.equals(tequals)) { // needs to have something after =
+ Properties props = new Properties();
+ for(String f : Split.split(File.pathSeparatorChar,arg.substring(tequals.length()))) {
+ moreProps(new File(f),props);
+ }
+ for(Entry<Object, Object> es : props.entrySet()) {
+ put(staticSlot(es.getKey().toString()),es.getValue());
+ }
+ }
+ }
+ }
+
+ // Make sure properties on command line override those in Props
+ propsFromArgs(tag,args);
+ }
+
+ public StoreImpl(String tag, Properties props) {
+ staticState = new Object[growSize];
+ staticMap = new HashMap<>();
+ localMap = new HashMap<>();
+
+ if(tag!=null) {
+ String fname = props.getProperty(tag);
+ if(fname!=null) {
+ for(String f : Split.split(File.pathSeparatorChar,fname)) {
+ if(!moreProps(new File(f),props)) {
+ System.err.println("Unable to load Properties from " + f);
+ }
+ }
+ }
+ }
+
+ for(Entry<Object, Object> es : props.entrySet()) {
+ put(staticSlot(es.getKey().toString()),es.getValue());
+ }
+ }
+
+ public void propsFromArgs(String tag, String[] args) {
+ if(tag!=null) {
+ for(String arg : args) {
+ String sarg[] = Split.split('=',arg);
+ if(sarg.length==2) {
+ if(tag.equals(sarg[0])) {
+ for(String fname : Split.split(File.pathSeparatorChar,sarg[1])) {
+ moreProps(new File(fname),null /* no target */);
+ }
+ }
+ put(staticSlot(sarg[0]),sarg[1]);
+ }
+ }
+ }
+ }
+
+ private boolean moreProps(File f, Properties target) {
+ if(f.exists()) {
+ Properties props = new Properties();
+ try {
+ FileInputStream fis = new FileInputStream(f);
+ try {
+ props.load(fis);
+ if(target!=null) {
+ target.load(fis);
+ }
+ } finally {
+ fis.close();
+ }
+ } catch(IOException e) {
+ System.err.println(e);
+ }
+ for(Entry<Object, Object> es : props.entrySet()) {
+ put(staticSlot(es.getKey().toString()),es.getValue());
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public Object[] newTransState() {
+ return new Object[local];
+ }
+
+ /* (non-Javadoc)
+ * @see com.att.env.Store#slot(java.lang.String)
+ */
+ public synchronized Slot slot(String name) {
+ name = name == null ? "" : name.trim();
+ Slot slot = localMap.get(name);
+ if (slot == null) {
+ slot = new Slot(local++, name);
+ localMap.put(name, slot);
+ }
+ return slot;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.att.env.Store#existingSlot(java.lang.String)
+ */
+ public Slot existingSlot(String name) {
+ return localMap.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see com.att.env.Store#existingSlotNames()
+ */
+ public List<String> existingSlotNames() {
+ return new ArrayList<>(localMap.keySet());
+ }
+
+ /* (non-Javadoc)
+ * @see com.att.env.Store#staticSlot(java.lang.String)
+ */
+ public synchronized StaticSlot staticSlot(String name) {
+ name = name == null ? "" : name.trim();
+ StaticSlot slot = staticMap.get(name);
+ if (slot == null) {
+ if (stat%growSize == 0) {
+ Object[] temp = staticState;
+ staticState = new Object[temp.length+growSize];
+ System.arraycopy(temp, 0, staticState, 0, temp.length);
+ }
+ slot = new StaticSlot(stat++, name);
+ staticMap.put(name, slot);
+ }
+ return slot;
+ }
+
+ /* (non-Javadoc)
+ * @see com.att.env.Store#put(com.att.env.StaticSlot, java.lang.Object)
+ */
+ public void put(StaticSlot slot, Object value) {
+ staticState[slot.slot] = value;
+ }
+
+ /* (non-Javadoc)
+ * @see com.att.env.Store#get(com.att.env.StaticSlot T defaultObject)
+ */
+ @SuppressWarnings("unchecked")
+ public<T> T get(StaticSlot sslot,T dflt) {
+ T t = (T)staticState[sslot.slot];
+ return t==null?dflt:t;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T get(StaticSlot sslot) {
+ return (T)staticState[sslot.slot];
+ }
+
+ public List<String> existingStaticSlotNames() {
+ return new ArrayList<>(staticMap.keySet());
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java
index c6e0dbd1..293d7c15 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java
@@ -28,18 +28,18 @@ package org.onap.aaf.misc.env;
* <i>Stringifier</i> abstracts the marshaling of a String to an Object
*/
public interface Stringifier<T> extends LifeCycle {
-
- /**
- * Marshal from a String to an Object T, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return String
- * @throws APIException
- */
- public abstract String stringify(Env env, T input, boolean ... options) throws APIException;
-
+
+ /**
+ * Marshal from a String to an Object T, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return String
+ * @throws APIException
+ */
+ public abstract String stringify(Env env, T input, boolean ... options) throws APIException;
+
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java
index 78f4a617..02018707 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java
@@ -35,82 +35,82 @@ package org.onap.aaf.misc.env;
*
*/
public abstract class TimeTaken {
- public final long start;
- protected long end, size;
- public final int flag;
- public final String name;
-
- /**
- * The name is as it will appear when written to output (abstract method)
- *
- * The flag is an integer which can be System type (XML, REMOTE, etc), or End User defined for reporting purposes
- *
- * @param name
- * @param flag
- */
- public TimeTaken(String name, int flag) {
- start = System.nanoTime();
- this.flag = flag;
- this.name = name;
- size = -1;
- }
+ public final long start;
+ protected long end, size;
+ public final int flag;
+ public final String name;
+
+ /**
+ * The name is as it will appear when written to output (abstract method)
+ *
+ * The flag is an integer which can be System type (XML, REMOTE, etc), or End User defined for reporting purposes
+ *
+ * @param name
+ * @param flag
+ */
+ public TimeTaken(String name, int flag) {
+ start = System.nanoTime();
+ this.flag = flag;
+ this.name = name;
+ size = -1;
+ }
- /**
- * Call this when process is done to state ending time.<p>
- *
- * It is <i>exceedingly prudent</i> to wrap the process called with a try-finally:<p>
- *
- * <pre>
- * TimeTaken tt = env.startSubTime();
- * try {
- * process.me(); // code to be timed.
- * } finally {
- * tt.done();
- * }
- * </pre>
- */
- public void done() {
- end = System.nanoTime();
- }
-
-
- /**
- * For sizable contents, set the size. Implementations can simply write a no-op if they don't wish to
- * store the size.
- *
- * @param size
- */
- public void size(long theSize) {
- size = theSize;
- }
-
- /**
- * Give readonly access to End, which isn't final
- * @return
- */
- public long end() {
- return end;
- }
-
- /**
- * Time is taken in NanoSeconds. This method converts to decimals of Milliseconds
- * @return
- */
- public float millis() {
- return (end-start)/1000000f;
- }
- /**
- * Write self to a String Builder (for making Audits)
- * @param sb
- */
- public abstract void output(StringBuilder sb);
-
- /**
- * For Debugging
- */
- public String toString() {
- return name + ' ' + millis() + "ms " + (size>0?Long.toString(size):"");
- }
-
-}
+ /**
+ * Call this when process is done to state ending time.<p>
+ *
+ * It is <i>exceedingly prudent</i> to wrap the process called with a try-finally:<p>
+ *
+ * <pre>
+ * TimeTaken tt = env.startSubTime();
+ * try {
+ * process.me(); // code to be timed.
+ * } finally {
+ * tt.done();
+ * }
+ * </pre>
+ */
+ public void done() {
+ end = System.nanoTime();
+ }
+
+
+ /**
+ * For sizable contents, set the size. Implementations can simply write a no-op if they don't wish to
+ * store the size.
+ *
+ * @param size
+ */
+ public void size(long theSize) {
+ size = theSize;
+ }
+
+ /**
+ * Give readonly access to End, which isn't final
+ * @return
+ */
+ public long end() {
+ return end;
+ }
+
+ /**
+ * Time is taken in NanoSeconds. This method converts to decimals of Milliseconds
+ * @return
+ */
+ public float millis() {
+ return (end-start)/1000000f;
+ }
+ /**
+ * Write self to a String Builder (for making Audits)
+ * @param sb
+ */
+ public abstract void output(StringBuilder sb);
+
+ /**
+ * For Debugging
+ */
+ public String toString() {
+ return name + ' ' + millis() + "ms " + (size>0?Long.toString(size):"");
+ }
+
+}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java
index 24473751..bb66c0f6 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java
@@ -39,36 +39,36 @@ package org.onap.aaf.misc.env;
*
*/
public interface Trans extends Env {
- /**
- * Add a completed entry in the Audit Trail for tracking purposes.
- *
- * @param text
- */
- public void checkpoint(String text);
+ /**
+ * Add a completed entry in the Audit Trail for tracking purposes.
+ *
+ * @param text
+ */
+ public void checkpoint(String text);
- /**
- * Add a completed entry in the Audit Trail for tracking purposes, and combine flag with "CHECKPOINT"
- *
- * @param text
- */
- public void checkpoint(String text, int additionalFlag);
+ /**
+ * Add a completed entry in the Audit Trail for tracking purposes, and combine flag with "CHECKPOINT"
+ *
+ * @param text
+ */
+ public void checkpoint(String text, int additionalFlag);
- /**
- * Output an Audit Trail onto the StringBuilder
- *
- * Load metrics into an array of floats from passed in Flags
- *
- * @param flag
- * @param sb
- * @return
- */
- public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int ... flag);
+ /**
+ * Output an Audit Trail onto the StringBuilder
+ *
+ * Load metrics into an array of floats from passed in Flags
+ *
+ * @param flag
+ * @param sb
+ * @return
+ */
+ public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int ... flag);
- public Metric auditTrail(int indent, StringBuilder sb, int ... flag);
+ public Metric auditTrail(int indent, StringBuilder sb, int ... flag);
- public class Metric {
- public float[] buckets;
- public float total;
- public int entries;
- }
+ public class Metric {
+ public float[] buckets;
+ public float total;
+ public int entries;
+ }
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java
index 1ed4dcd2..d311c3ed 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java
@@ -22,5 +22,5 @@
package org.onap.aaf.misc.env;
public interface TransCreate<TRANS> {
- public TRANS newTrans();
+ public TRANS newTrans();
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java
index e9c1b390..5a8f7620 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java
@@ -22,36 +22,36 @@
package org.onap.aaf.misc.env;
public interface TransStore extends Trans {
- /**
- * Returns the Slot assigned to the supplied name.
- *
- * @param name
- * The name of the Slot to acquire.
- * @return
- * The Slot associated with the supplied name.
- */
- public abstract Slot slot(String name);
-
- /**
- * Put data into the right slot
- */
- public void put(Slot slot, Object value);
+ /**
+ * Returns the Slot assigned to the supplied name.
+ *
+ * @param name
+ * The name of the Slot to acquire.
+ * @return
+ * The Slot associated with the supplied name.
+ */
+ public abstract Slot slot(String name);
+
+ /**
+ * Put data into the right slot
+ */
+ public void put(Slot slot, Object value);
- /**
- * Get data from the right slot
- *
- * This will do a cast to the expected type derived from Default
- */
- public<T> T get(Slot slot, T deflt);
+ /**
+ * Get data from the right slot
+ *
+ * This will do a cast to the expected type derived from Default
+ */
+ public<T> T get(Slot slot, T deflt);
- /**
- * Returns an Object from the Organizer's static state, or the Default if null
- *
- * @param slot
- * The StaticSlot to retrieve the data from.
- * @return
- * The Object located in the supplied StaticSlot of the Organizer's static state.
- */
- public abstract<T> T get(StaticSlot slot, T dflt);
-
+ /**
+ * Returns an Object from the Organizer's static state, or the Default if null
+ *
+ * @param slot
+ * The StaticSlot to retrieve the data from.
+ * @return
+ * The Object located in the supplied StaticSlot of the Organizer's static state.
+ */
+ public abstract<T> T get(StaticSlot slot, T dflt);
+
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java
index e378e2c3..b86b4fbb 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java
@@ -33,182 +33,182 @@ import org.onap.aaf.misc.env.TimeTaken;
import org.onap.aaf.misc.env.TransStore;
public abstract class AbsTrans<ENV extends Env> implements TransStore {
- private static final float[] EMPTYF = new float[0];
- private static final Object[] EMPTYO = new Object[0];
-
- protected ENV delegate;
- protected List<TimeTaken> trail = new ArrayList<>(30);
- private Object[] state;
-
-
+ private static final float[] EMPTYF = new float[0];
+ private static final Object[] EMPTYO = new Object[0];
+
+ protected ENV delegate;
+ protected List<TimeTaken> trail = new ArrayList<>(30);
+ private Object[] state;
+
+
public AbsTrans(ENV delegate) {
- this.delegate = delegate;
- state = delegate instanceof StoreImpl?((StoreImpl) delegate).newTransState():EMPTYO;
- }
-
- // @Override
- public LogTarget fatal() {
- return delegate.fatal();
- }
-
-// @Override
- public LogTarget error() {
- return delegate.error();
- }
-
-// @Override
- public LogTarget audit() {
- return delegate.audit();
- }
-
-// @Override
- public LogTarget init() {
- return delegate.init();
- }
-
-// @Override
- public LogTarget warn() {
- return delegate.warn();
- }
-
-// @Override
- public LogTarget info() {
- return delegate.info();
- }
-
-// @Override
- public LogTarget debug() {
- return delegate.debug();
- }
-
-// @Override
- public LogTarget trace() {
- return delegate.trace();
- }
-
- /**
- * Let the final Trans Implementation choose the exact kind of TimeTaken to use
- * @param name
- * @param flag
- * @return
- */
- protected abstract TimeTaken newTimeTaken(String name, int flag);
-
-// @Override
- public final TimeTaken start(String name, int flag) {
- TimeTaken tt = newTimeTaken(name,flag);
- trail.add(tt);
- return tt;
- }
-
-// @Override
- public final void checkpoint(String name) {
- TimeTaken tt = newTimeTaken(name,CHECKPOINT);
- tt.done();
- trail.add(tt);
- }
-
- public final void checkpoint(String name, int additionalFlag) {
- TimeTaken tt = newTimeTaken(name,CHECKPOINT|additionalFlag);
- trail.add(tt);
- tt.done();
- }
-
- @Override
- public Metric auditTrail(int indent, StringBuilder sb, int ... flags) {
- return auditTrail(info(),indent,sb,flags);
- }
-
- @Override
- public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int ... flags) {
- Metric metric = new Metric();
- int last = (metric.entries = trail.size()) -1;
- metric.buckets = flags.length==0?EMPTYF:new float[flags.length];
- if(last>=0) {
- TimeTaken first = trail.get(0);
- // If first entry is sub, then it's actually the last "end" as well
- // otherwise, check end
- //long end = (first.flag&SUB)==SUB?first.end():trail.get(last).end();
- long end = trail.get(last).end();
- metric.total = (end - first.start) / 1000000f;
- }
-
- if(sb==null) {
- for(TimeTaken tt : trail) {
- float ms = tt.millis();
- for(int i=0;i<flags.length;++i) {
- if(tt.flag == flags[i]) metric.buckets[i]+=ms;
- }
- }
- } else if(!lt.isLoggable()) {
- boolean first = true;
- for(TimeTaken tt : trail) {
- float ms = tt.millis();
- for(int i=0;i<flags.length;++i) {
- if(tt.flag == flags[i]) metric.buckets[i]+=ms;
- }
- if((tt.flag&ALWAYS)==ALWAYS) {
- if(first) first = false;
- else sb.append('/');
- sb.append(tt.name);
- }
- }
- } else {
- Stack<Long> stack = new Stack<Long>();
- for(TimeTaken tt : trail) {
- // Create Indentation based on SUB
- while(!stack.isEmpty() && tt.end()>stack.peek()) {
- --indent;
- stack.pop();
- }
- for(int i=0;i<indent;++i) {
- sb.append(" ");
- }
- tt.output(sb);
- sb.append('\n');
- if((tt.flag&SUB)==SUB) {
- stack.push(tt.end());
- ++indent;
- }
-
- // Add time values to Metric
- float ms = tt.millis();
- for(int i=0;i<flags.length;++i) {
- if(tt.flag == flags[i]) metric.buckets[i]+=ms;
- }
- }
- }
- return metric;
- }
-
- /**
- * Put data into the Trans State at the right slot
- */
-// @Override
- public void put(Slot slot, Object value) {
- slot.put(state, value);
- }
-
- /**
- * Get data from the Trans State from the right slot
- *
- * This will do a cast to the expected type derived from Default
- */
-// @Override
- @SuppressWarnings("unchecked")
- public<T> T get(Slot slot, T deflt) {
- Object o;
- try {
- o = slot.get(state);
- } catch(ArrayIndexOutOfBoundsException e) {
- // Env State Size has changed because of dynamic Object creation... Rare event, but needs to be covered
- Object[] temp = ((StoreImpl) delegate).newTransState();
- System.arraycopy(state, 0, temp, 0, state.length);
- state = temp;
- o=null;
- }
- return o==null?deflt:(T)o;
- }
+ this.delegate = delegate;
+ state = delegate instanceof StoreImpl?((StoreImpl) delegate).newTransState():EMPTYO;
+ }
+
+ // @Override
+ public LogTarget fatal() {
+ return delegate.fatal();
+ }
+
+// @Override
+ public LogTarget error() {
+ return delegate.error();
+ }
+
+// @Override
+ public LogTarget audit() {
+ return delegate.audit();
+ }
+
+// @Override
+ public LogTarget init() {
+ return delegate.init();
+ }
+
+// @Override
+ public LogTarget warn() {
+ return delegate.warn();
+ }
+
+// @Override
+ public LogTarget info() {
+ return delegate.info();
+ }
+
+// @Override
+ public LogTarget debug() {
+ return delegate.debug();
+ }
+
+// @Override
+ public LogTarget trace() {
+ return delegate.trace();
+ }
+
+ /**
+ * Let the final Trans Implementation choose the exact kind of TimeTaken to use
+ * @param name
+ * @param flag
+ * @return
+ */
+ protected abstract TimeTaken newTimeTaken(String name, int flag);
+
+// @Override
+ public final TimeTaken start(String name, int flag) {
+ TimeTaken tt = newTimeTaken(name,flag);
+ trail.add(tt);
+ return tt;
+ }
+
+// @Override
+ public final void checkpoint(String name) {
+ TimeTaken tt = newTimeTaken(name,CHECKPOINT);
+ tt.done();
+ trail.add(tt);
+ }
+
+ public final void checkpoint(String name, int additionalFlag) {
+ TimeTaken tt = newTimeTaken(name,CHECKPOINT|additionalFlag);
+ trail.add(tt);
+ tt.done();
+ }
+
+ @Override
+ public Metric auditTrail(int indent, StringBuilder sb, int ... flags) {
+ return auditTrail(info(),indent,sb,flags);
+ }
+
+ @Override
+ public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int ... flags) {
+ Metric metric = new Metric();
+ int last = (metric.entries = trail.size()) -1;
+ metric.buckets = flags.length==0?EMPTYF:new float[flags.length];
+ if(last>=0) {
+ TimeTaken first = trail.get(0);
+ // If first entry is sub, then it's actually the last "end" as well
+ // otherwise, check end
+ //long end = (first.flag&SUB)==SUB?first.end():trail.get(last).end();
+ long end = trail.get(last).end();
+ metric.total = (end - first.start) / 1000000f;
+ }
+
+ if(sb==null) {
+ for(TimeTaken tt : trail) {
+ float ms = tt.millis();
+ for(int i=0;i<flags.length;++i) {
+ if(tt.flag == flags[i]) metric.buckets[i]+=ms;
+ }
+ }
+ } else if(!lt.isLoggable()) {
+ boolean first = true;
+ for(TimeTaken tt : trail) {
+ float ms = tt.millis();
+ for(int i=0;i<flags.length;++i) {
+ if(tt.flag == flags[i]) metric.buckets[i]+=ms;
+ }
+ if((tt.flag&ALWAYS)==ALWAYS) {
+ if(first) first = false;
+ else sb.append('/');
+ sb.append(tt.name);
+ }
+ }
+ } else {
+ Stack<Long> stack = new Stack<Long>();
+ for(TimeTaken tt : trail) {
+ // Create Indentation based on SUB
+ while(!stack.isEmpty() && tt.end()>stack.peek()) {
+ --indent;
+ stack.pop();
+ }
+ for(int i=0;i<indent;++i) {
+ sb.append(" ");
+ }
+ tt.output(sb);
+ sb.append('\n');
+ if((tt.flag&SUB)==SUB) {
+ stack.push(tt.end());
+ ++indent;
+ }
+
+ // Add time values to Metric
+ float ms = tt.millis();
+ for(int i=0;i<flags.length;++i) {
+ if(tt.flag == flags[i]) metric.buckets[i]+=ms;
+ }
+ }
+ }
+ return metric;
+ }
+
+ /**
+ * Put data into the Trans State at the right slot
+ */
+// @Override
+ public void put(Slot slot, Object value) {
+ slot.put(state, value);
+ }
+
+ /**
+ * Get data from the Trans State from the right slot
+ *
+ * This will do a cast to the expected type derived from Default
+ */
+// @Override
+ @SuppressWarnings("unchecked")
+ public<T> T get(Slot slot, T deflt) {
+ Object o;
+ try {
+ o = slot.get(state);
+ } catch(ArrayIndexOutOfBoundsException e) {
+ // Env State Size has changed because of dynamic Object creation... Rare event, but needs to be covered
+ Object[] temp = ((StoreImpl) delegate).newTransState();
+ System.arraycopy(state, 0, temp, 0, state.length);
+ state = temp;
+ o=null;
+ }
+ return o==null?deflt:(T)o;
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java
index c20589a3..5576a1a0 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java
@@ -30,28 +30,28 @@ import org.onap.aaf.misc.env.EnvJAXB;
import org.onap.aaf.misc.env.TransJAXB;
public abstract class AbsTransJAXB extends AbsTrans<EnvJAXB> implements TransJAXB {
- public AbsTransJAXB(EnvJAXB env) {
- super(env);
- }
-
-// @Override
- public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException {
- return delegate.newDataFactory(classes);
- }
-
-// @Override
- public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException {
- return delegate.newDataFactory(schema, classes);
- }
-
-// @Override
- public <T> DataFactory<T> newDataFactory(QName qName, Class<?>... classes) throws APIException {
- return delegate.newDataFactory(qName, classes);
- }
-
-// @Override
- public <T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?>... classes) throws APIException {
- return delegate.newDataFactory(schema, qName, classes);
- }
+ public AbsTransJAXB(EnvJAXB env) {
+ super(env);
+ }
+
+// @Override
+ public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException {
+ return delegate.newDataFactory(classes);
+ }
+
+// @Override
+ public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException {
+ return delegate.newDataFactory(schema, classes);
+ }
+
+// @Override
+ public <T> DataFactory<T> newDataFactory(QName qName, Class<?>... classes) throws APIException {
+ return delegate.newDataFactory(qName, classes);
+ }
+
+// @Override
+ public <T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?>... classes) throws APIException {
+ return delegate.newDataFactory(schema, qName, classes);
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java
index cd62a7e5..94f7d47b 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java
@@ -57,296 +57,296 @@ import org.onap.aaf.misc.env.util.Split;
*
*/
public class BasicEnv extends StoreImpl implements EnvJAXB, TransCreate<TransJAXB>{
- protected LogTarget fatal=LogTarget.SYSERR;
- protected LogTarget error=LogTarget.SYSERR;
- protected LogTarget audit=LogTarget.SYSOUT;
- protected LogTarget init=LogTarget.SYSOUT;
- protected LogTarget warn=LogTarget.SYSERR;
- protected LogTarget info=LogTarget.SYSOUT;
- protected LogTarget debug=LogTarget.NULL;
- protected LogTarget trace=LogTarget.NULL;
-// protected Map<String, String> props;
-
-// private boolean sysprops;
-
- public BasicEnv(String ... args) {
- super(null,args);
- }
-
- public BasicEnv(String tag, String[] args) {
- super(tag, args);
- }
-
-
- /**
- * Suitable for use in Applets... obtain all the values
- * listed for the variable String arg "tags"
- */
- public BasicEnv(Applet applet, String ... tags) {
- super(null, tags);
-// props = new HashMap<>();
-// String value;
-// for(int i=0;i<tags.length;++i) {
-// value = applet.getParameter(tags[i]);
-// if(value!=null) {
-// props.put(tags[i], value);
-// }
-// }
- }
-
- public BasicEnv(Properties props) {
- super(null, props);
- }
-
- public BasicEnv(String tag, Properties props) {
- super(tag, props);
- }
-
-
-
- // @Override
- public LogTarget fatal() {
- return fatal;
- }
-
- // @Override
- public LogTarget error() {
- return error;
- }
-
-
- // @Override
- public LogTarget audit() {
- return audit;
- }
-
- // @Override
- public LogTarget init() {
- return init;
- }
-
- // @Override
- public LogTarget warn() {
- return warn;
- }
-
- // @Override
- public LogTarget info() {
- return info;
- }
-
- // @Override
- public LogTarget debug() {
- return debug;
- }
-
- public void debug(LogTarget lt) {
- debug = lt;
- }
-
- // @Override
- public LogTarget trace() {
- return trace;
- }
-
- // @Override
- public TimeTaken start(String name, int flag) {
- return new TimeTaken(name, flag) {
- /**
- * Format to be printed when called upon
- */
- // @Override
- public void output(StringBuilder sb) {
-
- switch(flag) {
- case Env.XML: sb.append("XML "); break;
- case Env.JSON: sb.append("JSON "); break;
- case Env.REMOTE: sb.append("REMOTE "); break;
- }
- sb.append(name);
- if(flag != Env.CHECKPOINT) {
- sb.append(' ');
- sb.append((end-start)/1000000f);
- sb.append("ms");
- if(size>=0) {
- sb.append(" size: ");
- sb.append(Long.toString(size));
- }
- }
- }
- };
- }
-
- // @Override
- public String getProperty(String key) {
- return get(staticSlot(key),null);
- }
-
- public Properties getProperties(String ... filter) {
- Properties props = new Properties();
- boolean yes;
- for(String key : existingStaticSlotNames()) {
- if(filter.length>0) {
- yes = false;
- for(String f : filter) {
- if(key.startsWith(f)) {
- yes = true;
- break;
- }
- }
- } else {
- yes = true;
- }
- if(yes) {
- String value = getProperty(key);
- if(value!=null) {
- props.put(key, value);
- }
- }
- }
- return props;
- }
-
- // @Override
- public String getProperty(String key, String defaultValue) {
- return get(staticSlot(key),defaultValue);
- }
-
- // @Override
- public String setProperty(String key, String value) {
- put(staticSlot(key),value==null?null:value.trim());
- return value;
- }
-
- protected Decryptor decryptor = Decryptor.NULL;
- protected Encryptor encryptor = Encryptor.NULL;
-
-
- public Decryptor decryptor() {
- return decryptor;
- }
-
- public void set(Decryptor newDecryptor) {
- decryptor = newDecryptor;
- }
-
- public Encryptor encryptor() {
- return encryptor;
- }
-
- public void set(Encryptor newEncryptor) {
- encryptor = newEncryptor;
- }
-
-
-// @SuppressWarnings("unchecked")
- // @Override
- public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException {
-// if(String.class.isAssignableFrom(classes[0]))
-// return (DataFactory<T>) new StringDF(this);
- return new JAXBDF<T>(this,classes);
- }
-
-// @SuppressWarnings("unchecked")
- // @Override
- public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException {
-// if(String.class.isAssignableFrom(classes[0]))
-// return (DataFactory<T>) new StringDF(this);
- return new JAXBDF<T>(this, schema, classes);
- }
-
-// @SuppressWarnings("unchecked")
- // @Override
- public<T> DataFactory<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException {
-// if(String.class.isAssignableFrom(classes[0]))
-// return (DataFactory<T>) new StringDF(this);
- return new JAXBDF<T>(this, qName, classes);
- }
-
- // @Override
- public<T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException {
- return new JAXBDF<T>(this, schema, qName, classes);
- }
-
- // @Override
- public BasicTrans newTrans() {
- return new BasicTrans(this);
- }
-
- public void loadFromSystemPropsStartsWith(String ... str) {
- for(String name : System.getProperties().stringPropertyNames()) {
- for(String s : str) {
- if(name.startsWith(s)) {
- setProperty(name, System.getProperty(name));
- }
- }
- }
- }
-
- /**
- *
- *
- */
- public void loadToSystemPropsStartsWith(String ... str) {
- String value;
- for(String name : existingStaticSlotNames()) {
- for(String s : str) {
- if(name.startsWith(s)) {
- if((value = getProperty(name))!=null)
- System.setProperty(name,value);
- }
- }
- }
- }
-
- public void loadPropFiles(String tag, ClassLoader classloader) throws IOException {
- String propfiles = getProperty(tag);
- if(propfiles!=null) {
- for(String pf : Split.splitTrim(File.pathSeparatorChar, propfiles)) {
- InputStream is = classloader==null?null:classloader.getResourceAsStream(pf);
- if(is==null) {
- File f = new File(pf);
- if(f.exists()) {
- is = new FileInputStream(f);
- }
- }
- if(is!=null) {
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- try {
- String line;
- while((line=br.readLine())!=null) {
- line = line.trim();
- if(!line.startsWith("#")) {
- String[] tv = Split.splitTrim('=', line);
- if(tv.length==2) {
- setProperty(tv[0],tv[1]);
- }
- }
- }
- } finally {
- try {
- br.close();
- } catch (IOException e) {
- error().log(e);
- }
- }
- }
- }
- }
- }
-
- /**
- * Create a StaticSlot, and load it from existing Properties
- *
- * @param name
- * @param propName
- * @return
- */
- public synchronized StaticSlot staticSlot(String name, final String propName) {
- StaticSlot ss = staticSlot(name);
- put(ss,getProperty(propName));
- return ss;
- }
+ protected LogTarget fatal=LogTarget.SYSERR;
+ protected LogTarget error=LogTarget.SYSERR;
+ protected LogTarget audit=LogTarget.SYSOUT;
+ protected LogTarget init=LogTarget.SYSOUT;
+ protected LogTarget warn=LogTarget.SYSERR;
+ protected LogTarget info=LogTarget.SYSOUT;
+ protected LogTarget debug=LogTarget.NULL;
+ protected LogTarget trace=LogTarget.NULL;
+// protected Map<String, String> props;
+
+// private boolean sysprops;
+
+ public BasicEnv(String ... args) {
+ super(null,args);
+ }
+
+ public BasicEnv(String tag, String[] args) {
+ super(tag, args);
+ }
+
+
+ /**
+ * Suitable for use in Applets... obtain all the values
+ * listed for the variable String arg "tags"
+ */
+ public BasicEnv(Applet applet, String ... tags) {
+ super(null, tags);
+// props = new HashMap<>();
+// String value;
+// for(int i=0;i<tags.length;++i) {
+// value = applet.getParameter(tags[i]);
+// if(value!=null) {
+// props.put(tags[i], value);
+// }
+// }
+ }
+
+ public BasicEnv(Properties props) {
+ super(null, props);
+ }
+
+ public BasicEnv(String tag, Properties props) {
+ super(tag, props);
+ }
+
+
+
+ // @Override
+ public LogTarget fatal() {
+ return fatal;
+ }
+
+ // @Override
+ public LogTarget error() {
+ return error;
+ }
+
+
+ // @Override
+ public LogTarget audit() {
+ return audit;
+ }
+
+ // @Override
+ public LogTarget init() {
+ return init;
+ }
+
+ // @Override
+ public LogTarget warn() {
+ return warn;
+ }
+
+ // @Override
+ public LogTarget info() {
+ return info;
+ }
+
+ // @Override
+ public LogTarget debug() {
+ return debug;
+ }
+
+ public void debug(LogTarget lt) {
+ debug = lt;
+ }
+
+ // @Override
+ public LogTarget trace() {
+ return trace;
+ }
+
+ // @Override
+ public TimeTaken start(String name, int flag) {
+ return new TimeTaken(name, flag) {
+ /**
+ * Format to be printed when called upon
+ */
+ // @Override
+ public void output(StringBuilder sb) {
+
+ switch(flag) {
+ case Env.XML: sb.append("XML "); break;
+ case Env.JSON: sb.append("JSON "); break;
+ case Env.REMOTE: sb.append("REMOTE "); break;
+ }
+ sb.append(name);
+ if(flag != Env.CHECKPOINT) {
+ sb.append(' ');
+ sb.append((end-start)/1000000f);
+ sb.append("ms");
+ if(size>=0) {
+ sb.append(" size: ");
+ sb.append(Long.toString(size));
+ }
+ }
+ }
+ };
+ }
+
+ // @Override
+ public String getProperty(String key) {
+ return get(staticSlot(key),null);
+ }
+
+ public Properties getProperties(String ... filter) {
+ Properties props = new Properties();
+ boolean yes;
+ for(String key : existingStaticSlotNames()) {
+ if(filter.length>0) {
+ yes = false;
+ for(String f : filter) {
+ if(key.startsWith(f)) {
+ yes = true;
+ break;
+ }
+ }
+ } else {
+ yes = true;
+ }
+ if(yes) {
+ String value = getProperty(key);
+ if(value!=null) {
+ props.put(key, value);
+ }
+ }
+ }
+ return props;
+ }
+
+ // @Override
+ public String getProperty(String key, String defaultValue) {
+ return get(staticSlot(key),defaultValue);
+ }
+
+ // @Override
+ public String setProperty(String key, String value) {
+ put(staticSlot(key),value==null?null:value.trim());
+ return value;
+ }
+
+ protected Decryptor decryptor = Decryptor.NULL;
+ protected Encryptor encryptor = Encryptor.NULL;
+
+
+ public Decryptor decryptor() {
+ return decryptor;
+ }
+
+ public void set(Decryptor newDecryptor) {
+ decryptor = newDecryptor;
+ }
+
+ public Encryptor encryptor() {
+ return encryptor;
+ }
+
+ public void set(Encryptor newEncryptor) {
+ encryptor = newEncryptor;
+ }
+
+
+// @SuppressWarnings("unchecked")
+ // @Override
+ public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException {
+// if(String.class.isAssignableFrom(classes[0]))
+// return (DataFactory<T>) new StringDF(this);
+ return new JAXBDF<T>(this,classes);
+ }
+
+// @SuppressWarnings("unchecked")
+ // @Override
+ public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException {
+// if(String.class.isAssignableFrom(classes[0]))
+// return (DataFactory<T>) new StringDF(this);
+ return new JAXBDF<T>(this, schema, classes);
+ }
+
+// @SuppressWarnings("unchecked")
+ // @Override
+ public<T> DataFactory<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException {
+// if(String.class.isAssignableFrom(classes[0]))
+// return (DataFactory<T>) new StringDF(this);
+ return new JAXBDF<T>(this, qName, classes);
+ }
+
+ // @Override
+ public<T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException {
+ return new JAXBDF<T>(this, schema, qName, classes);
+ }
+
+ // @Override
+ public BasicTrans newTrans() {
+ return new BasicTrans(this);
+ }
+
+ public void loadFromSystemPropsStartsWith(String ... str) {
+ for(String name : System.getProperties().stringPropertyNames()) {
+ for(String s : str) {
+ if(name.startsWith(s)) {
+ setProperty(name, System.getProperty(name));
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ public void loadToSystemPropsStartsWith(String ... str) {
+ String value;
+ for(String name : existingStaticSlotNames()) {
+ for(String s : str) {
+ if(name.startsWith(s)) {
+ if((value = getProperty(name))!=null)
+ System.setProperty(name,value);
+ }
+ }
+ }
+ }
+
+ public void loadPropFiles(String tag, ClassLoader classloader) throws IOException {
+ String propfiles = getProperty(tag);
+ if(propfiles!=null) {
+ for(String pf : Split.splitTrim(File.pathSeparatorChar, propfiles)) {
+ InputStream is = classloader==null?null:classloader.getResourceAsStream(pf);
+ if(is==null) {
+ File f = new File(pf);
+ if(f.exists()) {
+ is = new FileInputStream(f);
+ }
+ }
+ if(is!=null) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ try {
+ String line;
+ while((line=br.readLine())!=null) {
+ line = line.trim();
+ if(!line.startsWith("#")) {
+ String[] tv = Split.splitTrim('=', line);
+ if(tv.length==2) {
+ setProperty(tv[0],tv[1]);
+ }
+ }
+ }
+ } finally {
+ try {
+ br.close();
+ } catch (IOException e) {
+ error().log(e);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a StaticSlot, and load it from existing Properties
+ *
+ * @param name
+ * @param propName
+ * @return
+ */
+ public synchronized StaticSlot staticSlot(String name, final String propName) {
+ StaticSlot ss = staticSlot(name);
+ put(ss,getProperty(propName));
+ return ss;
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java
index 05e62024..dbda57b5 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java
@@ -30,52 +30,52 @@ import org.onap.aaf.misc.env.TimeTaken;
public class BasicTrans extends AbsTransJAXB {
-
- public BasicTrans(EnvJAXB env) {
- super(env);
- }
+
+ public BasicTrans(EnvJAXB env) {
+ super(env);
+ }
- @Override
- protected TimeTaken newTimeTaken(String name, int flag) {
- /**
- * Note: could have created a different format for Time Taken, but using BasicEnv's instead
- */
- return delegate.start(name, flag);
- }
-
- public Slot slot(String name) {
- return delegate.slot(name);
- }
+ @Override
+ protected TimeTaken newTimeTaken(String name, int flag) {
+ /**
+ * Note: could have created a different format for Time Taken, but using BasicEnv's instead
+ */
+ return delegate.start(name, flag);
+ }
+
+ public Slot slot(String name) {
+ return delegate.slot(name);
+ }
- public <T> T get(StaticSlot slot) {
- return delegate.get(slot);
- }
+ public <T> T get(StaticSlot slot) {
+ return delegate.get(slot);
+ }
- public <T> T get(StaticSlot slot, T dflt) {
- return delegate.get(slot,dflt);
- }
+ public <T> T get(StaticSlot slot, T dflt) {
+ return delegate.get(slot,dflt);
+ }
- public String setProperty(String tag, String value) {
- delegate.setProperty(tag, value);
- return value;
- }
+ public String setProperty(String tag, String value) {
+ delegate.setProperty(tag, value);
+ return value;
+ }
- public String getProperty(String tag) {
- return delegate.getProperty(tag);
- }
+ public String getProperty(String tag) {
+ return delegate.getProperty(tag);
+ }
- public String getProperty(String tag, String deflt) {
- return delegate.getProperty(tag, deflt);
- }
+ public String getProperty(String tag, String deflt) {
+ return delegate.getProperty(tag, deflt);
+ }
- @Override
- public Decryptor decryptor() {
- return delegate.decryptor();
- }
+ @Override
+ public Decryptor decryptor() {
+ return delegate.decryptor();
+ }
- @Override
- public Encryptor encryptor() {
- return delegate.encryptor();
- }
+ @Override
+ public Encryptor encryptor() {
+ return delegate.encryptor();
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java
index 9bf4fdc5..aa0b947a 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java
@@ -33,36 +33,36 @@ import org.onap.aaf.misc.env.TransJAXB;
*/
public class EnvFactory {
- public static final String SCHEMA_DIR = "env-schema_dir";
- public static final String DEFAULT_SCHEMA_DIR = "src/main/xsd";
- static BasicEnv singleton;
+ public static final String SCHEMA_DIR = "env-schema_dir";
+ public static final String DEFAULT_SCHEMA_DIR = "src/main/xsd";
+ static BasicEnv singleton;
- static {
- singleton = new BasicEnv();
- }
- public static BasicEnv singleton() {
- return singleton;
- }
-
- public static void setSingleton(BasicEnv be) {
- singleton = be;
- }
-
- public static TransJAXB newTrans() {
- return new BasicTrans(singleton);
- }
+ static {
+ singleton = new BasicEnv();
+ }
+ public static BasicEnv singleton() {
+ return singleton;
+ }
+
+ public static void setSingleton(BasicEnv be) {
+ singleton = be;
+ }
+
+ public static TransJAXB newTrans() {
+ return new BasicTrans(singleton);
+ }
- public static TransJAXB newTrans(EnvJAXB env) {
- return new BasicTrans(env);
- }
-
- public static TransCreate<TransJAXB> transCreator() {
- return new TransCreate<TransJAXB>() {
- // @Override
- public BasicTrans newTrans() {
- return singleton.newTrans();
- }
- };
- }
+ public static TransJAXB newTrans(EnvJAXB env) {
+ return new BasicTrans(env);
+ }
+
+ public static TransCreate<TransJAXB> transCreator() {
+ return new TransCreate<TransJAXB>() {
+ // @Override
+ public BasicTrans newTrans() {
+ return singleton.newTrans();
+ }
+ };
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java
index ac3e8b45..c8adfc78 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java
@@ -36,55 +36,55 @@ import org.onap.aaf.misc.env.LogTarget;
*
*/
public class JavaUtilLogTarget implements LogTarget {
- private Level level;
- private Logger log;
+ private Level level;
+ private Logger log;
- public JavaUtilLogTarget(Logger logger, Level theLevel) {
- log = logger;
- level = theLevel;
- }
+ public JavaUtilLogTarget(Logger logger, Level theLevel) {
+ log = logger;
+ level = theLevel;
+ }
- public boolean isLoggable() {
- return log.isLoggable(level);
- }
+ public boolean isLoggable() {
+ return log.isLoggable(level);
+ }
- public void log(Object ... msgs) {
- if(log.isLoggable(level)) {
- StringBuilder sb = new StringBuilder();
- String msg;
- for(int i=0;i<msgs.length;++i) {
- msg = msgs[i].toString();
- if(msg!=null && msg.length()>0) {
- int sbl = sb.length();
- if(sbl>0) {
- char last = sb.charAt(sbl-1);
- if(" (.".indexOf(last)<0 && "().".indexOf(msg.charAt(0))<0)sb.append(' ');
- }
- sb.append(msg);
- }
- }
- log.log(level, sb.toString());
- }
- }
+ public void log(Object ... msgs) {
+ if(log.isLoggable(level)) {
+ StringBuilder sb = new StringBuilder();
+ String msg;
+ for(int i=0;i<msgs.length;++i) {
+ msg = msgs[i].toString();
+ if(msg!=null && msg.length()>0) {
+ int sbl = sb.length();
+ if(sbl>0) {
+ char last = sb.charAt(sbl-1);
+ if(" (.".indexOf(last)<0 && "().".indexOf(msg.charAt(0))<0)sb.append(' ');
+ }
+ sb.append(msg);
+ }
+ }
+ log.log(level, sb.toString());
+ }
+ }
- public void log(Throwable e, Object ... msgs) {
- String str = e.getLocalizedMessage();
- if(str==null) {
- str = e.getMessage();
- }
- if(str==null) {
- str = e.getClass().getName();
- }
- log.log(level,str,msgs);
- }
+ public void log(Throwable e, Object ... msgs) {
+ String str = e.getLocalizedMessage();
+ if(str==null) {
+ str = e.getMessage();
+ }
+ if(str==null) {
+ str = e.getClass().getName();
+ }
+ log.log(level,str,msgs);
+ }
- /* (non-Javadoc)
- * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[])
- */
- @Override
- public void printf(String fmt, Object ... vars) {
- if(log.isLoggable(level)) {
- log.log(level,String.format(fmt,vars));
- }
- }
-}
+ /* (non-Javadoc)
+ * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[])
+ */
+ @Override
+ public void printf(String fmt, Object ... vars) {
+ if(log.isLoggable(level)) {
+ log.log(level,String.format(fmt,vars));
+ }
+ }
+}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java
index a5f118c9..81d9c1b2 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java
@@ -37,73 +37,73 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter;
*
*/
public class Log4JLogTarget implements LogTarget {
- private Level level;
- private Logger log;
+ private Level level;
+ private Logger log;
- public Log4JLogTarget(String loggerName, Level level) throws APIException {
- this.level = level;
- if (loggerName != null && loggerName.length() > 0) {
- log = Logger.getLogger(loggerName);
- } else {
- log = Logger.getRootLogger();
- }
- }
+ public Log4JLogTarget(String loggerName, Level level) throws APIException {
+ this.level = level;
+ if (loggerName != null && loggerName.length() > 0) {
+ log = Logger.getLogger(loggerName);
+ } else {
+ log = Logger.getRootLogger();
+ }
+ }
- // @Override
- public boolean isLoggable() {
- return log.isEnabledFor(level);
- }
+ // @Override
+ public boolean isLoggable() {
+ return log.isEnabledFor(level);
+ }
- // @Override
- public void log(Object... msgs) {
- log(null, msgs);
- }
+ // @Override
+ public void log(Object... msgs) {
+ log(null, msgs);
+ }
- // @Override
- public void log(Throwable e, Object... msgs) {
- if (log.isEnabledFor(level)) {
- StringBuilder sb = new StringBuilder();
-
- String msg;
- if (e != null) {
- e.printStackTrace(new PrintWriter(new StringBuilderWriter(sb)));
- }
- for (int i = 0; i < msgs.length; ++i) {
- if(msgs[i]!=null) {
- msg = msgs[i].toString();
- if (msg != null && msg.length() > 0) {
- int sbl = sb.length();
- if (sbl > 0) {
- char last = sb.charAt(sbl - 1);
- if (" (.".indexOf(last) < 0
- && "().".indexOf(msg.charAt(0)) < 0)
- sb.append(' ');
- }
- sb.append(msg);
- }
- }
- }
- log.log(level, sb.toString());
- }
- }
+ // @Override
+ public void log(Throwable e, Object... msgs) {
+ if (log.isEnabledFor(level)) {
+ StringBuilder sb = new StringBuilder();
+
+ String msg;
+ if (e != null) {
+ e.printStackTrace(new PrintWriter(new StringBuilderWriter(sb)));
+ }
+ for (int i = 0; i < msgs.length; ++i) {
+ if(msgs[i]!=null) {
+ msg = msgs[i].toString();
+ if (msg != null && msg.length() > 0) {
+ int sbl = sb.length();
+ if (sbl > 0) {
+ char last = sb.charAt(sbl - 1);
+ if (" (.".indexOf(last) < 0
+ && "().".indexOf(msg.charAt(0)) < 0)
+ sb.append(' ');
+ }
+ sb.append(msg);
+ }
+ }
+ }
+ log.log(level, sb.toString());
+ }
+ }
- /* (non-Javadoc)
- * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[])
- */
- @Override
- public void printf(String fmt, Object ... vars) {
- if(log.isEnabledFor(level)) {
- log.log(level,String.format(fmt,vars));
- }
- }
+ /* (non-Javadoc)
+ * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[])
+ */
+ @Override
+ public void printf(String fmt, Object ... vars) {
+ if(log.isEnabledFor(level)) {
+ log.log(level,String.format(fmt,vars));
+ }
+ }
- public static void setLog4JEnv(String loggerName, BasicEnv env) throws APIException {
- env.fatal = new Log4JLogTarget(loggerName,Level.FATAL);
- env.error = new Log4JLogTarget(loggerName,Level.ERROR);
- env.warn = env.audit = env.init = new Log4JLogTarget(loggerName,Level.WARN);
- env.info = new Log4JLogTarget(loggerName,Level.INFO);
- env.debug = new Log4JLogTarget(loggerName,Level.DEBUG);
- env.trace = new Log4JLogTarget(loggerName,Level.TRACE);
- }
-
+ public static void setLog4JEnv(String loggerName, BasicEnv env) throws APIException {
+ env.fatal = new Log4JLogTarget(loggerName,Level.FATAL);
+ env.error = new Log4JLogTarget(loggerName,Level.ERROR);
+ env.warn = env.audit = env.init = new Log4JLogTarget(loggerName,Level.WARN);
+ env.info = new Log4JLogTarget(loggerName,Level.INFO);
+ env.debug = new Log4JLogTarget(loggerName,Level.DEBUG);
+ env.trace = new Log4JLogTarget(loggerName,Level.TRACE);
+ }
+
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java
index 7e41f5df..3184f8c0 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java
@@ -51,9 +51,9 @@ import org.onap.aaf.misc.env.LifeCycle;
*
*/
public class NullLifeCycle implements LifeCycle {
- public void servicePrestart(Env env) throws APIException {}
- public void threadPrestart(Env env) throws APIException {}
- public void refresh(Env env) throws APIException {}
- public void threadDestroy(Env env) throws APIException {}
- public void serviceDestroy(Env env) throws APIException {}
+ public void servicePrestart(Env env) throws APIException {}
+ public void threadPrestart(Env env) throws APIException {}
+ public void refresh(Env env) throws APIException {}
+ public void threadDestroy(Env env) throws APIException {}
+ public void serviceDestroy(Env env) throws APIException {}
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java
index e32532bc..dc7ee192 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java
@@ -42,268 +42,268 @@ import org.onap.aaf.misc.env.old.IOStringifier;
import org.onap.aaf.misc.env.old.OldDataFactory;
public class JAXBDF<T> extends BaseDataFactory implements OldDataFactory<T>,IOObjectifier<T>, IOStringifier<T> {
- // Package on purpose
- EnvJAXB primaryEnv;
- JAXBumar jumar;
- JAXBmar jmar;
-
- public JAXBDF(EnvJAXB env, Class<?> ... classes) throws APIException {
- try {
- primaryEnv = env;
- jumar = new JAXBumar(classes);
- jmar = new JAXBmar(classes) ;
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBDF(EnvJAXB env, Schema schema, Class<?> ... classes) throws APIException {
- try {
- primaryEnv = env;
- jumar = new JAXBumar(schema, classes);
- jmar = new JAXBmar(classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBDF(EnvJAXB env, QName qname, Class<?> ... classes) throws APIException {
- try {
- primaryEnv = env;
- jumar = new JAXBumar(classes);
- jmar = new JAXBmar(qname, classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBDF(EnvJAXB env, Schema schema, QName qname, Class<?> ... classes) throws APIException {
- try {
- primaryEnv = env;
- jumar = new JAXBumar(schema, classes);
- jmar = new JAXBmar(qname, classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public T newInstance() throws APIException {
- try {
- return jumar.newInstance();
- } catch (Exception e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public IOStringifier<T> pretty(boolean pretty) {
- jmar.pretty(pretty);
- return this;
- }
-
- // @Override
- public IOStringifier<T> asFragment(boolean fragment) {
- jmar.asFragment(fragment);
- return this;
- }
-
- // @Override
- public void servicePrestart(Env env) throws APIException {
- }
-
- // @Override
- public void threadPrestart(Env env) throws APIException {
- }
-
- // @Override
- public void refresh(Env env) throws APIException {
- }
-
- // @Override
- public void threadDestroy(Env env) throws APIException {
- }
-
- // @Override
- public void serviceDestroy(Env env) throws APIException {
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public Data<T> newData() {
- return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),"",(Class<T>)jmar.getMarshalClass());
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public Data<T> newData(Env env) {
- return new JAXBData<T>(env, this,new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),"",(Class<T>)jmar.getMarshalClass());
- }
-
- // @Override
- public Data<T> newData(T type) {
- return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar), type);
- }
-
- // @Override
- public Data<T> newDataFromStream(Env env, InputStream input) throws APIException {
- //TODO Write an unvalidated String using STAX checking for end of Doc?
- // perhaps key evaluation as well.
- try {
- T t = jumar.unmarshal(env.debug(), input);
- return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),t);
- } catch(JAXBException e) {
- throw new APIException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public Data<T> newDataFromString(String string) {
- return new JAXBData<T>(primaryEnv, this,new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar), string,(Class<T>)jmar.getMarshalClass());
- }
-
- /////////// Old DataFactory Interface
- // @Override
- public String stringify(T type) throws APIException {
- try {
- StringWriter sw = new StringWriter();
- jmar.marshal(primaryEnv.debug(), type, sw);
- return sw.toString();
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public void stringify(T type, Writer writer) throws APIException {
- try {
- jmar.marshal(primaryEnv.debug(), type, writer);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public void stringify(T type, OutputStream os) throws APIException {
- try {
- jmar.marshal(primaryEnv.debug(), type, os);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- /////////// New DataFactory Interface
- // @Override
- public String stringify(Env env, T input, boolean ... options) throws APIException {
- try {
- StringWriter sw = new StringWriter();
- TimeTaken tt = env.start("JAXB Stringify", Env.XML);
- try {
- jmar.marshal(env.debug(), input, sw, options);
- } finally {
- tt.done();
- }
- String str = sw.toString();
- tt.size(str.getBytes().length);
- return str;
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException {
- TimeTaken tt = env.start("JAXB Stringify", Env.XML);
- try {
- jmar.marshal(env.debug(), input, writer, options);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException {
- TimeTaken tt = env.start("JAXB Stringify", Env.XML);
- try {
- jmar.marshal(env.debug(), input, os, options);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public T objectify(Env env, Reader rdr) throws APIException {
- TimeTaken tt = env.start("JAXB Objectify", Env.XML);
- try {
- return jumar.unmarshal(env.debug(), rdr);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public T objectify(Reader rdr) throws APIException {
- try {
- return jumar.unmarshal(primaryEnv.debug(), rdr);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public T objectify(Env env, InputStream is) throws APIException {
- TimeTaken tt = env.start("JAXB Objectify", Env.XML);
- try {
- return jumar.unmarshal(env.debug(), is);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public T objectify(InputStream is) throws APIException {
- try {
- return jumar.unmarshal(primaryEnv.debug(), is);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // @Override
- public T objectify(Env env, String input) throws APIException {
- TimeTaken tt = env.start("JAXB Objectify", Env.XML);
- tt.size(input.getBytes().length);
- try {
- return jumar.unmarshal(env.debug(), input);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public T objectify(String text) throws APIException {
- try {
- return jumar.unmarshal(primaryEnv.debug(), text);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public Class<T> getTypeClass() {
- return (Class<T>)jmar.getMarshalClass();
- }
+ // Package on purpose
+ EnvJAXB primaryEnv;
+ JAXBumar jumar;
+ JAXBmar jmar;
+
+ public JAXBDF(EnvJAXB env, Class<?> ... classes) throws APIException {
+ try {
+ primaryEnv = env;
+ jumar = new JAXBumar(classes);
+ jmar = new JAXBmar(classes) ;
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public JAXBDF(EnvJAXB env, Schema schema, Class<?> ... classes) throws APIException {
+ try {
+ primaryEnv = env;
+ jumar = new JAXBumar(schema, classes);
+ jmar = new JAXBmar(classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public JAXBDF(EnvJAXB env, QName qname, Class<?> ... classes) throws APIException {
+ try {
+ primaryEnv = env;
+ jumar = new JAXBumar(classes);
+ jmar = new JAXBmar(qname, classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public JAXBDF(EnvJAXB env, Schema schema, QName qname, Class<?> ... classes) throws APIException {
+ try {
+ primaryEnv = env;
+ jumar = new JAXBumar(schema, classes);
+ jmar = new JAXBmar(qname, classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public T newInstance() throws APIException {
+ try {
+ return jumar.newInstance();
+ } catch (Exception e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public IOStringifier<T> pretty(boolean pretty) {
+ jmar.pretty(pretty);
+ return this;
+ }
+
+ // @Override
+ public IOStringifier<T> asFragment(boolean fragment) {
+ jmar.asFragment(fragment);
+ return this;
+ }
+
+ // @Override
+ public void servicePrestart(Env env) throws APIException {
+ }
+
+ // @Override
+ public void threadPrestart(Env env) throws APIException {
+ }
+
+ // @Override
+ public void refresh(Env env) throws APIException {
+ }
+
+ // @Override
+ public void threadDestroy(Env env) throws APIException {
+ }
+
+ // @Override
+ public void serviceDestroy(Env env) throws APIException {
+ }
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public Data<T> newData() {
+ return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),"",(Class<T>)jmar.getMarshalClass());
+ }
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public Data<T> newData(Env env) {
+ return new JAXBData<T>(env, this,new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),"",(Class<T>)jmar.getMarshalClass());
+ }
+
+ // @Override
+ public Data<T> newData(T type) {
+ return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar), type);
+ }
+
+ // @Override
+ public Data<T> newDataFromStream(Env env, InputStream input) throws APIException {
+ //TODO Write an unvalidated String using STAX checking for end of Doc?
+ // perhaps key evaluation as well.
+ try {
+ T t = jumar.unmarshal(env.debug(), input);
+ return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),t);
+ } catch(JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public Data<T> newDataFromString(String string) {
+ return new JAXBData<T>(primaryEnv, this,new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar), string,(Class<T>)jmar.getMarshalClass());
+ }
+
+ /////////// Old DataFactory Interface
+ // @Override
+ public String stringify(T type) throws APIException {
+ try {
+ StringWriter sw = new StringWriter();
+ jmar.marshal(primaryEnv.debug(), type, sw);
+ return sw.toString();
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public void stringify(T type, Writer writer) throws APIException {
+ try {
+ jmar.marshal(primaryEnv.debug(), type, writer);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public void stringify(T type, OutputStream os) throws APIException {
+ try {
+ jmar.marshal(primaryEnv.debug(), type, os);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ /////////// New DataFactory Interface
+ // @Override
+ public String stringify(Env env, T input, boolean ... options) throws APIException {
+ try {
+ StringWriter sw = new StringWriter();
+ TimeTaken tt = env.start("JAXB Stringify", Env.XML);
+ try {
+ jmar.marshal(env.debug(), input, sw, options);
+ } finally {
+ tt.done();
+ }
+ String str = sw.toString();
+ tt.size(str.getBytes().length);
+ return str;
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException {
+ TimeTaken tt = env.start("JAXB Stringify", Env.XML);
+ try {
+ jmar.marshal(env.debug(), input, writer, options);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException {
+ TimeTaken tt = env.start("JAXB Stringify", Env.XML);
+ try {
+ jmar.marshal(env.debug(), input, os, options);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public T objectify(Env env, Reader rdr) throws APIException {
+ TimeTaken tt = env.start("JAXB Objectify", Env.XML);
+ try {
+ return jumar.unmarshal(env.debug(), rdr);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public T objectify(Reader rdr) throws APIException {
+ try {
+ return jumar.unmarshal(primaryEnv.debug(), rdr);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public T objectify(Env env, InputStream is) throws APIException {
+ TimeTaken tt = env.start("JAXB Objectify", Env.XML);
+ try {
+ return jumar.unmarshal(env.debug(), is);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public T objectify(InputStream is) throws APIException {
+ try {
+ return jumar.unmarshal(primaryEnv.debug(), is);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // @Override
+ public T objectify(Env env, String input) throws APIException {
+ TimeTaken tt = env.start("JAXB Objectify", Env.XML);
+ tt.size(input.getBytes().length);
+ try {
+ return jumar.unmarshal(env.debug(), input);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public T objectify(String text) throws APIException {
+ try {
+ return jumar.unmarshal(primaryEnv.debug(), text);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public Class<T> getTypeClass() {
+ return (Class<T>)jmar.getMarshalClass();
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java
index 84502ade..38977a35 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java
@@ -55,267 +55,267 @@ import org.onap.aaf.misc.env.old.Stringifier;
* @param <T>
*/
public final class JAXBData<T> implements Data<T>{
- private Stringifier<T> stringifier;
- private Objectifier<T> objectifier;
- private String dataAsString;
- private T dataAsObject;
- private Class<T> tclass;
- private JAXBDF<T> df;
- private Env creatingEnv;
- private boolean options[] = new boolean[] {false, false};
-
- /**
- * Construct a Data Object with an appropriate Stringifier, Objectifier and Class to support
- *
- * @param env
- * @param strfr
- * @param objfr
- * @param text
- * @param typeClass
- */
- JAXBData(Env env, JAXBDF<T> df, Stringifier<T> strfr, Objectifier<T> objfr, String text, Class<T> typeClass) {
- dataAsString = text;
- dataAsObject = null;
- stringifier = strfr;
- objectifier = objfr;
- tclass = typeClass;
- creatingEnv = env;
- this.df = df;
- }
-
-
- /**
- * Construct a Data Object with an appropriate Stringifier, Objectifier and Object (which will
- * yield it's class)
- *
- * @param env
- * @param strfr
- * @param objfr
- * @param object
- */
- @SuppressWarnings("unchecked")
- JAXBData(Env env, JAXBDF<T> df, Stringifier<T> strfr, Objectifier<T> objfr, T object) {
- dataAsString = null;
- dataAsObject = object;
- stringifier = strfr;
- objectifier = objfr;
- tclass = (Class<T>) object.getClass();
- creatingEnv = env;
- this.df = df;
- }
+ private Stringifier<T> stringifier;
+ private Objectifier<T> objectifier;
+ private String dataAsString;
+ private T dataAsObject;
+ private Class<T> tclass;
+ private JAXBDF<T> df;
+ private Env creatingEnv;
+ private boolean options[] = new boolean[] {false, false};
+
+ /**
+ * Construct a Data Object with an appropriate Stringifier, Objectifier and Class to support
+ *
+ * @param env
+ * @param strfr
+ * @param objfr
+ * @param text
+ * @param typeClass
+ */
+ JAXBData(Env env, JAXBDF<T> df, Stringifier<T> strfr, Objectifier<T> objfr, String text, Class<T> typeClass) {
+ dataAsString = text;
+ dataAsObject = null;
+ stringifier = strfr;
+ objectifier = objfr;
+ tclass = typeClass;
+ creatingEnv = env;
+ this.df = df;
+ }
+
+
+ /**
+ * Construct a Data Object with an appropriate Stringifier, Objectifier and Object (which will
+ * yield it's class)
+ *
+ * @param env
+ * @param strfr
+ * @param objfr
+ * @param object
+ */
+ @SuppressWarnings("unchecked")
+ JAXBData(Env env, JAXBDF<T> df, Stringifier<T> strfr, Objectifier<T> objfr, T object) {
+ dataAsString = null;
+ dataAsObject = object;
+ stringifier = strfr;
+ objectifier = objfr;
+ tclass = (Class<T>) object.getClass();
+ creatingEnv = env;
+ this.df = df;
+ }
- /**
- * Respond with the String if it exists, or marshal the String and pass the result back.<p>
- *
- * Explicitly use a specific Env for logging purposes
- *
- * @param env
- * @return String
- * @throws APIException
- */
- public String asString(EnvJAXB env) throws APIException {
- if(dataAsString!=null) {
- return dataAsString;
- } else {
- return dataAsString = stringifier.stringify(env, dataAsObject);
- }
- }
+ /**
+ * Respond with the String if it exists, or marshal the String and pass the result back.<p>
+ *
+ * Explicitly use a specific Env for logging purposes
+ *
+ * @param env
+ * @return String
+ * @throws APIException
+ */
+ public String asString(EnvJAXB env) throws APIException {
+ if(dataAsString!=null) {
+ return dataAsString;
+ } else {
+ return dataAsString = stringifier.stringify(env, dataAsObject);
+ }
+ }
- /**
- * Respond with the String if it exists, or marshal the String and pass the result back.
- *
- * However, use the Env the Data Object was created with.
- *
- * @return String
- * @throws APIException
- */
- // @Override
- public String asString() throws APIException {
- if(dataAsString!=null) {
- return dataAsString;
- } else {
- return dataAsString = stringifier.stringify(creatingEnv, dataAsObject,options);
- }
- }
-
- public Data<T> to(OutputStream os) throws APIException, IOException {
- if(dataAsString!=null) {
- os.write(dataAsString.getBytes());
- } else if (stringifier instanceof IOStringifier){
- ((IOStringifier<T>)stringifier).stringify(creatingEnv, dataAsObject, os, options);
- } else {
- dataAsString = stringifier.stringify(creatingEnv, dataAsObject, options);
- os.write(dataAsString.getBytes());
- }
- return this;
- }
+ /**
+ * Respond with the String if it exists, or marshal the String and pass the result back.
+ *
+ * However, use the Env the Data Object was created with.
+ *
+ * @return String
+ * @throws APIException
+ */
+ // @Override
+ public String asString() throws APIException {
+ if(dataAsString!=null) {
+ return dataAsString;
+ } else {
+ return dataAsString = stringifier.stringify(creatingEnv, dataAsObject,options);
+ }
+ }
+
+ public Data<T> to(OutputStream os) throws APIException, IOException {
+ if(dataAsString!=null) {
+ os.write(dataAsString.getBytes());
+ } else if (stringifier instanceof IOStringifier){
+ ((IOStringifier<T>)stringifier).stringify(creatingEnv, dataAsObject, os, options);
+ } else {
+ dataAsString = stringifier.stringify(creatingEnv, dataAsObject, options);
+ os.write(dataAsString.getBytes());
+ }
+ return this;
+ }
- // @Override
- public JAXBData<T> to(Writer writer) throws APIException, IOException {
- if(dataAsString!=null) {
- writer.write(dataAsString);
- } else if (stringifier instanceof IOStringifier){
- ((IOStringifier<T>)stringifier).stringify(creatingEnv, dataAsObject, writer, options);
- } else {
- dataAsString = stringifier.stringify(creatingEnv, dataAsObject, options);
- writer.write(dataAsString);
- }
- return this;
- }
+ // @Override
+ public JAXBData<T> to(Writer writer) throws APIException, IOException {
+ if(dataAsString!=null) {
+ writer.write(dataAsString);
+ } else if (stringifier instanceof IOStringifier){
+ ((IOStringifier<T>)stringifier).stringify(creatingEnv, dataAsObject, writer, options);
+ } else {
+ dataAsString = stringifier.stringify(creatingEnv, dataAsObject, options);
+ writer.write(dataAsString);
+ }
+ return this;
+ }
- public InputStream getInputStream() throws APIException {
- if(dataAsString==null) {
- dataAsString = stringifier.stringify(creatingEnv,dataAsObject,options);
- }
- return new ByteArrayInputStream(dataAsString.getBytes());
- }
-
- /**
- * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String
- * and pass the result back.<p>
- *
- * Explicitly use a specific Env for logging purposes
- *
- * @param env
- * @return T
- * @throws APIException
- */
+ public InputStream getInputStream() throws APIException {
+ if(dataAsString==null) {
+ dataAsString = stringifier.stringify(creatingEnv,dataAsObject,options);
+ }
+ return new ByteArrayInputStream(dataAsString.getBytes());
+ }
+
+ /**
+ * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String
+ * and pass the result back.<p>
+ *
+ * Explicitly use a specific Env for logging purposes
+ *
+ * @param env
+ * @return T
+ * @throws APIException
+ */
- public T asObject(EnvJAXB env) throws APIException {
- if(dataAsObject !=null) {
- return dataAsObject;
- } else {
- // Some Java compilers need two statements here
- dataAsObject = objectifier.objectify(env, dataAsString);
- return dataAsObject;
- }
- }
+ public T asObject(EnvJAXB env) throws APIException {
+ if(dataAsObject !=null) {
+ return dataAsObject;
+ } else {
+ // Some Java compilers need two statements here
+ dataAsObject = objectifier.objectify(env, dataAsString);
+ return dataAsObject;
+ }
+ }
- /**
- * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String
- * and pass the result back.<p>
- *
- * However, use the Env the Data Object was created with.
- *
- * @return T
- * @throws APIException
- */
- // @Override
- public T asObject() throws APIException {
- if(dataAsObject !=null) {
- return dataAsObject;
- } else {
- // Some Java compilers need two statements here
- dataAsObject = objectifier.objectify(creatingEnv, dataAsString);
- return dataAsObject;
- }
- }
-
+ /**
+ * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String
+ * and pass the result back.<p>
+ *
+ * However, use the Env the Data Object was created with.
+ *
+ * @return T
+ * @throws APIException
+ */
+ // @Override
+ public T asObject() throws APIException {
+ if(dataAsObject !=null) {
+ return dataAsObject;
+ } else {
+ // Some Java compilers need two statements here
+ dataAsObject = objectifier.objectify(creatingEnv, dataAsString);
+ return dataAsObject;
+ }
+ }
+
- /**
- * Return the Class Type supported by this DataObject
- *
- * @return {@literal Class<T>}
- */
- // @Override
- public Class<T> getTypeClass() {
- return tclass;
- }
-
-
- /**
- * For Debugging Convenience, we marshal to String if possible.
- *
- * Behavior is essentially the same as asString(), except asString() throws
- * an APIException. <p>
- * Since toString() must not throw exceptions, the function just catches and prints an
- * error, which is probably not the behavior desired.<p>
- *
- * Therefore, use "asString()" where possible in actual Transactional code.
- *
- * @see java.lang.Object#toString()
- */
- // @Override
- public String toString() {
- if(dataAsString!=null) {
- return dataAsString;
- } else {
- try {
- return dataAsString = stringifier.stringify(creatingEnv, dataAsObject);
- } catch (APIException e) {
- return "ERROR - Can't Stringify from Object " + e.getLocalizedMessage();
- }
- }
- }
+ /**
+ * Return the Class Type supported by this DataObject
+ *
+ * @return {@literal Class<T>}
+ */
+ // @Override
+ public Class<T> getTypeClass() {
+ return tclass;
+ }
+
+
+ /**
+ * For Debugging Convenience, we marshal to String if possible.
+ *
+ * Behavior is essentially the same as asString(), except asString() throws
+ * an APIException. <p>
+ * Since toString() must not throw exceptions, the function just catches and prints an
+ * error, which is probably not the behavior desired.<p>
+ *
+ * Therefore, use "asString()" where possible in actual Transactional code.
+ *
+ * @see java.lang.Object#toString()
+ */
+ // @Override
+ public String toString() {
+ if(dataAsString!=null) {
+ return dataAsString;
+ } else {
+ try {
+ return dataAsString = stringifier.stringify(creatingEnv, dataAsObject);
+ } catch (APIException e) {
+ return "ERROR - Can't Stringify from Object " + e.getLocalizedMessage();
+ }
+ }
+ }
- public Data<T> load(T t) throws APIException {
- dataAsObject = t;
- dataAsString = null;
- return this;
- }
+ public Data<T> load(T t) throws APIException {
+ dataAsObject = t;
+ dataAsString = null;
+ return this;
+ }
- public Data<T> load(String str) throws APIException {
- dataAsObject = null;
- dataAsString = str;
- return this;
- }
+ public Data<T> load(String str) throws APIException {
+ dataAsObject = null;
+ dataAsString = str;
+ return this;
+ }
- public Data<T> load(InputStream is) throws APIException {
- try {
- dataAsObject = df.jumar.unmarshal(creatingEnv.debug(),is);
- dataAsString = null;
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- return this;
- }
+ public Data<T> load(InputStream is) throws APIException {
+ try {
+ dataAsObject = df.jumar.unmarshal(creatingEnv.debug(),is);
+ dataAsString = null;
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ return this;
+ }
- public Data<T> load(Reader rdr) throws APIException {
- try {
- dataAsObject = df.jumar.unmarshal(creatingEnv.debug(),rdr);
- dataAsString = null;
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- return this;
- }
+ public Data<T> load(Reader rdr) throws APIException {
+ try {
+ dataAsObject = df.jumar.unmarshal(creatingEnv.debug(),rdr);
+ dataAsString = null;
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ return this;
+ }
- // @Override
- public void direct(InputStream input, OutputStream output) throws APIException, IOException {
- byte b[] = new byte[128];
- int count;
- do {
- count = input.read(b);
- if(count>0)output.write(b, 0, count);
- } while(count>=0);
- }
+ // @Override
+ public void direct(InputStream input, OutputStream output) throws APIException, IOException {
+ byte b[] = new byte[128];
+ int count;
+ do {
+ count = input.read(b);
+ if(count>0)output.write(b, 0, count);
+ } while(count>=0);
+ }
- // @Override
- public Data<T> out(TYPE type) {
- // it's going to be XML regardless...
- return this;
- }
+ // @Override
+ public Data<T> out(TYPE type) {
+ // it's going to be XML regardless...
+ return this;
+ }
- // @Override
- public Data<T> in(TYPE type) {
- // Not Supported... will still be XML
- return this;
- }
+ // @Override
+ public Data<T> in(TYPE type) {
+ // Not Supported... will still be XML
+ return this;
+ }
- // @Override
- public Data<T> option(int option) {
- options[0] = (option&Data.PRETTY)==Data.PRETTY;
- options[1] = (option&Data.FRAGMENT)==Data.FRAGMENT;
- return this;
- }
-
+ // @Override
+ public Data<T> option(int option) {
+ options[0] = (option&Data.PRETTY)==Data.PRETTY;
+ options[1] = (option&Data.FRAGMENT)==Data.FRAGMENT;
+ return this;
+ }
+
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java
index 432a449a..7075c7ef 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java
@@ -36,100 +36,100 @@ import org.onap.aaf.misc.env.old.IOObjectifier;
* Allow Extended IO interface usage without muddying up the Stringifier Interface
*/
public class JAXBObjectifier<T> implements IOObjectifier<T> {
- private JAXBumar jumar;
-
- public JAXBObjectifier(Schema schema, Class<?>... classes) throws APIException {
- try {
- jumar = new JAXBumar(schema, classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBObjectifier(Class<?>... classes) throws APIException {
- try {
- jumar = new JAXBumar(classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
+ private JAXBumar jumar;
+
+ public JAXBObjectifier(Schema schema, Class<?>... classes) throws APIException {
+ try {
+ jumar = new JAXBumar(schema, classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public JAXBObjectifier(Class<?>... classes) throws APIException {
+ try {
+ jumar = new JAXBumar(classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
// package on purpose
- JAXBObjectifier(JAXBumar jumar) {
- this.jumar = jumar;
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public T objectify(Env env, String input) throws APIException {
- TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
- try {
- tt.size(input.length());
- return (T)jumar.unmarshal(env.debug(), input);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public T objectify(Env env, Reader rdr) throws APIException {
- //TODO create a Reader that Counts?
- TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
- try {
- return (T)jumar.unmarshal(env.debug(), rdr);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
-
- @SuppressWarnings("unchecked")
- // @Override
- public T objectify(Env env, InputStream is) throws APIException {
- //TODO create a Reader that Counts?
- TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
- try {
- return (T)jumar.unmarshal(env.debug(), is);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
-
- public void servicePrestart(Env env) throws APIException {
- }
-
- public void threadPrestart(Env env) throws APIException {
- }
-
- // // @Override
- public void refresh(Env env) throws APIException {
- }
-
- // // @Override
- public void threadDestroy(Env env) throws APIException {
- }
-
- // // @Override
- public void serviceDestroy(Env env) throws APIException {
- }
-
-
- @SuppressWarnings("unchecked")
- public T newInstance() throws APIException {
- try {
- return (T)jumar.newInstance();
- } catch (Exception e) {
- throw new APIException(e);
- }
- }
+ JAXBObjectifier(JAXBumar jumar) {
+ this.jumar = jumar;
+ }
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public T objectify(Env env, String input) throws APIException {
+ TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
+ try {
+ tt.size(input.length());
+ return (T)jumar.unmarshal(env.debug(), input);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public T objectify(Env env, Reader rdr) throws APIException {
+ //TODO create a Reader that Counts?
+ TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
+ try {
+ return (T)jumar.unmarshal(env.debug(), rdr);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ // @Override
+ public T objectify(Env env, InputStream is) throws APIException {
+ //TODO create a Reader that Counts?
+ TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
+ try {
+ return (T)jumar.unmarshal(env.debug(), is);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+
+ public void servicePrestart(Env env) throws APIException {
+ }
+
+ public void threadPrestart(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void refresh(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void threadDestroy(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void serviceDestroy(Env env) throws APIException {
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public T newInstance() throws APIException {
+ try {
+ return (T)jumar.newInstance();
+ } catch (Exception e) {
+ throw new APIException(e);
+ }
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java
index d1b0cdad..8600efa2 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java
@@ -34,104 +34,104 @@ import org.onap.aaf.misc.env.TimeTaken;
import org.onap.aaf.misc.env.old.IOStringifier;
public class JAXBStringifier<T> implements IOStringifier<T> {
- private JAXBmar jmar;
-
- public JAXBStringifier(Class<?>... classes) throws APIException {
- try {
- jmar = new JAXBmar(classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBStringifier(QName qname, Class<?>... classes)
- throws APIException {
- try {
- jmar = new JAXBmar(qname, classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // package on purpose
- JAXBStringifier(JAXBmar jmar) {
- this.jmar = jmar;
- }
-
- // // @Override
- public void stringify(Env env, T input, Writer writer, boolean ... options)
- throws APIException {
- TimeTaken tt = env.start("JAXB Marshal", Env.XML);
- try {
- jmar.marshal(env.debug(), input, writer, options);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public void stringify(Env env, T input, OutputStream os, boolean ... options)
- throws APIException {
- // TODO create an OutputStream that Counts?
- TimeTaken tt = env.start("JAXB Marshal", Env.XML);
- try {
- jmar.marshal(env.debug(), input, os, options);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public String stringify(Env env, T input, boolean ... options) throws APIException {
- TimeTaken tt = env.start("JAXB Marshal", Env.XML);
- StringWriter sw = new StringWriter();
- try {
- jmar.marshal(env.debug(), input, sw, options);
- String rv = sw.toString();
- tt.size(rv.length());
- return rv;
- } catch (JAXBException e) {
- tt.size(0);
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // // @Override
- public void servicePrestart(Env env) throws APIException {
- }
-
- // // @Override
- public void threadPrestart(Env env) throws APIException {
- }
-
- // // @Override
- public void refresh(Env env) throws APIException {
- }
-
- // // @Override
- public void threadDestroy(Env env) throws APIException {
- }
-
- // // @Override
- public void serviceDestroy(Env env) throws APIException {
- }
-
- // @Override
- public JAXBStringifier<T> pretty(boolean pretty) {
- jmar.pretty(pretty);
- return this;
- }
-
- // @Override
- public JAXBStringifier<T> asFragment(boolean fragment) {
- jmar.asFragment(fragment);
- return this;
- }
+ private JAXBmar jmar;
+
+ public JAXBStringifier(Class<?>... classes) throws APIException {
+ try {
+ jmar = new JAXBmar(classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public JAXBStringifier(QName qname, Class<?>... classes)
+ throws APIException {
+ try {
+ jmar = new JAXBmar(qname, classes);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ // package on purpose
+ JAXBStringifier(JAXBmar jmar) {
+ this.jmar = jmar;
+ }
+
+ // // @Override
+ public void stringify(Env env, T input, Writer writer, boolean ... options)
+ throws APIException {
+ TimeTaken tt = env.start("JAXB Marshal", Env.XML);
+ try {
+ jmar.marshal(env.debug(), input, writer, options);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public void stringify(Env env, T input, OutputStream os, boolean ... options)
+ throws APIException {
+ // TODO create an OutputStream that Counts?
+ TimeTaken tt = env.start("JAXB Marshal", Env.XML);
+ try {
+ jmar.marshal(env.debug(), input, os, options);
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // @Override
+ public String stringify(Env env, T input, boolean ... options) throws APIException {
+ TimeTaken tt = env.start("JAXB Marshal", Env.XML);
+ StringWriter sw = new StringWriter();
+ try {
+ jmar.marshal(env.debug(), input, sw, options);
+ String rv = sw.toString();
+ tt.size(rv.length());
+ return rv;
+ } catch (JAXBException e) {
+ tt.size(0);
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
+
+ // // @Override
+ public void servicePrestart(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void threadPrestart(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void refresh(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void threadDestroy(Env env) throws APIException {
+ }
+
+ // // @Override
+ public void serviceDestroy(Env env) throws APIException {
+ }
+
+ // @Override
+ public JAXBStringifier<T> pretty(boolean pretty) {
+ jmar.pretty(pretty);
+ return this;
+ }
+
+ // @Override
+ public JAXBStringifier<T> asFragment(boolean fragment) {
+ jmar.asFragment(fragment);
+ return this;
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java
index 4a01d8b1..46c40ebb 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java
@@ -63,191 +63,191 @@ import org.onap.aaf.misc.env.util.Pool.Pooled;
*
*/
public class JAXBmar {
- // Need to store off possible JAXBContexts based on Class, which will be stored in Creator
- private static Map<Class<?>[],Pool<PMarshaller>> pools = new HashMap<>();
-
- // Handle Marshaller class setting of properties only when needed
- private class PMarshaller {
- private Marshaller m;
- private boolean p;
- private boolean f;
-
- public PMarshaller(Marshaller marshaller) throws JAXBException {
- m = marshaller;
- m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, p = false);
- m.setProperty(Marshaller.JAXB_FRAGMENT, f = false);
- }
-
- public Marshaller get(boolean pretty, boolean fragment) throws JAXBException {
- if(pretty != p) {
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, p = pretty);
- }
- if(fragment != f) {
- m.setProperty(Marshaller.JAXB_FRAGMENT, f = fragment);
- }
- return m;
- }
- }
-
- private class Creator implements Pool.Creator<PMarshaller> {
- private JAXBContext jc;
- private String name;
- public Creator(Class<?>[] classes) throws JAXBException {
- jc = JAXBContext.newInstance(classes);
- name = "JAXBmar: " + classes[0].getName();
- }
-
- // @Override
- public PMarshaller create() throws APIException {
- try {
- return new PMarshaller(jc.createMarshaller());
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public String toString() {
- return name;
- }
-
- // @Override
- public void reuse(PMarshaller pm) {
- // Nothing to do
- }
-
- // @Override
- public void destroy(PMarshaller pm) {
- // Nothing to do
- }
-
- // @Override
- public boolean isValid(PMarshaller t) {
- return true;
- }
- }
-
- //TODO isn't UTF-8 a standard string somewhere for encoding?
- private boolean fragment= false;
- private boolean pretty=false;
- private QName qname;
-
- private Pool<PMarshaller> mpool; // specific Pool associated with constructed Classes
- private Class<?> cls;
-
- private Pool<PMarshaller> getPool(Class<?> ... classes) throws JAXBException {
- Pool<PMarshaller> mp;
- synchronized(pools) {
- mp = pools.get(classes);
- if(mp==null) {
- pools.put(classes,mp = new Pool<PMarshaller>(new Creator(classes)));
- }
- }
- return mp;
- }
-
- public JAXBmar(Class<?>... classes) throws JAXBException {
- cls = classes[0];
- mpool = getPool(classes);
- qname = null;
- }
-
- public JAXBmar(QName theQname, Class<?>... classes) throws JAXBException {
- cls = classes[0];
- mpool = getPool(classes);
- qname = theQname;
- }
-
- @SuppressWarnings("unchecked")
- public<O> O marshal(LogTarget lt,O o, Writer writer, boolean ... options) throws JAXBException, APIException {
- boolean pretty, fragment;
- pretty = options.length>0?options[0]:this.pretty;
- fragment = options.length>1?options[1]:this.fragment;
- Pooled<PMarshaller> m = mpool.get(lt);
- try {
- if(qname==null) {
- m.content.get(pretty,fragment).marshal(o, writer);
- } else {
- m.content.get(pretty,fragment).marshal(
- new JAXBElement<O>(qname, (Class<O>)cls, o ),
- writer);
- }
- return o;
- } finally {
- m.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- public<O> O marshal(LogTarget lt, O o, OutputStream os, boolean ... options) throws JAXBException, APIException {
- boolean pretty, fragment;
- pretty = options.length>0?options[0]:this.pretty;
- fragment = options.length>1?options[1]:this.fragment;
- Pooled<PMarshaller> m = mpool.get(lt);
- try {
- if(qname==null) {
- m.content.get(pretty,fragment).marshal(o, os);
- } else {
- m.content.get(pretty,fragment).marshal(
- new JAXBElement<O>(qname, (Class<O>)cls, o ),os);
- }
- return o;
- } finally {
- m.done();
- }
- }
-
- public<O> O marshal(LogTarget lt, O o, Writer writer, Class<O> clss) throws JAXBException, APIException {
- Pooled<PMarshaller> m = mpool.get(lt);
- try {
- if(qname==null) {
- m.content.get(pretty,fragment).marshal(o, writer);
- } else {
- m.content.get(pretty,fragment).marshal(
- new JAXBElement<O>(qname, clss, o),writer);
- }
- return o;
- } finally {
- m.done();
- }
-
- }
-
- public<O> O marshal(LogTarget lt, O o, OutputStream os, Class<O> clss) throws JAXBException, APIException {
- Pooled<PMarshaller> m = mpool.get(lt);
- try {
- if(qname==null) {
- m.content.get(pretty,fragment).marshal(o, os);
- } else {
- m.content.get(pretty,fragment).marshal(
- new JAXBElement<O>(qname, clss, o ),os);
- }
- return o;
- } finally {
- m.done();
- }
- }
-
- /**
- * @return
- */
- public Class<?> getMarshalClass() {
- return cls;
- }
-
- public<O> String stringify(LogTarget lt, O o) throws JAXBException, APIException {
- StringWriter sw = new StringWriter();
- marshal(lt,o,sw);
- return sw.toString();
- }
-
- public JAXBmar pretty(boolean pretty) {
- this.pretty = pretty;
- return this;
- }
-
- public JAXBmar asFragment(boolean fragment) {
- this.fragment = fragment;
- return this;
- }
+ // Need to store off possible JAXBContexts based on Class, which will be stored in Creator
+ private static Map<Class<?>[],Pool<PMarshaller>> pools = new HashMap<>();
+
+ // Handle Marshaller class setting of properties only when needed
+ private class PMarshaller {
+ private Marshaller m;
+ private boolean p;
+ private boolean f;
+
+ public PMarshaller(Marshaller marshaller) throws JAXBException {
+ m = marshaller;
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, p = false);
+ m.setProperty(Marshaller.JAXB_FRAGMENT, f = false);
+ }
+
+ public Marshaller get(boolean pretty, boolean fragment) throws JAXBException {
+ if(pretty != p) {
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, p = pretty);
+ }
+ if(fragment != f) {
+ m.setProperty(Marshaller.JAXB_FRAGMENT, f = fragment);
+ }
+ return m;
+ }
+ }
+
+ private class Creator implements Pool.Creator<PMarshaller> {
+ private JAXBContext jc;
+ private String name;
+ public Creator(Class<?>[] classes) throws JAXBException {
+ jc = JAXBContext.newInstance(classes);
+ name = "JAXBmar: " + classes[0].getName();
+ }
+
+ // @Override
+ public PMarshaller create() throws APIException {
+ try {
+ return new PMarshaller(jc.createMarshaller());
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ // @Override
+ public void reuse(PMarshaller pm) {
+ // Nothing to do
+ }
+
+ // @Override
+ public void destroy(PMarshaller pm) {
+ // Nothing to do
+ }
+
+ // @Override
+ public boolean isValid(PMarshaller t) {
+ return true;
+ }
+ }
+
+ //TODO isn't UTF-8 a standard string somewhere for encoding?
+ private boolean fragment= false;
+ private boolean pretty=false;
+ private QName qname;
+
+ private Pool<PMarshaller> mpool; // specific Pool associated with constructed Classes
+ private Class<?> cls;
+
+ private Pool<PMarshaller> getPool(Class<?> ... classes) throws JAXBException {
+ Pool<PMarshaller> mp;
+ synchronized(pools) {
+ mp = pools.get(classes);
+ if(mp==null) {
+ pools.put(classes,mp = new Pool<PMarshaller>(new Creator(classes)));
+ }
+ }
+ return mp;
+ }
+
+ public JAXBmar(Class<?>... classes) throws JAXBException {
+ cls = classes[0];
+ mpool = getPool(classes);
+ qname = null;
+ }
+
+ public JAXBmar(QName theQname, Class<?>... classes) throws JAXBException {
+ cls = classes[0];
+ mpool = getPool(classes);
+ qname = theQname;
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O marshal(LogTarget lt,O o, Writer writer, boolean ... options) throws JAXBException, APIException {
+ boolean pretty, fragment;
+ pretty = options.length>0?options[0]:this.pretty;
+ fragment = options.length>1?options[1]:this.fragment;
+ Pooled<PMarshaller> m = mpool.get(lt);
+ try {
+ if(qname==null) {
+ m.content.get(pretty,fragment).marshal(o, writer);
+ } else {
+ m.content.get(pretty,fragment).marshal(
+ new JAXBElement<O>(qname, (Class<O>)cls, o ),
+ writer);
+ }
+ return o;
+ } finally {
+ m.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O marshal(LogTarget lt, O o, OutputStream os, boolean ... options) throws JAXBException, APIException {
+ boolean pretty, fragment;
+ pretty = options.length>0?options[0]:this.pretty;
+ fragment = options.length>1?options[1]:this.fragment;
+ Pooled<PMarshaller> m = mpool.get(lt);
+ try {
+ if(qname==null) {
+ m.content.get(pretty,fragment).marshal(o, os);
+ } else {
+ m.content.get(pretty,fragment).marshal(
+ new JAXBElement<O>(qname, (Class<O>)cls, o ),os);
+ }
+ return o;
+ } finally {
+ m.done();
+ }
+ }
+
+ public<O> O marshal(LogTarget lt, O o, Writer writer, Class<O> clss) throws JAXBException, APIException {
+ Pooled<PMarshaller> m = mpool.get(lt);
+ try {
+ if(qname==null) {
+ m.content.get(pretty,fragment).marshal(o, writer);
+ } else {
+ m.content.get(pretty,fragment).marshal(
+ new JAXBElement<O>(qname, clss, o),writer);
+ }
+ return o;
+ } finally {
+ m.done();
+ }
+
+ }
+
+ public<O> O marshal(LogTarget lt, O o, OutputStream os, Class<O> clss) throws JAXBException, APIException {
+ Pooled<PMarshaller> m = mpool.get(lt);
+ try {
+ if(qname==null) {
+ m.content.get(pretty,fragment).marshal(o, os);
+ } else {
+ m.content.get(pretty,fragment).marshal(
+ new JAXBElement<O>(qname, clss, o ),os);
+ }
+ return o;
+ } finally {
+ m.done();
+ }
+ }
+
+ /**
+ * @return
+ */
+ public Class<?> getMarshalClass() {
+ return cls;
+ }
+
+ public<O> String stringify(LogTarget lt, O o) throws JAXBException, APIException {
+ StringWriter sw = new StringWriter();
+ marshal(lt,o,sw);
+ return sw.toString();
+ }
+
+ public JAXBmar pretty(boolean pretty) {
+ this.pretty = pretty;
+ return this;
+ }
+
+ public JAXBmar asFragment(boolean fragment) {
+ this.fragment = fragment;
+ return this;
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java
index 0c078a98..fe3f0145 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java
@@ -67,177 +67,177 @@ import org.w3c.dom.Node;
*
*/
public class JAXBumar {
- // Need to store off possible JAXBContexts based on Class, which will be stored in Creator
- private static Map<Class<?>[],Pool<SUnmarshaller>> pools = new HashMap<>();
-
- private Class<?> cls;
- private Schema schema;
- private Pool<SUnmarshaller> mpool;;
-
- // Handle Marshaller class setting of properties only when needed
- private class SUnmarshaller {
- private Unmarshaller u;
- private Schema s;
-
- public SUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
- u = unmarshaller;
- s = null;
- }
-
- public Unmarshaller get(Schema schema) throws JAXBException {
- if(s != schema) {
- u.setSchema(s = schema);
- }
- return u;
- }
- }
-
- private class Creator implements Pool.Creator<SUnmarshaller> {
- private JAXBContext jc;
- private String name;
-
- public Creator(Class<?>[] classes) throws JAXBException {
- jc = JAXBContext.newInstance(classes);
- name = "JAXBumar: " + classes[0].getName();
- }
-
- // @Override
- public SUnmarshaller create() throws APIException {
- try {
- return new SUnmarshaller(jc.createUnmarshaller());
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public String toString() {
- return name;
- }
-
- // @Override
- public void destroy(SUnmarshaller sui) {
- // Nothing to do
- }
-
- // @Override
- public boolean isValid(SUnmarshaller t) {
- return true;
- }
-
- // @Override
- public void reuse(SUnmarshaller t) {
- // Nothing to do here
- }
-
- }
-
- private Pool<SUnmarshaller> getPool(Class<?> ... classes) throws JAXBException {
- Pool<SUnmarshaller> mp;
- synchronized(pools) {
- mp = pools.get(classes);
- if(mp==null) {
- pools.put(classes,mp = new Pool<SUnmarshaller>(new Creator(classes)));
- }
- }
- return mp;
- }
-
- public JAXBumar(Class<?> ... classes) throws JAXBException {
- cls = classes[0];
- mpool = getPool(classes);
- schema = null;
- }
-
- /**
- * Constructs a new JAXBumar with schema validation enabled.
- *
- * @param schema
- * @param theClass
- * @throws JAXBException
- */
- public JAXBumar(Schema schema, Class<?> ... classes) throws JAXBException {
- cls = classes[0];
- mpool = getPool(classes);
- this.schema = schema;
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env, Node node) throws JAXBException, APIException {
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return s.content.get(schema).unmarshal(node,(Class<O>)cls).getValue();
- } finally {
- s.done();
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env, String xml) throws JAXBException, APIException {
- if(xml==null) throw new JAXBException("Null Input for String unmarshal");
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return (O)s.content.get(schema).unmarshal(
- new StreamSource(new StringReader(xml))
- ,(Class<O>)cls).getValue();
- } finally {
- s.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env, File xmlFile) throws JAXBException, APIException {
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return (O)s.content.get(schema).unmarshal(xmlFile);
- } finally {
- s.done();
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env,InputStream is) throws JAXBException, APIException {
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return (O)s.content.get(schema).unmarshal(is);
- } finally {
- s.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env, Reader rdr) throws JAXBException, APIException {
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return (O)s.content.get(schema).unmarshal(rdr);
- } finally {
- s.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env, XMLStreamReader xsr) throws JAXBException, APIException {
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return (O)s.content.get(schema).unmarshal(xsr,(Class<O>)cls).getValue();
- } finally {
- s.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- public<O> O unmarshal(LogTarget env, XMLEventReader xer) throws JAXBException, APIException {
- Pooled<SUnmarshaller> s = mpool.get(env);
- try {
- return (O)s.content.get(schema).unmarshal(xer,(Class<O>)cls).getValue();
- } finally {
- s.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- public<O> O newInstance() throws InstantiationException, IllegalAccessException{
- return ((Class<O>)cls).newInstance();
- }
+ // Need to store off possible JAXBContexts based on Class, which will be stored in Creator
+ private static Map<Class<?>[],Pool<SUnmarshaller>> pools = new HashMap<>();
+
+ private Class<?> cls;
+ private Schema schema;
+ private Pool<SUnmarshaller> mpool;;
+
+ // Handle Marshaller class setting of properties only when needed
+ private class SUnmarshaller {
+ private Unmarshaller u;
+ private Schema s;
+
+ public SUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
+ u = unmarshaller;
+ s = null;
+ }
+
+ public Unmarshaller get(Schema schema) throws JAXBException {
+ if(s != schema) {
+ u.setSchema(s = schema);
+ }
+ return u;
+ }
+ }
+
+ private class Creator implements Pool.Creator<SUnmarshaller> {
+ private JAXBContext jc;
+ private String name;
+
+ public Creator(Class<?>[] classes) throws JAXBException {
+ jc = JAXBContext.newInstance(classes);
+ name = "JAXBumar: " + classes[0].getName();
+ }
+
+ // @Override
+ public SUnmarshaller create() throws APIException {
+ try {
+ return new SUnmarshaller(jc.createUnmarshaller());
+ } catch (JAXBException e) {
+ throw new APIException(e);
+ }
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ // @Override
+ public void destroy(SUnmarshaller sui) {
+ // Nothing to do
+ }
+
+ // @Override
+ public boolean isValid(SUnmarshaller t) {
+ return true;
+ }
+
+ // @Override
+ public void reuse(SUnmarshaller t) {
+ // Nothing to do here
+ }
+
+ }
+
+ private Pool<SUnmarshaller> getPool(Class<?> ... classes) throws JAXBException {
+ Pool<SUnmarshaller> mp;
+ synchronized(pools) {
+ mp = pools.get(classes);
+ if(mp==null) {
+ pools.put(classes,mp = new Pool<SUnmarshaller>(new Creator(classes)));
+ }
+ }
+ return mp;
+ }
+
+ public JAXBumar(Class<?> ... classes) throws JAXBException {
+ cls = classes[0];
+ mpool = getPool(classes);
+ schema = null;
+ }
+
+ /**
+ * Constructs a new JAXBumar with schema validation enabled.
+ *
+ * @param schema
+ * @param theClass
+ * @throws JAXBException
+ */
+ public JAXBumar(Schema schema, Class<?> ... classes) throws JAXBException {
+ cls = classes[0];
+ mpool = getPool(classes);
+ this.schema = schema;
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env, Node node) throws JAXBException, APIException {
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return s.content.get(schema).unmarshal(node,(Class<O>)cls).getValue();
+ } finally {
+ s.done();
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env, String xml) throws JAXBException, APIException {
+ if(xml==null) throw new JAXBException("Null Input for String unmarshal");
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return (O)s.content.get(schema).unmarshal(
+ new StreamSource(new StringReader(xml))
+ ,(Class<O>)cls).getValue();
+ } finally {
+ s.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env, File xmlFile) throws JAXBException, APIException {
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return (O)s.content.get(schema).unmarshal(xmlFile);
+ } finally {
+ s.done();
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env,InputStream is) throws JAXBException, APIException {
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return (O)s.content.get(schema).unmarshal(is);
+ } finally {
+ s.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env, Reader rdr) throws JAXBException, APIException {
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return (O)s.content.get(schema).unmarshal(rdr);
+ } finally {
+ s.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env, XMLStreamReader xsr) throws JAXBException, APIException {
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return (O)s.content.get(schema).unmarshal(xsr,(Class<O>)cls).getValue();
+ } finally {
+ s.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O unmarshal(LogTarget env, XMLEventReader xer) throws JAXBException, APIException {
+ Pooled<SUnmarshaller> s = mpool.get(env);
+ try {
+ return (O)s.content.get(schema).unmarshal(xer,(Class<O>)cls).getValue();
+ } finally {
+ s.done();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public<O> O newInstance() throws InstantiationException, IllegalAccessException{
+ return ((Class<O>)cls).newInstance();
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java
index ba1b981a..03e47911 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java
@@ -28,30 +28,30 @@ import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Env;
public interface IOObjectifier<T> extends Objectifier<T> {
- /**
- * Marshal to Object T from a Reader, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return T
- * @throws APIException
- */
- public abstract T objectify(Env env, Reader rdr) throws APIException;
-
- /**
- * Marshal to Object T from an InputStream, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return T
- * @throws APIException
- */
- public abstract T objectify(Env env, InputStream is) throws APIException;
+ /**
+ * Marshal to Object T from a Reader, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return T
+ * @throws APIException
+ */
+ public abstract T objectify(Env env, Reader rdr) throws APIException;
+
+ /**
+ * Marshal to Object T from an InputStream, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return T
+ * @throws APIException
+ */
+ public abstract T objectify(Env env, InputStream is) throws APIException;
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java
index 137e401f..ca03a1b8 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java
@@ -31,47 +31,47 @@ import org.onap.aaf.misc.env.Env;
* Allow Extended IO interface usage without muddying up the Stringifier Interface
*/
public interface IOStringifier<T> extends Stringifier<T> {
- /**
- * Marshal from an Object T onto a Writer, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startTime(<string>, Env.XML)" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return String
- * @throws APIException
- */
- public abstract void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException;
-
- /**
- * Marshal from a String to an Object T, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return String
- * @throws APIException
- */
- public abstract void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException;
+ /**
+ * Marshal from an Object T onto a Writer, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startTime(<string>, Env.XML)" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return String
+ * @throws APIException
+ */
+ public abstract void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException;
+
+ /**
+ * Marshal from a String to an Object T, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return String
+ * @throws APIException
+ */
+ public abstract void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException;
- /**
- * Set Pretty XML, where possible
- *
- * @param pretty
- * @throws APIException
- */
- public abstract IOStringifier<T> pretty(boolean pretty);
+ /**
+ * Set Pretty XML, where possible
+ *
+ * @param pretty
+ * @throws APIException
+ */
+ public abstract IOStringifier<T> pretty(boolean pretty);
- /**
- * Set Generate Fragment
- *
- * @param fragment
- * @throws APIException
- */
- public abstract IOStringifier<T> asFragment(boolean fragment);
+ /**
+ * Set Generate Fragment
+ *
+ * @param fragment
+ * @throws APIException
+ */
+ public abstract IOStringifier<T> asFragment(boolean fragment);
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java
index 1fd3cdaf..1f58077e 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java
@@ -35,26 +35,26 @@ import org.onap.aaf.misc.env.LifeCycle;
* the creation of an uninitialized object.
*/
public interface Objectifier<T> extends LifeCycle {
- /**
- * Marshal to Object T from a String, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return T
- * @throws APIException
- */
- public abstract T objectify(Env env, String input) throws APIException;
+ /**
+ * Marshal to Object T from a String, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return T
+ * @throws APIException
+ */
+ public abstract T objectify(Env env, String input) throws APIException;
- /**
- * Create a new object of type T. This is often more efficiently done with
- * the underlying XML (or other) Library.
- * @return T
- * @throws APIException
- */
- public abstract T newInstance() throws APIException;
+ /**
+ * Create a new object of type T. This is often more efficiently done with
+ * the underlying XML (or other) Library.
+ * @return T
+ * @throws APIException
+ */
+ public abstract T newInstance() throws APIException;
-
+
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java
index 724e9f48..463bc15a 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java
@@ -32,16 +32,16 @@ import org.onap.aaf.misc.env.DataFactory;
import org.onap.aaf.misc.env.Env;
public interface OldDataFactory<T> extends DataFactory<T> {
- public abstract String stringify(T type) throws APIException;
- public abstract void stringify(T type, OutputStream os) throws APIException;
- public abstract void stringify(T type, Writer writer) throws APIException;
- public abstract T objectify(InputStream is) throws APIException;
- public abstract T objectify(Reader rdr) throws APIException;
- public abstract T objectify(String text) throws APIException;
- public abstract T newInstance() throws APIException;
- public abstract Data<T> newData(T type);
- public abstract Data<T> newDataFromStream(Env env, InputStream input) throws APIException;
- public abstract Data<T> newDataFromString(String string);
-
+ public abstract String stringify(T type) throws APIException;
+ public abstract void stringify(T type, OutputStream os) throws APIException;
+ public abstract void stringify(T type, Writer writer) throws APIException;
+ public abstract T objectify(InputStream is) throws APIException;
+ public abstract T objectify(Reader rdr) throws APIException;
+ public abstract T objectify(String text) throws APIException;
+ public abstract T newInstance() throws APIException;
+ public abstract Data<T> newData(T type);
+ public abstract Data<T> newDataFromStream(Env env, InputStream input) throws APIException;
+ public abstract Data<T> newDataFromString(String string);
+
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java
index eaea7f6a..01689f38 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java
@@ -31,18 +31,18 @@ import org.onap.aaf.misc.env.LifeCycle;
* <i>Stringifier</i> abstracts the marshaling of a String to an Object
*/
public interface Stringifier<T> extends LifeCycle {
-
- /**
- * Marshal from a String to an Object T, using contents from Env as necessary.<p>
- *
- * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
- * XML time, since this is often a costly process.
- *
- * @param env
- * @param input
- * @return String
- * @throws APIException
- */
- public abstract String stringify(Env env, T input, boolean ... options) throws APIException;
-
+
+ /**
+ * Marshal from a String to an Object T, using contents from Env as necessary.<p>
+ *
+ * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark
+ * XML time, since this is often a costly process.
+ *
+ * @param env
+ * @param input
+ * @return String
+ * @throws APIException
+ */
+ public abstract String stringify(Env env, T input, boolean ... options) throws APIException;
+
} \ No newline at end of file
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java
index ebae19b4..ae78918c 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java
@@ -38,273 +38,273 @@ import javax.xml.datatype.XMLGregorianCalendar;
public class Chrono {
private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
- public final static DateFormat dateFmt, dateOnlyFmt, niceDateFmt, utcFmt,iso8601Fmt;
- // Give general access to XML DataType Factory, since it's pretty common
- public static final DatatypeFactory xmlDatatypeFactory;
-
- static {
- try {
- xmlDatatypeFactory = DatatypeFactory.newInstance();
- } catch (DatatypeConfigurationException e) {
- throw new RuntimeException(e);
- }
- dateOnlyFmt = new SimpleDateFormat("yyyy-MM-dd");
- niceDateFmt = new SimpleDateFormat("yyyy/MM/dd HH:mm zzz");
- dateFmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- utcFmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- iso8601Fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");
- utcFmt.setTimeZone(TimeZone.getTimeZone("UTC"));
- }
-
-
- public static class Formatter8601 extends Formatter {
-
- @Override
- public String format(LogRecord r) {
- StringBuilder sb = new StringBuilder();
- sb.append(dateFmt.format(new Date(r.getMillis())));
- sb.append(' ');
- sb.append(r.getThreadID());
- sb.append(' ');
- sb.append(r.getLevel());
- sb.append(": ");
- sb.append(r.getMessage());
- sb.append('\n');
- return sb.toString();
- }
-
- }
-
- /**
- * timeStamp
- *
- * Convenience method to setup an XML dateTime (XMLGregorianCalendar) with "now"
- * @return
- */
- public static XMLGregorianCalendar timeStamp() {
- return xmlDatatypeFactory.newXMLGregorianCalendar(new GregorianCalendar());
- }
-
- /**
- * timestamp
- *
- * Convenience method to setup an XML dateTime (XMLGregorianCalendar) with passed in Date
- * @param date
- * @return
- */
- public static XMLGregorianCalendar timeStamp(Date date) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- return xmlDatatypeFactory.newXMLGregorianCalendar(gc);
- }
-
- public static XMLGregorianCalendar timeStamp(GregorianCalendar gc) {
- return xmlDatatypeFactory.newXMLGregorianCalendar(gc);
- }
-
- public static String utcStamp() {
- return utcFmt.format(new Date());
- }
-
- public static String utcStamp(Date date) {
- if(date==null)return "";
- return utcFmt.format(date);
- }
-
- public static String utcStamp(GregorianCalendar gc) {
- if(gc==null)return "";
- return utcFmt.format(gc.getTime());
- }
-
- public static String utcStamp(XMLGregorianCalendar xgc) {
- if(xgc==null)return "";
- return utcFmt.format(xgc.toGregorianCalendar().getTime());
- }
-
- public static String dateStamp() {
- return dateFmt.format(new Date());
- }
-
- public static String dateStamp(GregorianCalendar gc) {
- if(gc == null)return "";
- return dateFmt.format(gc.getTime());
- }
-
- public static String dateStamp(Date date) {
- if(date == null)return "";
- return dateFmt.format(date);
- }
-
- public static String dateStamp(XMLGregorianCalendar xgc) {
- if(xgc==null)return "";
- return dateFmt.format(xgc.toGregorianCalendar().getTime());
- }
-
- /**
- * JAXB compatible dataTime Stamp
- *
- * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
- *
- * @return
- */
- public static String dateTime() {
- return dateTime(new GregorianCalendar());
- }
-
- /**
- * JAXB compatible dataTime Stamp
- *
- * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
- *
- * @return
- */
- public static String dateTime(Date date) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- return dateTime(gc);
- }
-
- /**
- * JAXB compatible dataTime Stamp
- *
- * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
- *
- * @return
- */
- public static String dateTime(GregorianCalendar gc) {
- if(gc == null)return "";
- TimeZone tz = gc.getTimeZone();
- int tz1 = (tz.getRawOffset()+tz.getDSTSavings())/0x8CA0;
- int tz1abs = Math.abs(tz1);
- return String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d",
- gc.get(GregorianCalendar.YEAR),
- gc.get(GregorianCalendar.MONTH)+1,
- gc.get(GregorianCalendar.DAY_OF_MONTH),
- gc.get(GregorianCalendar.HOUR),
- gc.get(GregorianCalendar.MINUTE),
- gc.get(GregorianCalendar.SECOND),
- gc.get(GregorianCalendar.MILLISECOND),
- tz1==tz1abs?'+':'-',
- tz1abs/100,
- ((tz1abs-(tz1abs/100)*100)*6)/10 // Get the "10s", then convert to mins (without losing int place)
- );
- }
-
- /**
- * JAXB compatible dataTime Stamp
- *
- * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
- *
- * @return
- */
- public static String dateTime(XMLGregorianCalendar xgc) {
- return xgc==null?"":dateTime(xgc.toGregorianCalendar());
- }
-
- public static String dateOnlyStamp() {
- return dateOnlyFmt.format(new Date());
- }
-
- public static String dateOnlyStamp(GregorianCalendar gc) {
- return gc == null?"":dateOnlyFmt.format(gc.getTime());
- }
-
- public static String dateOnlyStamp(Date date) {
- return date == null?"":dateOnlyFmt.format(date);
- }
-
- public static String dateOnlyStamp(XMLGregorianCalendar xgc) {
- return xgc==null?"":dateOnlyFmt.format(xgc.toGregorianCalendar().getTime());
- }
-
- public static String niceDateStamp() {
- return niceDateFmt.format(new Date());
- }
-
- public static String niceDateStamp(Date date) {
- return date==null?"":niceDateFmt.format(date);
- }
-
- public static String niceDateStamp(GregorianCalendar gc) {
- return gc==null?"":niceDateFmt.format(gc.getTime());
- }
-
- public static String niceDateStamp(XMLGregorianCalendar xgc) {
- return xgc==null?"":niceDateFmt.format(xgc.toGregorianCalendar().getTime());
- }
-
-
- ////////////////////// HELPFUL Strings
- public static final String BAD_DIR_CHARS_REGEX = "[/:\\;.]";
- public static final String SPLIT_DIR_REGEX = "/";
-
- public static long firstMomentOfDay(long utc) {
- GregorianCalendar begin = new GregorianCalendar();
- begin.setTimeInMillis(utc);
- return firstMomentOfDay(begin).getTimeInMillis();
- }
-
- public static long lastMomentOfDay(long utc) {
- GregorianCalendar end = new GregorianCalendar();
- end.setTimeInMillis(utc);
- return lastMomentOfDay(end).getTimeInMillis();
- }
-
- public static GregorianCalendar firstMomentOfDay(GregorianCalendar begin) {
- if(begin==null)begin = new GregorianCalendar();
- begin.set(GregorianCalendar.HOUR, 0);
- begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
- begin.set(GregorianCalendar.MINUTE, 0);
- begin.set(GregorianCalendar.SECOND, 0);
- begin.set(GregorianCalendar.MILLISECOND, 0);
- return begin;
- }
-
- public static GregorianCalendar lastMomentOfDay(GregorianCalendar end) {
- if(end==null)end = new GregorianCalendar();
- end.set(GregorianCalendar.HOUR, 11);
- end.set(GregorianCalendar.MINUTE, 59);
- end.set(GregorianCalendar.SECOND, 59);
- end.set(GregorianCalendar.MILLISECOND, 999);
- end.set(GregorianCalendar.AM_PM, GregorianCalendar.PM);
- return end;
- }
-
- // UUID needs to be converted from UUID Epoch
- public static final Date uuidToDate(UUID id) {
- return new Date((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000);
- }
-
- public static final long uuidToUnix(UUID id) {
- return (id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000;
- }
-
- public static float millisFromNanos(long start, long end) {
- return (end - start) / 1000000f;
- }
-
-
- private static long sequence = new SecureRandom().nextInt();
- private static synchronized long sequence() {
- return ++sequence;
- }
-
- public static final UUID dateToUUID(Date origTime) {
- return dateToUUID(origTime.getTime());
- }
-
- public static final UUID dateToUUID(long origTime) {
- /*
- * From Cassandra : http://wiki.apache.org/cassandra/FAQ
- Magic number obtained from #cassandra's thobbs, who
- claims to have stolen it from a Python library.
- */
+ public final static DateFormat dateFmt, dateOnlyFmt, niceDateFmt, utcFmt,iso8601Fmt;
+ // Give general access to XML DataType Factory, since it's pretty common
+ public static final DatatypeFactory xmlDatatypeFactory;
+
+ static {
+ try {
+ xmlDatatypeFactory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ dateOnlyFmt = new SimpleDateFormat("yyyy-MM-dd");
+ niceDateFmt = new SimpleDateFormat("yyyy/MM/dd HH:mm zzz");
+ dateFmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ utcFmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ iso8601Fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");
+ utcFmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+
+ public static class Formatter8601 extends Formatter {
+
+ @Override
+ public String format(LogRecord r) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(dateFmt.format(new Date(r.getMillis())));
+ sb.append(' ');
+ sb.append(r.getThreadID());
+ sb.append(' ');
+ sb.append(r.getLevel());
+ sb.append(": ");
+ sb.append(r.getMessage());
+ sb.append('\n');
+ return sb.toString();
+ }
+
+ }
+
+ /**
+ * timeStamp
+ *
+ * Convenience method to setup an XML dateTime (XMLGregorianCalendar) with "now"
+ * @return
+ */
+ public static XMLGregorianCalendar timeStamp() {
+ return xmlDatatypeFactory.newXMLGregorianCalendar(new GregorianCalendar());
+ }
+
+ /**
+ * timestamp
+ *
+ * Convenience method to setup an XML dateTime (XMLGregorianCalendar) with passed in Date
+ * @param date
+ * @return
+ */
+ public static XMLGregorianCalendar timeStamp(Date date) {
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTime(date);
+ return xmlDatatypeFactory.newXMLGregorianCalendar(gc);
+ }
+
+ public static XMLGregorianCalendar timeStamp(GregorianCalendar gc) {
+ return xmlDatatypeFactory.newXMLGregorianCalendar(gc);
+ }
+
+ public static String utcStamp() {
+ return utcFmt.format(new Date());
+ }
+
+ public static String utcStamp(Date date) {
+ if(date==null)return "";
+ return utcFmt.format(date);
+ }
+
+ public static String utcStamp(GregorianCalendar gc) {
+ if(gc==null)return "";
+ return utcFmt.format(gc.getTime());
+ }
+
+ public static String utcStamp(XMLGregorianCalendar xgc) {
+ if(xgc==null)return "";
+ return utcFmt.format(xgc.toGregorianCalendar().getTime());
+ }
+
+ public static String dateStamp() {
+ return dateFmt.format(new Date());
+ }
+
+ public static String dateStamp(GregorianCalendar gc) {
+ if(gc == null)return "";
+ return dateFmt.format(gc.getTime());
+ }
+
+ public static String dateStamp(Date date) {
+ if(date == null)return "";
+ return dateFmt.format(date);
+ }
+
+ public static String dateStamp(XMLGregorianCalendar xgc) {
+ if(xgc==null)return "";
+ return dateFmt.format(xgc.toGregorianCalendar().getTime());
+ }
+
+ /**
+ * JAXB compatible dataTime Stamp
+ *
+ * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
+ *
+ * @return
+ */
+ public static String dateTime() {
+ return dateTime(new GregorianCalendar());
+ }
+
+ /**
+ * JAXB compatible dataTime Stamp
+ *
+ * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
+ *
+ * @return
+ */
+ public static String dateTime(Date date) {
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTime(date);
+ return dateTime(gc);
+ }
+
+ /**
+ * JAXB compatible dataTime Stamp
+ *
+ * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
+ *
+ * @return
+ */
+ public static String dateTime(GregorianCalendar gc) {
+ if(gc == null)return "";
+ TimeZone tz = gc.getTimeZone();
+ int tz1 = (tz.getRawOffset()+tz.getDSTSavings())/0x8CA0;
+ int tz1abs = Math.abs(tz1);
+ return String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d",
+ gc.get(GregorianCalendar.YEAR),
+ gc.get(GregorianCalendar.MONTH)+1,
+ gc.get(GregorianCalendar.DAY_OF_MONTH),
+ gc.get(GregorianCalendar.HOUR),
+ gc.get(GregorianCalendar.MINUTE),
+ gc.get(GregorianCalendar.SECOND),
+ gc.get(GregorianCalendar.MILLISECOND),
+ tz1==tz1abs?'+':'-',
+ tz1abs/100,
+ ((tz1abs-(tz1abs/100)*100)*6)/10 // Get the "10s", then convert to mins (without losing int place)
+ );
+ }
+
+ /**
+ * JAXB compatible dataTime Stamp
+ *
+ * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it.
+ *
+ * @return
+ */
+ public static String dateTime(XMLGregorianCalendar xgc) {
+ return xgc==null?"":dateTime(xgc.toGregorianCalendar());
+ }
+
+ public static String dateOnlyStamp() {
+ return dateOnlyFmt.format(new Date());
+ }
+
+ public static String dateOnlyStamp(GregorianCalendar gc) {
+ return gc == null?"":dateOnlyFmt.format(gc.getTime());
+ }
+
+ public static String dateOnlyStamp(Date date) {
+ return date == null?"":dateOnlyFmt.format(date);
+ }
+
+ public static String dateOnlyStamp(XMLGregorianCalendar xgc) {
+ return xgc==null?"":dateOnlyFmt.format(xgc.toGregorianCalendar().getTime());
+ }
+
+ public static String niceDateStamp() {
+ return niceDateFmt.format(new Date());
+ }
+
+ public static String niceDateStamp(Date date) {
+ return date==null?"":niceDateFmt.format(date);
+ }
+
+ public static String niceDateStamp(GregorianCalendar gc) {
+ return gc==null?"":niceDateFmt.format(gc.getTime());
+ }
+
+ public static String niceDateStamp(XMLGregorianCalendar xgc) {
+ return xgc==null?"":niceDateFmt.format(xgc.toGregorianCalendar().getTime());
+ }
+
+
+ ////////////////////// HELPFUL Strings
+ public static final String BAD_DIR_CHARS_REGEX = "[/:\\;.]";
+ public static final String SPLIT_DIR_REGEX = "/";
+
+ public static long firstMomentOfDay(long utc) {
+ GregorianCalendar begin = new GregorianCalendar();
+ begin.setTimeInMillis(utc);
+ return firstMomentOfDay(begin).getTimeInMillis();
+ }
+
+ public static long lastMomentOfDay(long utc) {
+ GregorianCalendar end = new GregorianCalendar();
+ end.setTimeInMillis(utc);
+ return lastMomentOfDay(end).getTimeInMillis();
+ }
+
+ public static GregorianCalendar firstMomentOfDay(GregorianCalendar begin) {
+ if(begin==null)begin = new GregorianCalendar();
+ begin.set(GregorianCalendar.HOUR, 0);
+ begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
+ begin.set(GregorianCalendar.MINUTE, 0);
+ begin.set(GregorianCalendar.SECOND, 0);
+ begin.set(GregorianCalendar.MILLISECOND, 0);
+ return begin;
+ }
+
+ public static GregorianCalendar lastMomentOfDay(GregorianCalendar end) {
+ if(end==null)end = new GregorianCalendar();
+ end.set(GregorianCalendar.HOUR, 11);
+ end.set(GregorianCalendar.MINUTE, 59);
+ end.set(GregorianCalendar.SECOND, 59);
+ end.set(GregorianCalendar.MILLISECOND, 999);
+ end.set(GregorianCalendar.AM_PM, GregorianCalendar.PM);
+ return end;
+ }
+
+ // UUID needs to be converted from UUID Epoch
+ public static final Date uuidToDate(UUID id) {
+ return new Date((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000);
+ }
+
+ public static final long uuidToUnix(UUID id) {
+ return (id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000;
+ }
+
+ public static float millisFromNanos(long start, long end) {
+ return (end - start) / 1000000f;
+ }
+
+
+ private static long sequence = new SecureRandom().nextInt();
+ private static synchronized long sequence() {
+ return ++sequence;
+ }
+
+ public static final UUID dateToUUID(Date origTime) {
+ return dateToUUID(origTime.getTime());
+ }
+
+ public static final UUID dateToUUID(long origTime) {
+ /*
+ * From Cassandra : http://wiki.apache.org/cassandra/FAQ
+ Magic number obtained from #cassandra's thobbs, who
+ claims to have stolen it from a Python library.
+ */
long time = origTime * 10000 + NUM_100NS_INTERVALS_SINCE_UUID_EPOCH;
long timeLow = time & 0xffffffffL;
long timeMid = time & 0xffff00000000L;
long timeHi = time & 0xfff000000000000L;
long upperLong = (timeLow << 32) | (timeMid >> 16) | (1 << 12) | (timeHi >> 48) ;
return new java.util.UUID(upperLong, (0xC000000000000000L | sequence()));
- }
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java
index 9c4c4316..97d9de99 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java
@@ -26,15 +26,15 @@ import java.io.OutputStream;
public class DoubleOutputStream extends OutputStream {
private OutputStream[] oss;
- private boolean[] close;
+ private boolean[] close;
- /**
+ /**
* Create a Double Stream Writer
* Some Streams should not be closed by this object (i.e. System.out), therefore, mark them with booleans
*/
public DoubleOutputStream(OutputStream a, boolean closeA, OutputStream b, boolean closeB) {
- oss = new OutputStream[] {a,b};
- close = new boolean[] {closeA,closeB};
+ oss = new OutputStream[] {a,b};
+ close = new boolean[] {closeA,closeB};
}
/**
@@ -43,9 +43,9 @@ public class DoubleOutputStream extends OutputStream {
*/
@Override
public void write(int c) throws IOException {
- for(OutputStream os : oss) {
- os.write(c);
- }
+ for(OutputStream os : oss) {
+ os.write(c);
+ }
}
/**
@@ -58,39 +58,39 @@ public class DoubleOutputStream extends OutputStream {
*/
@Override
public void write(byte bbuf[], int off, int len) throws IOException {
- for(OutputStream os : oss) {
- os.write(bbuf,off,len);
- }
+ for(OutputStream os : oss) {
+ os.write(bbuf,off,len);
+ }
}
@Override
- public void write(byte[] b) throws IOException {
- for(OutputStream os : oss) {
- os.write(b);
- }
- }
+ public void write(byte[] b) throws IOException {
+ for(OutputStream os : oss) {
+ os.write(b);
+ }
+ }
- /* (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- @Override
- public void close() throws IOException {
- for(int i=0;i<oss.length;++i) {
- if(close[i]) {
- oss[i].close();
- }
- }
- }
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#close()
+ */
+ @Override
+ public void close() throws IOException {
+ for(int i=0;i<oss.length;++i) {
+ if(close[i]) {
+ oss[i].close();
+ }
+ }
+ }
- /* (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- @Override
- public void flush() throws IOException {
- for(OutputStream os : oss) {
- os.flush();
- }
- }
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#flush()
+ */
+ @Override
+ public void flush() throws IOException {
+ for(OutputStream os : oss) {
+ os.flush();
+ }
+ }
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java
index 3e02c009..f6242657 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java
@@ -24,34 +24,34 @@ package org.onap.aaf.misc.env.util;
import java.util.regex.Pattern;
public class IPValidator {
- private static final Pattern ipv4_p = Pattern.compile(
- "^((\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}\\2$"
- );
+ private static final Pattern ipv4_p = Pattern.compile(
+ "^((\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}\\2$"
+ );
- private static final Pattern ipv6_p = Pattern.compile(
- "^(([0-9a-fA-F]{0,4})([:|.])){2,7}([0-9a-fA-F]{0,4})$"
- );
-
- private static final Pattern doubleColon = Pattern.compile(
- ".*::.*::.*"
- );
+ private static final Pattern ipv6_p = Pattern.compile(
+ "^(([0-9a-fA-F]{0,4})([:|.])){2,7}([0-9a-fA-F]{0,4})$"
+ );
+
+ private static final Pattern doubleColon = Pattern.compile(
+ ".*::.*::.*"
+ );
- private static final Pattern tooManyColon = Pattern.compile(
- "(.*:){1,7}"
- );
+ private static final Pattern tooManyColon = Pattern.compile(
+ "(.*:){1,7}"
+ );
-
- public static boolean ipv4(String str) {
- return ipv4_p.matcher(str).matches();
- }
-
- public static boolean ipv6(String str) {
- return ipv6_p.matcher(str).matches() &&
- !doubleColon.matcher(str).matches() &&
- !tooManyColon.matcher(str).matches();
- }
-
- public static boolean ip (String str) {
- return ipv4_p.matcher(str).matches() || ipv6(str);
- }
+
+ public static boolean ipv4(String str) {
+ return ipv4_p.matcher(str).matches();
+ }
+
+ public static boolean ipv6(String str) {
+ return ipv6_p.matcher(str).matches() &&
+ !doubleColon.matcher(str).matches() &&
+ !tooManyColon.matcher(str).matches();
+ }
+
+ public static boolean ip (String str) {
+ return ipv4_p.matcher(str).matches() || ipv6(str);
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java
index 82f05b4a..db93abfd 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java
@@ -60,339 +60,339 @@ import org.onap.aaf.misc.env.LogTarget;
* @param <T>
*/
public class Pool<T> {
- /**
- * This is a constant which specified the default maximum number of unused
- * objects to be held at any given time.
- */
- private static final int MAX_RANGE = 6; // safety
+ /**
+ * This is a constant which specified the default maximum number of unused
+ * objects to be held at any given time.
+ */
+ private static final int MAX_RANGE = 6; // safety
- /**
- * only Simple List needed.
- *
- * NOTE TO MAINTAINERS: THIS OBJECT DOES IT'S OWN SYNCHRONIZATION. All
- * changes that touch list must account for correctly synchronizing list.
- */
- private LinkedList<Pooled<T>> list;
+ /**
+ * only Simple List needed.
+ *
+ * NOTE TO MAINTAINERS: THIS OBJECT DOES IT'S OWN SYNCHRONIZATION. All
+ * changes that touch list must account for correctly synchronizing list.
+ */
+ private LinkedList<Pooled<T>> list;
- /**
- * keep track of how many elements exist, to avoid asking list.
- */
- private int count;
+ /**
+ * keep track of how many elements exist, to avoid asking list.
+ */
+ private int count;
- /**
- * Spares are those Object that are primed and ready to go.
- */
- private int spares;
+ /**
+ * Spares are those Object that are primed and ready to go.
+ */
+ private int spares;
- /**
- * Actual MAX number of spares allowed to hang around. Can be set to
- * something besides the default MAX_RANGE.
- */
- private int max_range = MAX_RANGE;
+ /**
+ * Actual MAX number of spares allowed to hang around. Can be set to
+ * something besides the default MAX_RANGE.
+ */
+ private int max_range = MAX_RANGE;
- /**
- * The Creator for this particular pool. It must work for type T.
- */
- private Creator<T> creator;
+ /**
+ * The Creator for this particular pool. It must work for type T.
+ */
+ private Creator<T> creator;
- /**
- * Create a new Pool, given the implementation of Creator<T>, which must be
- * able to create/destroy T objects at will.
- *
- * @param creator
- */
- public Pool(Creator<T> creator) {
- count = spares = 0;
- this.creator = creator;
- list = new LinkedList<>();
- }
+ /**
+ * Create a new Pool, given the implementation of Creator<T>, which must be
+ * able to create/destroy T objects at will.
+ *
+ * @param creator
+ */
+ public Pool(Creator<T> creator) {
+ count = spares = 0;
+ this.creator = creator;
+ list = new LinkedList<>();
+ }
- /**
- * Preallocate a certain number of T Objects. Useful for services so that
- * the first transactions don't get hit with all the Object creation costs
- *
- * @param lt
- * @param prime
- * @throws APIException
- */
- public void prime(LogTarget lt, int prime) throws APIException {
- for (int i = 0; i < prime; ++i) {
- Pooled<T> pt = new Pooled<T>(creator.create(), this, lt);
- synchronized (list) {
- list.addFirst(pt);
- ++count;
- }
- }
+ /**
+ * Preallocate a certain number of T Objects. Useful for services so that
+ * the first transactions don't get hit with all the Object creation costs
+ *
+ * @param lt
+ * @param prime
+ * @throws APIException
+ */
+ public void prime(LogTarget lt, int prime) throws APIException {
+ for (int i = 0; i < prime; ++i) {
+ Pooled<T> pt = new Pooled<T>(creator.create(), this, lt);
+ synchronized (list) {
+ list.addFirst(pt);
+ ++count;
+ }
+ }
- }
+ }
- /**
- * Destroy and remove all remaining objects. This is valuable for closing
- * down all Allocated objects cleanly for exiting. It is also a good method
- * for removing objects when, for instance, all Objects are invalid because
- * of broken connections, etc.
- */
- public void drain() {
- synchronized (list) {
- for (int i = 0; i < list.size(); ++i) {
- Pooled<T> pt = list.remove();
- creator.destroy(pt.content);
- pt.logTarget.log("Pool drained ", creator.toString());
- }
- count = spares = 0;
- }
+ /**
+ * Destroy and remove all remaining objects. This is valuable for closing
+ * down all Allocated objects cleanly for exiting. It is also a good method
+ * for removing objects when, for instance, all Objects are invalid because
+ * of broken connections, etc.
+ */
+ public void drain() {
+ synchronized (list) {
+ for (int i = 0; i < list.size(); ++i) {
+ Pooled<T> pt = list.remove();
+ creator.destroy(pt.content);
+ pt.logTarget.log("Pool drained ", creator.toString());
+ }
+ count = spares = 0;
+ }
- }
+ }
- /**
- * This is the essential function for Pool. Get an Object "T" inside a
- * "Pooled<T>" object. If there is a spare Object, then use it. If not, then
- * create and pass back.
- *
- * This one uses a Null LogTarget
- *
- * IMPORTANT: When the use of this object is done (and the object is still
- * in a valid state), then "done()" should be called immediately to allow
- * the object to be reused. That is the point of the Pool...
- *
- * If the Object is in an invalid state, then "toss()" should be used so the
- * Pool doesn't pass on invalid objects to others.
- *
- * @param lt
- * @return
- * @throws APIException
- */
- public Pooled<T> get() throws APIException {
- Pooled<T> pt;
- synchronized (list) {
- if (list.isEmpty()) {
- pt = null;
- } else {
- pt = list.removeLast();
- --count;
- creator.reuse(pt.content);
- }
- }
- if (pt == null) {
- if (spares < max_range)
- ++spares;
- pt = new Pooled<T>(creator.create(), this, LogTarget.NULL);
- } else {
- if (spares > 1)
- --spares;
- }
- return pt;
- }
+ /**
+ * This is the essential function for Pool. Get an Object "T" inside a
+ * "Pooled<T>" object. If there is a spare Object, then use it. If not, then
+ * create and pass back.
+ *
+ * This one uses a Null LogTarget
+ *
+ * IMPORTANT: When the use of this object is done (and the object is still
+ * in a valid state), then "done()" should be called immediately to allow
+ * the object to be reused. That is the point of the Pool...
+ *
+ * If the Object is in an invalid state, then "toss()" should be used so the
+ * Pool doesn't pass on invalid objects to others.
+ *
+ * @param lt
+ * @return
+ * @throws APIException
+ */
+ public Pooled<T> get() throws APIException {
+ Pooled<T> pt;
+ synchronized (list) {
+ if (list.isEmpty()) {
+ pt = null;
+ } else {
+ pt = list.removeLast();
+ --count;
+ creator.reuse(pt.content);
+ }
+ }
+ if (pt == null) {
+ if (spares < max_range)
+ ++spares;
+ pt = new Pooled<T>(creator.create(), this, LogTarget.NULL);
+ } else {
+ if (spares > 1)
+ --spares;
+ }
+ return pt;
+ }
- /**
- * This is the essential function for Pool. Get an Object "T" inside a
- * "Pooled<T>" object. If there is a spare Object, then use it. If not, then
- * create and pass back.
- *
- * If you don't have access to a LogTarget from Env, use LogTarget.NULL
- *
- * IMPORTANT: When the use of this object is done (and the object is still
- * in a valid state), then "done()" should be called immediately to allow
- * the object to be reused. That is the point of the Pool...
- *
- * If the Object is in an invalid state, then "toss()" should be used so the
- * Pool doesn't pass on invalid objects to others.
- *
- * @param lt
- * @return
- * @throws APIException
- */
- public Pooled<T> get(LogTarget lt) throws APIException {
- Pooled<T> pt;
- synchronized (list) {
- if (list.isEmpty()) {
- pt = null;
- } else {
- pt = list.remove();
- --count;
- creator.reuse(pt.content);
- }
- }
- if (pt == null) {
- if (spares < max_range)
- ++spares;
- pt = new Pooled<T>(creator.create(), this, lt);
- lt.log("Pool created ", creator.toString());
- } else {
- if (spares > 1)
- --spares;
- }
- return pt;
- }
+ /**
+ * This is the essential function for Pool. Get an Object "T" inside a
+ * "Pooled<T>" object. If there is a spare Object, then use it. If not, then
+ * create and pass back.
+ *
+ * If you don't have access to a LogTarget from Env, use LogTarget.NULL
+ *
+ * IMPORTANT: When the use of this object is done (and the object is still
+ * in a valid state), then "done()" should be called immediately to allow
+ * the object to be reused. That is the point of the Pool...
+ *
+ * If the Object is in an invalid state, then "toss()" should be used so the
+ * Pool doesn't pass on invalid objects to others.
+ *
+ * @param lt
+ * @return
+ * @throws APIException
+ */
+ public Pooled<T> get(LogTarget lt) throws APIException {
+ Pooled<T> pt;
+ synchronized (list) {
+ if (list.isEmpty()) {
+ pt = null;
+ } else {
+ pt = list.remove();
+ --count;
+ creator.reuse(pt.content);
+ }
+ }
+ if (pt == null) {
+ if (spares < max_range)
+ ++spares;
+ pt = new Pooled<T>(creator.create(), this, lt);
+ lt.log("Pool created ", creator.toString());
+ } else {
+ if (spares > 1)
+ --spares;
+ }
+ return pt;
+ }
- /**
- * This function will validate whether the Objects are still in a usable
- * state. If not, they are tossed from the Pool. This is valuable to have
- * when Remote Connections go down, and there is a question on whether the
- * Pooled Objects are still functional.
- *
- * @return
- */
- public boolean validate() {
- boolean rv = true;
- synchronized (list) {
- for (Pooled<T> t : list) {
- if (!creator.isValid(t.content)) {
- rv = false;
- t.toss();
- list.remove(t);
- }
- }
- }
- return rv;
- }
+ /**
+ * This function will validate whether the Objects are still in a usable
+ * state. If not, they are tossed from the Pool. This is valuable to have
+ * when Remote Connections go down, and there is a question on whether the
+ * Pooled Objects are still functional.
+ *
+ * @return
+ */
+ public boolean validate() {
+ boolean rv = true;
+ synchronized (list) {
+ for (Pooled<T> t : list) {
+ if (!creator.isValid(t.content)) {
+ rv = false;
+ t.toss();
+ list.remove(t);
+ }
+ }
+ }
+ return rv;
+ }
- /**
- * This is an internal method, used only by the Internal Pooled<T> class.
- *
- * The Pooled<T> class "offers" it's Object back after use. It is an
- * "offer", because Pool will simply destroy and remove the object if it has
- * more than enough spares.
- *
- * @param lt
- * @param used
- * @return
- */
- // Used only by Pooled<T>
- private boolean offer(LogTarget lt, Pooled<T> used) {
- if (count < spares) {
- synchronized (list) {
- list.addFirst(used);
- ++count;
- }
- lt.log("Pool recovered ", creator.toString());
- } else {
- lt.log("Pool destroyed ", creator.toString());
- creator.destroy(used.content);
- }
- return false;
- }
+ /**
+ * This is an internal method, used only by the Internal Pooled<T> class.
+ *
+ * The Pooled<T> class "offers" it's Object back after use. It is an
+ * "offer", because Pool will simply destroy and remove the object if it has
+ * more than enough spares.
+ *
+ * @param lt
+ * @param used
+ * @return
+ */
+ // Used only by Pooled<T>
+ private boolean offer(LogTarget lt, Pooled<T> used) {
+ if (count < spares) {
+ synchronized (list) {
+ list.addFirst(used);
+ ++count;
+ }
+ lt.log("Pool recovered ", creator.toString());
+ } else {
+ lt.log("Pool destroyed ", creator.toString());
+ creator.destroy(used.content);
+ }
+ return false;
+ }
- /**
- * The Creator Interface give the Pool the ability to Create, Destroy and
- * Validate the Objects it is maintaining. Thus, it is a specially written
- * Implementation for each type.
- *
- * @author Jonathan
- *
- * @param <T>
- */
- public interface Creator<T> {
- public T create() throws APIException;
+ /**
+ * The Creator Interface give the Pool the ability to Create, Destroy and
+ * Validate the Objects it is maintaining. Thus, it is a specially written
+ * Implementation for each type.
+ *
+ * @author Jonathan
+ *
+ * @param <T>
+ */
+ public interface Creator<T> {
+ public T create() throws APIException;
- public void destroy(T t);
+ public void destroy(T t);
- public boolean isValid(T t);
+ public boolean isValid(T t);
- public void reuse(T t);
- }
+ public void reuse(T t);
+ }
- /**
- * The "Pooled<T>" class is the transient class that wraps the actual Object
- * T for API use/ It gives the ability to return ("done()", or "toss()") the
- * Object to the Pool when processing is finished.
- *
- * For Safety, i.e. to avoid memory leaks and invalid Object States, there
- * is a "finalize" method. It is strictly for when coder forgets to return
- * the object, or perhaps hasn't covered the case during Exceptions or
- * Runtime Exceptions with finally (preferred). This should not be
- * considered normal procedure, as finalize() is called at an undetermined
- * time during garbage collection, and is thus rather useless for a Pool.
- * However, we don't want Coding Mistakes to put the whole program in an
- * invalid state, so if something happened such that "done()" or "toss()"
- * were not called, the resource is still cleaned up as well as possible.
- *
- * @author Jonathan
- *
- * @param <T>
- */
- public static class Pooled<T> {
- public final T content;
- private Pool<T> pool;
- protected LogTarget logTarget;
+ /**
+ * The "Pooled<T>" class is the transient class that wraps the actual Object
+ * T for API use/ It gives the ability to return ("done()", or "toss()") the
+ * Object to the Pool when processing is finished.
+ *
+ * For Safety, i.e. to avoid memory leaks and invalid Object States, there
+ * is a "finalize" method. It is strictly for when coder forgets to return
+ * the object, or perhaps hasn't covered the case during Exceptions or
+ * Runtime Exceptions with finally (preferred). This should not be
+ * considered normal procedure, as finalize() is called at an undetermined
+ * time during garbage collection, and is thus rather useless for a Pool.
+ * However, we don't want Coding Mistakes to put the whole program in an
+ * invalid state, so if something happened such that "done()" or "toss()"
+ * were not called, the resource is still cleaned up as well as possible.
+ *
+ * @author Jonathan
+ *
+ * @param <T>
+ */
+ public static class Pooled<T> {
+ public final T content;
+ private Pool<T> pool;
+ protected LogTarget logTarget;
- /**
- * Create the Wrapping Object Pooled<T>.
- *
- * @param t
- * @param pool
- * @param logTarget
- */
- public Pooled(T t, Pool<T> pool, LogTarget logTarget) {
- content = t;
- this.pool = pool;
- this.logTarget = logTarget;
- }
+ /**
+ * Create the Wrapping Object Pooled<T>.
+ *
+ * @param t
+ * @param pool
+ * @param logTarget
+ */
+ public Pooled(T t, Pool<T> pool, LogTarget logTarget) {
+ content = t;
+ this.pool = pool;
+ this.logTarget = logTarget;
+ }
- /**
- * This is the key API for the Pool, as calling "done()" offers this
- * object back to the Pool for reuse.
- *
- * Do not use the Pooled<T> object again after calling "done()".
- */
- public void done() {
- if (pool != null) {
- pool.offer(logTarget, this);
- }
- }
+ /**
+ * This is the key API for the Pool, as calling "done()" offers this
+ * object back to the Pool for reuse.
+ *
+ * Do not use the Pooled<T> object again after calling "done()".
+ */
+ public void done() {
+ if (pool != null) {
+ pool.offer(logTarget, this);
+ }
+ }
- /**
- * The user of the Object may discover that the Object t is no longer in
- * a valid state. Don't put Garbage back in the Refrigerator... Toss it,
- * if it's no longer valid.
- *
- * toss() is also used for draining the Pool, etc.
- *
- * toss() will attempt to destroy the Object by using the Creator
- * Interface.
- *
- */
- public void toss() {
- if (pool != null) {
- pool.creator.destroy(content);
- }
- // Don't allow finalize to put it back in.
- pool = null;
- }
+ /**
+ * The user of the Object may discover that the Object t is no longer in
+ * a valid state. Don't put Garbage back in the Refrigerator... Toss it,
+ * if it's no longer valid.
+ *
+ * toss() is also used for draining the Pool, etc.
+ *
+ * toss() will attempt to destroy the Object by using the Creator
+ * Interface.
+ *
+ */
+ public void toss() {
+ if (pool != null) {
+ pool.creator.destroy(content);
+ }
+ // Don't allow finalize to put it back in.
+ pool = null;
+ }
- /**
- * Just in case someone neglected to offer back object... Do not rely on
- * this, as there is no specific time when finalize is called, which
- * rather defeats the purpose of a Pool.
- */
- @Override
- protected void finalize() throws Throwable {
- if (pool != null) {
- done();
- pool = null;
- }
- }
- }
+ /**
+ * Just in case someone neglected to offer back object... Do not rely on
+ * this, as there is no specific time when finalize is called, which
+ * rather defeats the purpose of a Pool.
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ if (pool != null) {
+ done();
+ pool = null;
+ }
+ }
+ }
- /**
- * Get the maximum number of spare objects allowed at any moment
- *
- * @return
- */
- public int getMaxRange() {
- return max_range;
- }
+ /**
+ * Get the maximum number of spare objects allowed at any moment
+ *
+ * @return
+ */
+ public int getMaxRange() {
+ return max_range;
+ }
- /**
- * Set a Max Range for numbers of spare objects waiting to be used.
- *
- * No negative numbers are allowed
- *
- * @return
- */
- public void setMaxRange(int max_range) {
- // Do not allow negative numbers
- this.max_range = Math.max(0, max_range);
- }
+ /**
+ * Set a Max Range for numbers of spare objects waiting to be used.
+ *
+ * No negative numbers are allowed
+ *
+ * @return
+ */
+ public void setMaxRange(int max_range) {
+ // Do not allow negative numbers
+ this.max_range = Math.max(0, max_range);
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java
index 6892a4b5..759a8c8b 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java
@@ -54,71 +54,71 @@ import org.onap.aaf.misc.env.LifeCycle;
* @param <T>
*/
public class RefreshableThreadObject<T extends Creatable<T>> {
- private Map<Thread,T> objs;
- private long refreshed;
- private Constructor<T> cnst;
-
- /**
- * The passed in class <b>must</b> implement the constructor
- * <pre>
- * public MyClass(Env env) {
- * ...
- * }
- * </pre>
- * @param clss
- * @throws APIException
- */
- public RefreshableThreadObject(Class<T> clss) throws APIException {
- objs = new ConcurrentHashMap<>();
- try {
- cnst = clss.getConstructor(new Class[]{Env.class} );
- } catch (Exception e) {
- throw new APIException(e);
- }
- }
-
- /**
- * Get the "T" class from the current thread
- *
- * @param env
- * @return T
- * @throws APIException
- */
- public T get(Env env) throws APIException {
- Thread t = Thread.currentThread();
- T obj = objs.get(t);
- if(obj==null || refreshed>obj.created()) {
- try {
- obj = cnst.newInstance(new Object[]{env});
- } catch (InvocationTargetException e) {
- throw new APIException(e.getTargetException());
- } catch (Exception e) {
- throw new APIException(e);
- }
- T destroyMe = objs.put(t,obj);
- if(destroyMe!=null) {
- destroyMe.destroy(env);
- }
- }
- return obj;
- }
-
- /**
- * Mark the timestamp of refreshed.
- *
- * @param env
- */
- public void refresh(Env env) {
- refreshed = System.currentTimeMillis();
- }
-
- /**
- * Remove the object from the Thread instances
- * @param env
- */
- public void remove(Env env) {
- T obj = objs.remove(Thread.currentThread());
- if(obj!=null)
- obj.destroy(env);
- }
+ private Map<Thread,T> objs;
+ private long refreshed;
+ private Constructor<T> cnst;
+
+ /**
+ * The passed in class <b>must</b> implement the constructor
+ * <pre>
+ * public MyClass(Env env) {
+ * ...
+ * }
+ * </pre>
+ * @param clss
+ * @throws APIException
+ */
+ public RefreshableThreadObject(Class<T> clss) throws APIException {
+ objs = new ConcurrentHashMap<>();
+ try {
+ cnst = clss.getConstructor(new Class[]{Env.class} );
+ } catch (Exception e) {
+ throw new APIException(e);
+ }
+ }
+
+ /**
+ * Get the "T" class from the current thread
+ *
+ * @param env
+ * @return T
+ * @throws APIException
+ */
+ public T get(Env env) throws APIException {
+ Thread t = Thread.currentThread();
+ T obj = objs.get(t);
+ if(obj==null || refreshed>obj.created()) {
+ try {
+ obj = cnst.newInstance(new Object[]{env});
+ } catch (InvocationTargetException e) {
+ throw new APIException(e.getTargetException());
+ } catch (Exception e) {
+ throw new APIException(e);
+ }
+ T destroyMe = objs.put(t,obj);
+ if(destroyMe!=null) {
+ destroyMe.destroy(env);
+ }
+ }
+ return obj;
+ }
+
+ /**
+ * Mark the timestamp of refreshed.
+ *
+ * @param env
+ */
+ public void refresh(Env env) {
+ refreshed = System.currentTimeMillis();
+ }
+
+ /**
+ * Remove the object from the Thread instances
+ * @param env
+ */
+ public void remove(Env env) {
+ T obj = objs.remove(Thread.currentThread());
+ if(obj!=null)
+ obj.destroy(env);
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java
index efb68120..4069c329 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java
@@ -30,73 +30,73 @@ package org.onap.aaf.misc.env.util;
*/
public class Split {
- private static final String[] BLANK = new String[0];
-
- public static String[] split(char c, String value) {
- if(value==null) {
- return BLANK;
- }
+ private static final String[] BLANK = new String[0];
+
+ public static String[] split(char c, String value) {
+ if(value==null) {
+ return BLANK;
+ }
- // Count items to preallocate Array (memory alloc is more expensive than counting twice)
- int count,idx;
- for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count);
- String[] rv = new String[count];
- if(count==1) {
- rv[0]=value;
- } else {
- int last=0;
- count=-1;
- for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) {
- rv[++count]=value.substring(last,idx);
- last = ++idx;
- }
- rv[++count]=value.substring(last);
- }
- return rv;
- }
+ // Count items to preallocate Array (memory alloc is more expensive than counting twice)
+ int count,idx;
+ for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count);
+ String[] rv = new String[count];
+ if(count==1) {
+ rv[0]=value;
+ } else {
+ int last=0;
+ count=-1;
+ for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) {
+ rv[++count]=value.substring(last,idx);
+ last = ++idx;
+ }
+ rv[++count]=value.substring(last);
+ }
+ return rv;
+ }
- public static String[] splitTrim(char c, String value) {
- if(value==null) {
- return BLANK;
- }
- // Count items to preallocate Array (memory alloc is more expensive than counting twice)
- int count,idx;
- for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count);
- String[] rv = new String[count];
- if(count==1) {
- rv[0]=value.trim();
- } else {
- int last=0;
- count=-1;
- for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) {
- rv[++count]=value.substring(last,idx).trim();
- last = ++idx;
- }
- rv[++count]=value.substring(last).trim();
- }
- return rv;
- }
+ public static String[] splitTrim(char c, String value) {
+ if(value==null) {
+ return BLANK;
+ }
+ // Count items to preallocate Array (memory alloc is more expensive than counting twice)
+ int count,idx;
+ for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count);
+ String[] rv = new String[count];
+ if(count==1) {
+ rv[0]=value.trim();
+ } else {
+ int last=0;
+ count=-1;
+ for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) {
+ rv[++count]=value.substring(last,idx).trim();
+ last = ++idx;
+ }
+ rv[++count]=value.substring(last).trim();
+ }
+ return rv;
+ }
- public static String[] splitTrim(char c, String value, int size) {
- if(value==null) {
- return BLANK;
- }
+ public static String[] splitTrim(char c, String value, int size) {
+ if(value==null) {
+ return BLANK;
+ }
- int idx;
- String[] rv = new String[size];
- if(size==1) {
- rv[0]=value.trim();
- } else {
- int last=0;
- int count=-1;
- size-=2;
- for(idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
- rv[++count]=value.substring(last,idx).trim();
- last = ++idx;
- }
- rv[++count]=value.substring(last).trim();
- }
- return rv;
- }
+ int idx;
+ String[] rv = new String[size];
+ if(size==1) {
+ rv[0]=value.trim();
+ } else {
+ int last=0;
+ int count=-1;
+ size-=2;
+ for(idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
+ rv[++count]=value.substring(last,idx).trim();
+ last = ++idx;
+ }
+ rv[++count]=value.substring(last).trim();
+ }
+ return rv;
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java
index f0885069..c512b09a 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java
@@ -25,7 +25,7 @@ import java.io.IOException;
import java.io.OutputStream;
public class StringBuilderOutputStream extends OutputStream {
- private StringBuilder buf;
+ private StringBuilder buf;
/**
@@ -33,7 +33,7 @@ public class StringBuilderOutputStream extends OutputStream {
* size.
*/
public StringBuilderOutputStream() {
- buf = new StringBuilder();
+ buf = new StringBuilder();
}
/**
@@ -41,7 +41,7 @@ public class StringBuilderOutputStream extends OutputStream {
* size.
*/
public StringBuilderOutputStream(StringBuilder sb) {
- buf = sb;
+ buf = sb;
}
/**
@@ -56,17 +56,17 @@ public class StringBuilderOutputStream extends OutputStream {
* If <tt>initialSize</tt> is negative
*/
public StringBuilderOutputStream(int initialSize) {
- if (initialSize < 0) {
- throw new IllegalArgumentException("Negative buffer size");
- }
- buf = new StringBuilder(initialSize);
+ if (initialSize < 0) {
+ throw new IllegalArgumentException("Negative buffer size");
+ }
+ buf = new StringBuilder(initialSize);
}
/**
* Write a single character.
*/
public void write(int c) {
- buf.append((byte) c);
+ buf.append((byte) c);
}
/**
@@ -88,15 +88,15 @@ public class StringBuilderOutputStream extends OutputStream {
}
@Override
- public void write(byte[] b) throws IOException {
- buf.append(new String(b));
- }
+ public void write(byte[] b) throws IOException {
+ buf.append(new String(b));
+ }
- /**
+ /**
* Write a string.
*/
public void write(String str) {
- buf.append(str);
+ buf.append(str);
}
/**
@@ -107,23 +107,23 @@ public class StringBuilderOutputStream extends OutputStream {
* @param len Number of characters to write
*/
public void write(String str, int off, int len) {
- buf.append(str,off,len);
+ buf.append(str,off,len);
}
public StringBuilderOutputStream append(CharSequence csq) {
- if (csq == null) {
- write("null");
- } else {
- for(int i = 0;i<csq.length();++i) {
- buf.append(csq.charAt(i));
- }
- }
- return this;
+ if (csq == null) {
+ write("null");
+ } else {
+ for(int i = 0;i<csq.length();++i) {
+ buf.append(csq.charAt(i));
+ }
+ }
+ return this;
}
public StringBuilderOutputStream append(CharSequence csq, int start, int end) {
- CharSequence cs = (csq == null ? "null" : csq);
- return append(cs.subSequence(start, end));
+ CharSequence cs = (csq == null ? "null" : csq);
+ return append(cs.subSequence(start, end));
}
/**
@@ -143,15 +143,15 @@ public class StringBuilderOutputStream extends OutputStream {
* @since 1.5
*/
public StringBuilderOutputStream append(byte c) {
- buf.append(c);
- return this;
+ buf.append(c);
+ return this;
}
/**
* Return the buffer's current value as a string.
*/
public String toString() {
- return buf.toString();
+ return buf.toString();
}
/**
@@ -160,19 +160,19 @@ public class StringBuilderOutputStream extends OutputStream {
* @return StringBuffer holding the current buffer value.
*/
public StringBuilder getBuffer() {
- return buf;
+ return buf;
}
public void reset() {
- buf.setLength(0);
+ buf.setLength(0);
}
- @Override
- public void flush() throws IOException {
- }
+ @Override
+ public void flush() throws IOException {
+ }
- @Override
- public void close() throws IOException {
- }
+ @Override
+ public void close() throws IOException {
+ }
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java
index 467598b7..753e4ca7 100644
--- a/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java
+++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java
@@ -25,7 +25,7 @@ import java.io.IOException;
import java.io.Writer;
public class StringBuilderWriter extends Writer {
- private StringBuilder buf;
+ private StringBuilder buf;
/**
@@ -33,7 +33,7 @@ public class StringBuilderWriter extends Writer {
* size.
*/
public StringBuilderWriter() {
- buf = new StringBuilder();
+ buf = new StringBuilder();
}
/**
@@ -41,7 +41,7 @@ public class StringBuilderWriter extends Writer {
* size.
*/
public StringBuilderWriter(StringBuilder sb) {
- buf = sb;
+ buf = sb;
}
/**
@@ -56,17 +56,17 @@ public class StringBuilderWriter extends Writer {
* If <tt>initialSize</tt> is negative
*/
public StringBuilderWriter(int initialSize) {
- if (initialSize < 0) {
- throw new IllegalArgumentException("Negative buffer size");
- }
- buf = new StringBuilder(initialSize);
+ if (initialSize < 0) {
+ throw new IllegalArgumentException("Negative buffer size");
+ }
+ buf = new StringBuilder(initialSize);
}
/**
* Write a single character.
*/
public void write(int c) {
- buf.append((char) c);
+ buf.append((char) c);
}
/**
@@ -90,7 +90,7 @@ public class StringBuilderWriter extends Writer {
* Write a string.
*/
public void write(String str) {
- buf.append(str);
+ buf.append(str);
}
/**
@@ -101,23 +101,23 @@ public class StringBuilderWriter extends Writer {
* @param len Number of characters to write
*/
public void write(String str, int off, int len) {
- char[] chars = new char[len];
- str.getChars(off, off+len, chars, 0);
- buf.append(chars);
+ char[] chars = new char[len];
+ str.getChars(off, off+len, chars, 0);
+ buf.append(chars);
}
public StringBuilderWriter append(CharSequence csq) {
- if (csq == null) {
- write("null");
- } else {
- buf.append(csq);
- }
- return this;
+ if (csq == null) {
+ write("null");
+ } else {
+ buf.append(csq);
+ }
+ return this;
}
public StringBuilderWriter append(CharSequence csq, int start, int end) {
- CharSequence cs = (csq == null ? "null" : csq);
- return append(cs.subSequence(start, end));
+ CharSequence cs = (csq == null ? "null" : csq);
+ return append(cs.subSequence(start, end));
}
/**
@@ -137,15 +137,15 @@ public class StringBuilderWriter extends Writer {
* @since 1.5
*/
public StringBuilderWriter append(char c) {
- buf.append(c);
- return this;
+ buf.append(c);
+ return this;
}
/**
* Return the buffer's current value as a string.
*/
public String toString() {
- return buf.toString();
+ return buf.toString();
}
/**
@@ -154,19 +154,19 @@ public class StringBuilderWriter extends Writer {
* @return StringBuffer holding the current buffer value.
*/
public StringBuilder getBuffer() {
- return buf;
+ return buf;
}
public void reset() {
- buf.setLength(0);
+ buf.setLength(0);
}
- @Override
- public void flush() throws IOException {
- }
+ @Override
+ public void flush() throws IOException {
+ }
- @Override
- public void close() throws IOException {
- }
+ @Override
+ public void close() throws IOException {
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java
index b0c60878..c1d7f6b1 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java
@@ -27,45 +27,45 @@ import org.junit.Test;
public class JU_APIExceptionTest {
- private static final String EXCEPTION_MESSAGE = "New API Exception for test";
+ private static final String EXCEPTION_MESSAGE = "New API Exception for test";
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void testNewAPIExceptionWithMessage() {
- APIException exception = new APIException(EXCEPTION_MESSAGE);
+ @Test
+ public void testNewAPIExceptionWithMessage() {
+ APIException exception = new APIException(EXCEPTION_MESSAGE);
- assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
- }
+ assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
+ }
- @Test
- public void testNewAPIExceptionCreatedWithMessageAndThrowable() {
- Throwable throwable = new Throwable();
- APIException exception = new APIException(EXCEPTION_MESSAGE, throwable);
+ @Test
+ public void testNewAPIExceptionCreatedWithMessageAndThrowable() {
+ Throwable throwable = new Throwable();
+ APIException exception = new APIException(EXCEPTION_MESSAGE, throwable);
- assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
- assertEquals(exception.getCause(), throwable);
- }
+ assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
+ assertEquals(exception.getCause(), throwable);
+ }
- @Test
- public void testNewAPIExceptionCreatedWithThrowable() {
- Throwable throwable = new Throwable();
- APIException exception = new APIException(throwable);
+ @Test
+ public void testNewAPIExceptionCreatedWithThrowable() {
+ Throwable throwable = new Throwable();
+ APIException exception = new APIException(throwable);
- assertEquals(exception.getCause(), throwable);
- }
+ assertEquals(exception.getCause(), throwable);
+ }
- @Test
- public void testPayloadSetter() {
- Throwable throwable = new Throwable();
- Object payload = new Object();
+ @Test
+ public void testPayloadSetter() {
+ Throwable throwable = new Throwable();
+ Object payload = new Object();
- APIException exception = new APIException(throwable);
+ APIException exception = new APIException(throwable);
- exception.setPayload(payload);
+ exception.setPayload(payload);
- assertEquals(exception.getPayload(), payload);
- }
+ assertEquals(exception.getPayload(), payload);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java
index 6a090167..0525bd66 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java
@@ -33,77 +33,77 @@ import org.onap.aaf.misc.env.impl.BasicTrans;
@RunWith(MockitoJUnitRunner.class)
public class JU_BasicTransTest {
- BasicTrans trans = null;
-
- @Mock
- private EnvJAXB env;
-
- @Mock
- private TimeTaken timeTaken;
-
- @Before
- public void setUp() throws Exception {
- trans = new BasicTrans(env);
- }
-
- @Test
- public void testSlot() {
- Slot slot = new Slot(1, "XML");
- when(env.slot("XML")).thenReturn(slot);
-
- Slot outputSlot = trans.slot("XML");
- Object[] state = new Object[2];
-
- slot.put(state, "JSON");
-
- assertEquals(slot.get(state), "JSON");
- assertEquals(slot.getKey(), outputSlot.getKey());
- assertEquals(slot.toString(), outputSlot.toString());
- }
-
- @Test
- public void testGetStaticSlot() {
- StaticSlot staticSlot = new StaticSlot(1, "XML");
- when(env.get(staticSlot)).thenReturn(staticSlot.toString());
-
- assertEquals(staticSlot.toString(), trans.get(staticSlot));
- }
-
- @Test
- public void testGetStaticSlotWithT() {
- StaticSlot staticSlot = new StaticSlot(1, "XML");
- when(env.get(staticSlot, "XML")).thenReturn(staticSlot.getKey());
-
- assertEquals(staticSlot.getKey(), trans.get(staticSlot, "XML"));
- }
-
- @Test
- public void testSetProperty() {
- String tag = "tag";
- String value = "value";
- String defltValue = "diffValue";
- when(env.setProperty(tag, value)).thenReturn(value);
- when(env.getProperty(tag)).thenReturn(value);
- when(env.getProperty(tag, defltValue)).thenReturn(defltValue);
-
- assertEquals(value, trans.setProperty(tag, value));
- assertEquals(value, trans.getProperty(tag));
- assertEquals(defltValue, trans.getProperty(tag, defltValue));
- }
-
- @Test
- public void testDecryptor() {
- when(env.decryptor()).thenReturn(Decryptor.NULL);
-
- assertEquals(Decryptor.NULL, trans.decryptor());
- assertEquals("tag", trans.decryptor().decrypt("tag"));
- }
-
- @Test
- public void testEncryptor() {
- when(env.encryptor()).thenReturn(Encryptor.NULL);
-
- assertEquals(Encryptor.NULL, trans.encryptor());
- assertEquals("tag", trans.encryptor().encrypt("tag"));
- }
+ BasicTrans trans = null;
+
+ @Mock
+ private EnvJAXB env;
+
+ @Mock
+ private TimeTaken timeTaken;
+
+ @Before
+ public void setUp() throws Exception {
+ trans = new BasicTrans(env);
+ }
+
+ @Test
+ public void testSlot() {
+ Slot slot = new Slot(1, "XML");
+ when(env.slot("XML")).thenReturn(slot);
+
+ Slot outputSlot = trans.slot("XML");
+ Object[] state = new Object[2];
+
+ slot.put(state, "JSON");
+
+ assertEquals(slot.get(state), "JSON");
+ assertEquals(slot.getKey(), outputSlot.getKey());
+ assertEquals(slot.toString(), outputSlot.toString());
+ }
+
+ @Test
+ public void testGetStaticSlot() {
+ StaticSlot staticSlot = new StaticSlot(1, "XML");
+ when(env.get(staticSlot)).thenReturn(staticSlot.toString());
+
+ assertEquals(staticSlot.toString(), trans.get(staticSlot));
+ }
+
+ @Test
+ public void testGetStaticSlotWithT() {
+ StaticSlot staticSlot = new StaticSlot(1, "XML");
+ when(env.get(staticSlot, "XML")).thenReturn(staticSlot.getKey());
+
+ assertEquals(staticSlot.getKey(), trans.get(staticSlot, "XML"));
+ }
+
+ @Test
+ public void testSetProperty() {
+ String tag = "tag";
+ String value = "value";
+ String defltValue = "diffValue";
+ when(env.setProperty(tag, value)).thenReturn(value);
+ when(env.getProperty(tag)).thenReturn(value);
+ when(env.getProperty(tag, defltValue)).thenReturn(defltValue);
+
+ assertEquals(value, trans.setProperty(tag, value));
+ assertEquals(value, trans.getProperty(tag));
+ assertEquals(defltValue, trans.getProperty(tag, defltValue));
+ }
+
+ @Test
+ public void testDecryptor() {
+ when(env.decryptor()).thenReturn(Decryptor.NULL);
+
+ assertEquals(Decryptor.NULL, trans.decryptor());
+ assertEquals("tag", trans.decryptor().decrypt("tag"));
+ }
+
+ @Test
+ public void testEncryptor() {
+ when(env.encryptor()).thenReturn(Encryptor.NULL);
+
+ assertEquals(Encryptor.NULL, trans.encryptor());
+ assertEquals("tag", trans.encryptor().encrypt("tag"));
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java
index 474f646c..caaca1d1 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java
@@ -34,54 +34,54 @@ import org.mockito.Mock;
public class JU_LogTargetTest {
- @Mock
- Throwable t;
+ @Mock
+ Throwable t;
- @Before
- public void setup() {
- t = mock(Throwable.class);
- }
+ @Before
+ public void setup() {
+ t = mock(Throwable.class);
+ }
- @Test
- public void testLogTargetNull() {
- LogTarget nullTarget = LogTarget.NULL;
+ @Test
+ public void testLogTargetNull() {
+ LogTarget nullTarget = LogTarget.NULL;
- // Expect methods doing nothing as no implemenation provided.
- nullTarget.log(new Throwable(), null, null);
- nullTarget.log("String", null);
- nullTarget.printf(null, null, null);
+ // Expect methods doing nothing as no implemenation provided.
+ nullTarget.log(new Throwable(), null, null);
+ nullTarget.log("String", null);
+ nullTarget.printf(null, null, null);
- assertFalse(nullTarget.isLoggable());
- }
+ assertFalse(nullTarget.isLoggable());
+ }
- @Test
- public void testLogTargetSysOut() {
- LogTarget outTarget = LogTarget.SYSOUT;
+ @Test
+ public void testLogTargetSysOut() {
+ LogTarget outTarget = LogTarget.SYSOUT;
- outTarget.printf("format", new Date());
- outTarget.log("null", null, null);
+ outTarget.printf("format", new Date());
+ outTarget.log("null", null, null);
- outTarget.log(t);
- outTarget.log(t, "First String Object");
+ outTarget.log(t);
+ outTarget.log(t, "First String Object");
- assertTrue(outTarget.isLoggable());
+ assertTrue(outTarget.isLoggable());
- verify(t, times(2)).printStackTrace(System.out);
- }
+ verify(t, times(2)).printStackTrace(System.out);
+ }
- @Test
- public void testLogTargetSysErr() {
- LogTarget errTarget = LogTarget.SYSERR;
+ @Test
+ public void testLogTargetSysErr() {
+ LogTarget errTarget = LogTarget.SYSERR;
- errTarget.printf("format", new Date());
- errTarget.log("null", "null");
+ errTarget.printf("format", new Date());
+ errTarget.log("null", "null");
- errTarget.log(t);
- errTarget.log(t, "First String Object");
+ errTarget.log(t);
+ errTarget.log(t, "First String Object");
- assertTrue(errTarget.isLoggable());
+ assertTrue(errTarget.isLoggable());
- verify(t, times(2)).printStackTrace(System.err);
- }
+ verify(t, times(2)).printStackTrace(System.err);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java
index 65dc7c50..b15972ef 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java
@@ -40,141 +40,141 @@ import org.onap.aaf.misc.env.TimeTaken;
public class JU_BasicEnvTest {
- @Mock
- Decryptor decrypt;
+ @Mock
+ Decryptor decrypt;
- @Mock
- Encryptor encrypt;
+ @Mock
+ Encryptor encrypt;
- @Before
- public void setup() {
- decrypt = mock(Decryptor.class);
- encrypt = mock(Encryptor.class);
- }
+ @Before
+ public void setup() {
+ decrypt = mock(Decryptor.class);
+ encrypt = mock(Encryptor.class);
+ }
- @Test
- public void testLogTarget() {
- Properties prop = new Properties();
- BasicEnv env = new BasicEnv(prop);
+ @Test
+ public void testLogTarget() {
+ Properties prop = new Properties();
+ BasicEnv env = new BasicEnv(prop);
- assertEquals(env.fatal(), LogTarget.SYSERR);
- assertEquals(env.error(), LogTarget.SYSERR);
- assertEquals(env.audit(), LogTarget.SYSOUT);
- assertEquals(env.warn(), LogTarget.SYSERR);
- assertEquals(env.init(), LogTarget.SYSOUT);
- assertEquals(env.info(), LogTarget.SYSOUT);
- assertEquals(env.debug(), LogTarget.NULL);
- assertEquals(env.trace(), LogTarget.NULL);
+ assertEquals(env.fatal(), LogTarget.SYSERR);
+ assertEquals(env.error(), LogTarget.SYSERR);
+ assertEquals(env.audit(), LogTarget.SYSOUT);
+ assertEquals(env.warn(), LogTarget.SYSERR);
+ assertEquals(env.init(), LogTarget.SYSOUT);
+ assertEquals(env.info(), LogTarget.SYSOUT);
+ assertEquals(env.debug(), LogTarget.NULL);
+ assertEquals(env.trace(), LogTarget.NULL);
- env.debug(LogTarget.SYSOUT);
- assertEquals(env.debug(), LogTarget.SYSOUT);
+ env.debug(LogTarget.SYSOUT);
+ assertEquals(env.debug(), LogTarget.SYSOUT);
- assertNull(env.getProperty("key"));
- assertEquals("default", env.getProperty("key", "default"));
+ assertNull(env.getProperty("key"));
+ assertEquals("default", env.getProperty("key", "default"));
- env.setProperty("key", "value");
- assertEquals("value", env.getProperty("key", "default"));
+ env.setProperty("key", "value");
+ assertEquals("value", env.getProperty("key", "default"));
- Properties filteredProperties = env.getProperties("key");
- assertEquals(filteredProperties.size(), 1);
+ Properties filteredProperties = env.getProperties("key");
+ assertEquals(filteredProperties.size(), 1);
- env.setProperty("key", null);
- assertEquals("default", env.getProperty("key", "default"));
+ env.setProperty("key", null);
+ assertEquals("default", env.getProperty("key", "default"));
- filteredProperties = env.getProperties("key1");
- assertEquals(filteredProperties.size(), 0);
+ filteredProperties = env.getProperties("key1");
+ assertEquals(filteredProperties.size(), 0);
- filteredProperties = env.getProperties();
- assertEquals(filteredProperties.size(), 0);
+ filteredProperties = env.getProperties();
+ assertEquals(filteredProperties.size(), 0);
- }
+ }
- @Test
- public void testBasicEnv() {
- Applet applet = null;
+ @Test
+ public void testBasicEnv() {
+ Applet applet = null;
- BasicEnv env = new BasicEnv(applet, "tag1", "tag2");
+ BasicEnv env = new BasicEnv(applet, "tag1", "tag2");
- TimeTaken tt = env.start("Name", 2);
+ TimeTaken tt = env.start("Name", 2);
- long end = tt.end();
- StringBuilder sb = new StringBuilder();
+ long end = tt.end();
+ StringBuilder sb = new StringBuilder();
- assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
- tt.output(sb);
- assertEquals(sb.toString(), "XML Name " + (end - tt.start) / 1000000f + "ms");
+ assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
+ tt.output(sb);
+ assertEquals(sb.toString(), "XML Name " + (end - tt.start) / 1000000f + "ms");
- env.set(decrypt);
- assertEquals(env.decryptor(), decrypt);
- env.set(encrypt);
- assertEquals(env.encryptor(), encrypt);
- }
+ env.set(decrypt);
+ assertEquals(env.decryptor(), decrypt);
+ env.set(encrypt);
+ assertEquals(env.encryptor(), encrypt);
+ }
- @Test
- public void testBasicEnvDiffFlag() {
- Properties prop = new Properties();
+ @Test
+ public void testBasicEnvDiffFlag() {
+ Properties prop = new Properties();
- BasicEnv env = new BasicEnv("tag1", prop);
+ BasicEnv env = new BasicEnv("tag1", prop);
- TimeTaken tt = env.start("Name", 1);
+ TimeTaken tt = env.start("Name", 1);
- long end = tt.end();
- StringBuilder sb = new StringBuilder();
+ long end = tt.end();
+ StringBuilder sb = new StringBuilder();
- assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
- tt.output(sb);
- assertEquals(sb.toString(), "REMOTE Name " + (end - tt.start) / 1000000f + "ms");
+ assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
+ tt.output(sb);
+ assertEquals(sb.toString(), "REMOTE Name " + (end - tt.start) / 1000000f + "ms");
- tt = env.start("New Name", 4);
- tt.size(10);
- sb = new StringBuilder();
- tt.output(sb);
- assertEquals(tt.toString(), "New Name " + (end - tt.start) / 1000000f + "ms 10");
- assertEquals(sb.toString(), "JSON New Name " + (end - tt.start) / 1000000f + "ms size: 10");
+ tt = env.start("New Name", 4);
+ tt.size(10);
+ sb = new StringBuilder();
+ tt.output(sb);
+ assertEquals(tt.toString(), "New Name " + (end - tt.start) / 1000000f + "ms 10");
+ assertEquals(sb.toString(), "JSON New Name " + (end - tt.start) / 1000000f + "ms size: 10");
- env.staticSlot("tag", "prop");
+ env.staticSlot("tag", "prop");
- if (System.getProperties().keySet().iterator().hasNext()) {
- String key = (String) System.getProperties().keySet().iterator().next();
+ if (System.getProperties().keySet().iterator().hasNext()) {
+ String key = (String) System.getProperties().keySet().iterator().next();
- env.loadFromSystemPropsStartsWith(key);
- assertEquals(env.getProperty(key), System.getProperties().get(key));
- }
+ env.loadFromSystemPropsStartsWith(key);
+ assertEquals(env.getProperty(key), System.getProperties().get(key));
+ }
- BasicTrans trans = env.newTrans();
- assertEquals(trans.delegate, env);
+ BasicTrans trans = env.newTrans();
+ assertEquals(trans.delegate, env);
- }
+ }
- @Test
- public void testLoadProperties() throws IOException {
- Properties prop = new Properties();
+ @Test
+ public void testLoadProperties() throws IOException {
+ Properties prop = new Properties();
- BasicEnv env = new BasicEnv("tag1", prop);
+ BasicEnv env = new BasicEnv("tag1", prop);
- env.loadPropFiles("tag1", null);
- env.setProperty("tag1", "propfile.properties");
- env.loadPropFiles("tag1", null);
+ env.loadPropFiles("tag1", null);
+ env.setProperty("tag1", "propfile.properties");
+ env.loadPropFiles("tag1", null);
- assertEquals(env.getProperty("prop1"), "New Property");
+ assertEquals(env.getProperty("prop1"), "New Property");
- env.loadToSystemPropsStartsWith("prop1");
+ env.loadToSystemPropsStartsWith("prop1");
- assertTrue(System.getProperties().keySet().contains("prop1"));
- assertEquals(System.getProperties().get("prop1"), "New Property");
- }
+ assertTrue(System.getProperties().keySet().contains("prop1"));
+ assertEquals(System.getProperties().get("prop1"), "New Property");
+ }
- @After
- public void tearDown() throws IOException {
- /*
- * File file = new File("./log-Append" + ending + "_0.log"); if (file.exists())
- * { Files.delete(Paths.get(file.getAbsolutePath())); } file = new
- * File("./log-Append" + ending + "_1.log"); if (file.exists()) {
- * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
- * + ending + "_0.log"); if (file.exists()) {
- * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
- * + ending + "_1.log"); if (file.exists()) {
- * Files.delete(Paths.get(file.getAbsolutePath())); }
- */
- }
+ @After
+ public void tearDown() throws IOException {
+ /*
+ * File file = new File("./log-Append" + ending + "_0.log"); if (file.exists())
+ * { Files.delete(Paths.get(file.getAbsolutePath())); } file = new
+ * File("./log-Append" + ending + "_1.log"); if (file.exists()) {
+ * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
+ * + ending + "_0.log"); if (file.exists()) {
+ * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
+ * + ending + "_1.log"); if (file.exists()) {
+ * Files.delete(Paths.get(file.getAbsolutePath())); }
+ */
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java
index f6c6912d..e5d0ed52 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java
@@ -31,49 +31,49 @@ import org.onap.aaf.misc.env.TransJAXB;
public class JU_EnvFactoryTest {
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void testSingleton() {
- BasicEnv singleton = EnvFactory.singleton();
+ @Test
+ public void testSingleton() {
+ BasicEnv singleton = EnvFactory.singleton();
- assertEquals(EnvFactory.singleton, singleton);
- }
+ assertEquals(EnvFactory.singleton, singleton);
+ }
- @Test
- public void testSetSingleton() {
- String[] str = { "argument1" };
- BasicEnv env = new BasicEnv("tag", str);
- EnvFactory.setSingleton(env);
+ @Test
+ public void testSetSingleton() {
+ String[] str = { "argument1" };
+ BasicEnv env = new BasicEnv("tag", str);
+ EnvFactory.setSingleton(env);
- assertEquals(EnvFactory.singleton(), env);
- }
+ assertEquals(EnvFactory.singleton(), env);
+ }
- @Test
- public void testNewTrans() {
- TransJAXB newTrans = EnvFactory.newTrans();
+ @Test
+ public void testNewTrans() {
+ TransJAXB newTrans = EnvFactory.newTrans();
- assertTrue(newTrans instanceof BasicTrans);
- }
+ assertTrue(newTrans instanceof BasicTrans);
+ }
- @Test
- public void testNewTransEnvJAXB() {
- EnvJAXB env = new BasicEnv("");
+ @Test
+ public void testNewTransEnvJAXB() {
+ EnvJAXB env = new BasicEnv("");
- TransJAXB trans = EnvFactory.newTrans(env);
+ TransJAXB trans = EnvFactory.newTrans(env);
- assertTrue(trans instanceof BasicTrans);
- }
+ assertTrue(trans instanceof BasicTrans);
+ }
- @Test
- public void testTransCreator() {
- TransCreate<TransJAXB> transCreator = EnvFactory.transCreator();
+ @Test
+ public void testTransCreator() {
+ TransCreate<TransJAXB> transCreator = EnvFactory.transCreator();
- TransJAXB newTrans = transCreator.newTrans();
+ TransJAXB newTrans = transCreator.newTrans();
- assertTrue(newTrans instanceof BasicTrans);
- }
+ assertTrue(newTrans instanceof BasicTrans);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
index e3f54929..914a01b0 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
@@ -40,23 +40,23 @@ import org.powermock.modules.junit4.PowerMockRunner;
@PrepareForTest({ Log4JLogTarget.class, Logger.class })
public class JU_Log4JLogTargetTest {
- @Mock
- Logger log;
+ @Mock
+ Logger log;
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- PowerMockito.mockStatic(Logger.class);
- when(Logger.getLogger("Info")).thenReturn(log);
- when(log.isEnabledFor(Level.DEBUG)).thenReturn(false);
- }
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(Logger.class);
+ when(Logger.getLogger("Info")).thenReturn(log);
+ when(log.isEnabledFor(Level.DEBUG)).thenReturn(false);
+ }
- @Test
- public void test() throws APIException {
- Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);
- Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);
+ @Test
+ public void test() throws APIException {
+ Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);
+ Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);
- assertFalse(target1.isLoggable());
+ assertFalse(target1.isLoggable());
- }
+ }
} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java
index 80de9b7b..6780a6a8 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java
@@ -43,138 +43,138 @@ import org.onap.aaf.misc.env.old.Stringifier;
public class JU_JAXBDataTest {
- @Mock
- private Objectifier<String> objfr;
+ @Mock
+ private Objectifier<String> objfr;
- private String object = "Text";
+ private String object = "Text";
- @Mock
- private Stringifier<String> strfr;
+ @Mock
+ private Stringifier<String> strfr;
- @Mock
- private IOStringifier<String> ioStrfr;
+ @Mock
+ private IOStringifier<String> ioStrfr;
- @Mock
- private JAXBDF<String> df;
+ @Mock
+ private JAXBDF<String> df;
- @Mock
- private Env env;
+ @Mock
+ private Env env;
- @Mock
- private Class<String> typeClass;
+ @Mock
+ private Class<String> typeClass;
- @Mock
- private OutputStream os;
+ @Mock
+ private OutputStream os;
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- @Mock
- private EnvJAXB env1;
+ @Mock
+ private EnvJAXB env1;
- @Before
- public void setUp() throws Exception {
- writer = mock(Writer.class);
- os = mock(OutputStream.class);
- strfr = mock(Stringifier.class);
- ioStrfr = mock(IOStringifier.class);
- objfr = mock(Objectifier.class);
- env1 = mock(EnvJAXB.class);
- }
+ @Before
+ public void setUp() throws Exception {
+ writer = mock(Writer.class);
+ os = mock(OutputStream.class);
+ strfr = mock(Stringifier.class);
+ ioStrfr = mock(IOStringifier.class);
+ objfr = mock(Objectifier.class);
+ env1 = mock(EnvJAXB.class);
+ }
- @Test
- public void testJAXBDataEnv() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
+ @Test
+ public void testJAXBDataEnv() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
- when(objfr.objectify(env, object)).thenReturn("String1");
+ when(objfr.objectify(env, object)).thenReturn("String1");
- jaxb.to(os);
- jaxb.to(writer);
+ jaxb.to(os);
+ jaxb.to(writer);
- verify(writer).write(object);
- verify(os).write(object.getBytes());
+ verify(writer).write(object);
+ verify(os).write(object.getBytes());
- assertEquals(jaxb.asString(), object);
- assertEquals(jaxb.asString(null), object);
- assertEquals(jaxb.toString(), object);
- assertEquals(jaxb.getTypeClass(), typeClass);
- assertEquals(jaxb.out(null), jaxb);
- assertEquals(jaxb.in(null), jaxb);
- assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
- assertEquals(jaxb.asObject(), "String1");
- assertEquals(jaxb.asObject(env1), "String1");
- assertEquals(jaxb.toString(), object);
- }
+ assertEquals(jaxb.asString(), object);
+ assertEquals(jaxb.asString(null), object);
+ assertEquals(jaxb.toString(), object);
+ assertEquals(jaxb.getTypeClass(), typeClass);
+ assertEquals(jaxb.out(null), jaxb);
+ assertEquals(jaxb.in(null), jaxb);
+ assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
+ assertEquals(jaxb.asObject(), "String1");
+ assertEquals(jaxb.asObject(env1), "String1");
+ assertEquals(jaxb.toString(), object);
+ }
- @Test
- public void testJAXBDataEnvForObjectifier() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
+ @Test
+ public void testJAXBDataEnvForObjectifier() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
- when(objfr.objectify(env1, object)).thenReturn("String1");
+ when(objfr.objectify(env1, object)).thenReturn("String1");
- assertEquals(jaxb.asObject(env1), "String1");
- }
+ assertEquals(jaxb.asObject(env1), "String1");
+ }
- @Test
- public void testJAXBDataEnvWithObject() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testJAXBDataEnvWithObject() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- jaxb.to(os);
+ jaxb.to(os);
- verify(os).write(object.getBytes());
+ verify(os).write(object.getBytes());
- assertEquals(jaxb.asString(), object);
- assertEquals(jaxb.asString(null), object);
- assertEquals(jaxb.toString(), object);
- }
+ assertEquals(jaxb.asString(), object);
+ assertEquals(jaxb.asString(null), object);
+ assertEquals(jaxb.toString(), object);
+ }
- @Test
- public void testJAXBDataEnvForWriter() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testJAXBDataEnvForWriter() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- jaxb.to(writer);
+ jaxb.to(writer);
- verify(writer).write(object);
+ verify(writer).write(object);
- assertEquals(jaxb.asString(), object);
- assertEquals(jaxb.asString(null), object);
- assertEquals(jaxb.toString(), object);
- assertEquals(jaxb.asObject(), object);
- assertEquals(jaxb.asObject(null), object);
- }
+ assertEquals(jaxb.asString(), object);
+ assertEquals(jaxb.asString(null), object);
+ assertEquals(jaxb.toString(), object);
+ assertEquals(jaxb.asObject(), object);
+ assertEquals(jaxb.asObject(null), object);
+ }
- @Test
- public void testAsStringWithNullString() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testAsStringWithNullString() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- assertEquals(jaxb.asString(), object);
- }
+ assertEquals(jaxb.asString(), object);
+ }
- @Test
- public void testAsStringWithNullStringWithEnv() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testAsStringWithNullStringWithEnv() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env1, object)).thenReturn(object);
+ when(strfr.stringify(env1, object)).thenReturn(object);
- assertEquals(jaxb.asString(env1), object);
- }
+ assertEquals(jaxb.asString(env1), object);
+ }
- @Test
- public void testToWithIOStrifier() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testToWithIOStrifier() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- jaxb.option(0);
+ jaxb.option(0);
- when(strfr.stringify(env1, object)).thenReturn(object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env1, object)).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
- assertEquals(jaxb.asString(env1), object);
- }
+ assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
+ assertEquals(jaxb.asString(env1), object);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java
index 05fd6fbf..c113c86e 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java
@@ -36,204 +36,204 @@ import org.junit.Test;
public class JU_ChronoTest {
- @Before
- public void setUp() throws Exception {
- }
-
- @Test
- public void testFormatter8601() {
- Chrono.Formatter8601 formatter = new Chrono.Formatter8601();
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testFormatter8601() {
+ Chrono.Formatter8601 formatter = new Chrono.Formatter8601();
- LogRecord record = new LogRecord(Level.WARNING, "Log Record to test log formating");
+ LogRecord record = new LogRecord(Level.WARNING, "Log Record to test log formating");
- Date date = new Date(118, 02, 02);
- long time = date.getTime();
+ Date date = new Date(118, 02, 02);
+ long time = date.getTime();
- record.setMillis(time);
+ record.setMillis(time);
- String expectedString = Chrono.dateFmt.format(date) + " " + record.getThreadID() + " " + record.getLevel()
- + ": " + record.getMessage() + "\n";
- assertEquals(expectedString, formatter.format(record));
- }
+ String expectedString = Chrono.dateFmt.format(date) + " " + record.getThreadID() + " " + record.getLevel()
+ + ": " + record.getMessage() + "\n";
+ assertEquals(expectedString, formatter.format(record));
+ }
- @Test
- public void testTimeStampWithDate() {
- Date date = Calendar.getInstance().getTime();
- XMLGregorianCalendar timeStamp = Chrono.timeStamp(date);
+ @Test
+ public void testTimeStampWithDate() {
+ Date date = Calendar.getInstance().getTime();
+ XMLGregorianCalendar timeStamp = Chrono.timeStamp(date);
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- XMLGregorianCalendar expectedCalendar = Chrono.xmlDatatypeFactory.newXMLGregorianCalendar(gc);
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTime(date);
+ XMLGregorianCalendar expectedCalendar = Chrono.xmlDatatypeFactory.newXMLGregorianCalendar(gc);
- assertEquals(expectedCalendar, timeStamp);
- }
+ assertEquals(expectedCalendar, timeStamp);
+ }
- @Test
- public void testUTCStamp() {
- final Date date = Calendar.getInstance().getTime();
- String expectedUTCTime = Chrono.utcFmt.format(date);
+ @Test
+ public void testUTCStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ String expectedUTCTime = Chrono.utcFmt.format(date);
- String stamp = Chrono.utcStamp(date);
+ String stamp = Chrono.utcStamp(date);
- assertEquals(stamp, expectedUTCTime);
+ assertEquals(stamp, expectedUTCTime);
- Date date1 = null;
- assertEquals("", Chrono.utcStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.utcStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.utcStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.utcStamp(gc), expectedUTCTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.utcStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.utcStamp(gc), expectedUTCTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.utcStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.utcStamp(xgc), expectedUTCTime);
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.utcStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.utcStamp(xgc), expectedUTCTime);
- }
+ }
- @Test
- public void testDateStamp() {
- final Date date = Calendar.getInstance().getTime();
- String expectedUTCTime = Chrono.dateFmt.format(date);
+ @Test
+ public void testDateStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ String expectedUTCTime = Chrono.dateFmt.format(date);
- String stamp = Chrono.dateStamp(date);
+ String stamp = Chrono.dateStamp(date);
- assertEquals(stamp, expectedUTCTime);
+ assertEquals(stamp, expectedUTCTime);
- Date date1 = null;
- assertEquals("", Chrono.dateStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.dateStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.dateStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.dateStamp(gc), expectedUTCTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.dateStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.dateStamp(gc), expectedUTCTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.dateStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.dateStamp(xgc), expectedUTCTime);
- }
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.dateStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.dateStamp(xgc), expectedUTCTime);
+ }
- @Test
- public void testDateTime() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ @Test
+ public void testDateTime() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- GregorianCalendar gc = null;
- assertEquals(Chrono.dateTime(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.dateTime(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
- // String expectedDateTime = "2018-04-29T11:14:43.297" + sign + hourOffSet + ":"
- // + minOffSet;
+ // String expectedDateTime = "2018-04-29T11:14:43.297" + sign + hourOffSet + ":"
+ // + minOffSet;
- TimeZone tz = gc.getTimeZone();
- int tz1 = (tz.getRawOffset() + tz.getDSTSavings()) / 0x8CA0;
- int tz1abs = Math.abs(tz1);
- String expectedDateTime = String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d",
- gc.get(GregorianCalendar.YEAR), gc.get(GregorianCalendar.MONTH) + 1,
- gc.get(GregorianCalendar.DAY_OF_MONTH), gc.get(GregorianCalendar.HOUR),
- gc.get(GregorianCalendar.MINUTE), gc.get(GregorianCalendar.SECOND),
- gc.get(GregorianCalendar.MILLISECOND), tz1 == tz1abs ? '+' : '-', tz1abs / 100,
- ((tz1abs - (tz1abs / 100) * 100) * 6) / 10 // Get the "10s", then convert to mins (without losing int
- // place)
- );
+ TimeZone tz = gc.getTimeZone();
+ int tz1 = (tz.getRawOffset() + tz.getDSTSavings()) / 0x8CA0;
+ int tz1abs = Math.abs(tz1);
+ String expectedDateTime = String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d",
+ gc.get(GregorianCalendar.YEAR), gc.get(GregorianCalendar.MONTH) + 1,
+ gc.get(GregorianCalendar.DAY_OF_MONTH), gc.get(GregorianCalendar.HOUR),
+ gc.get(GregorianCalendar.MINUTE), gc.get(GregorianCalendar.SECOND),
+ gc.get(GregorianCalendar.MILLISECOND), tz1 == tz1abs ? '+' : '-', tz1abs / 100,
+ ((tz1abs - (tz1abs / 100) * 100) * 6) / 10 // Get the "10s", then convert to mins (without losing int
+ // place)
+ );
- String stamp = Chrono.dateTime(date);
+ String stamp = Chrono.dateTime(date);
- assertEquals(stamp, expectedDateTime);
+ assertEquals(stamp, expectedDateTime);
- assertEquals(Chrono.dateTime(gc), expectedDateTime);
+ assertEquals(Chrono.dateTime(gc), expectedDateTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.dateTime(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.dateTime(xgc), expectedDateTime);
- }
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.dateTime(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.dateTime(xgc), expectedDateTime);
+ }
- @Test
- public void testDateOnlyStamp() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ @Test
+ public void testDateOnlyStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- String expectedDateTime = Chrono.dateOnlyFmt.format(date);
+ String expectedDateTime = Chrono.dateOnlyFmt.format(date);
- String stamp = Chrono.dateOnlyStamp(date);
+ String stamp = Chrono.dateOnlyStamp(date);
- assertEquals(stamp, expectedDateTime);
+ assertEquals(stamp, expectedDateTime);
- Date date1 = null;
- assertEquals("", Chrono.dateOnlyStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.dateOnlyStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.dateOnlyStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.dateOnlyStamp(gc), expectedDateTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.dateOnlyStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.dateOnlyStamp(gc), expectedDateTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.dateOnlyStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.dateOnlyStamp(xgc), expectedDateTime);
- }
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.dateOnlyStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.dateOnlyStamp(xgc), expectedDateTime);
+ }
- @Test
- public void testNiceDateStamp() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ @Test
+ public void testNiceDateStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- String expectedDateTime = Chrono.niceDateFmt.format(date);
+ String expectedDateTime = Chrono.niceDateFmt.format(date);
- String stamp = Chrono.niceDateStamp(date);
+ String stamp = Chrono.niceDateStamp(date);
- assertEquals(stamp, expectedDateTime);
+ assertEquals(stamp, expectedDateTime);
- Date date1 = null;
- assertEquals("", Chrono.niceDateStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.niceDateStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.niceDateStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.niceDateStamp(gc), expectedDateTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.niceDateStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.niceDateStamp(gc), expectedDateTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.niceDateStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.niceDateStamp(xgc), expectedDateTime);
- }
-
- @Test
- public void testMoment() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.niceDateStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.niceDateStamp(xgc), expectedDateTime);
+ }
+
+ @Test
+ public void testMoment() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- GregorianCalendar begin = new GregorianCalendar();
- begin.setTimeInMillis(date.getTime());
- begin.set(GregorianCalendar.HOUR, 0);
- begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
- begin.set(GregorianCalendar.MINUTE, 0);
- begin.set(GregorianCalendar.SECOND, 0);
- begin.set(GregorianCalendar.MILLISECOND, 0);
+ GregorianCalendar begin = new GregorianCalendar();
+ begin.setTimeInMillis(date.getTime());
+ begin.set(GregorianCalendar.HOUR, 0);
+ begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
+ begin.set(GregorianCalendar.MINUTE, 0);
+ begin.set(GregorianCalendar.SECOND, 0);
+ begin.set(GregorianCalendar.MILLISECOND, 0);
- long firstMoment = begin.getTimeInMillis();
+ long firstMoment = begin.getTimeInMillis();
- begin.set(GregorianCalendar.HOUR, 11);
- begin.set(GregorianCalendar.MINUTE, 59);
- begin.set(GregorianCalendar.SECOND, 59);
- begin.set(GregorianCalendar.MILLISECOND, 999);
- begin.set(GregorianCalendar.AM_PM, GregorianCalendar.PM);
+ begin.set(GregorianCalendar.HOUR, 11);
+ begin.set(GregorianCalendar.MINUTE, 59);
+ begin.set(GregorianCalendar.SECOND, 59);
+ begin.set(GregorianCalendar.MILLISECOND, 999);
+ begin.set(GregorianCalendar.AM_PM, GregorianCalendar.PM);
- long lastMoment = begin.getTimeInMillis();
+ long lastMoment = begin.getTimeInMillis();
- assertEquals(firstMoment, Chrono.firstMomentOfDay(date.getTime()));
- assertEquals(lastMoment, Chrono.lastMomentOfDay(date.getTime()));
+ assertEquals(firstMoment, Chrono.firstMomentOfDay(date.getTime()));
+ assertEquals(lastMoment, Chrono.lastMomentOfDay(date.getTime()));
- float timeInMillis = (lastMoment - firstMoment) / 1000000f;
- assertEquals(timeInMillis, Chrono.millisFromNanos(firstMoment, lastMoment), 0);
+ float timeInMillis = (lastMoment - firstMoment) / 1000000f;
+ assertEquals(timeInMillis, Chrono.millisFromNanos(firstMoment, lastMoment), 0);
- }
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java
index 4b8c9dce..3e6f5355 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java
@@ -34,71 +34,71 @@ import org.mockito.Mock;
public class JU_DoubleOutputStreamTest {
- @Mock
- private OutputStream stream1;
+ @Mock
+ private OutputStream stream1;
- @Mock
- private OutputStream stream2;
+ @Mock
+ private OutputStream stream2;
- private DoubleOutputStream doubleOutputStream;
+ private DoubleOutputStream doubleOutputStream;
- @Before
- public void setup() {
- stream1 = mock(OutputStream.class);
- stream2 = mock(OutputStream.class);
- }
+ @Before
+ public void setup() {
+ stream1 = mock(OutputStream.class);
+ stream2 = mock(OutputStream.class);
+ }
- @Test
- public void testWriteInt() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testWriteInt() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- doubleOutputStream.write(123);
+ doubleOutputStream.write(123);
- verify(stream1, only()).write(123);
- verify(stream2, only()).write(123);
- }
+ verify(stream1, only()).write(123);
+ verify(stream2, only()).write(123);
+ }
- @Test
- public void testWriteByteArray() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testWriteByteArray() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- byte[] bytes = { 1, 2, 3, 4 };
+ byte[] bytes = { 1, 2, 3, 4 };
- doubleOutputStream.write(bytes);
+ doubleOutputStream.write(bytes);
- verify(stream1, only()).write(bytes);
- verify(stream2, only()).write(bytes);
+ verify(stream1, only()).write(bytes);
+ verify(stream2, only()).write(bytes);
- }
+ }
- @Test
- public void testWriteByteArrayWithOffset() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testWriteByteArrayWithOffset() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- byte[] bytes = { 1, 2, 3, 4 };
+ byte[] bytes = { 1, 2, 3, 4 };
- doubleOutputStream.write(bytes, 1, 3);
- verify(stream1, only()).write(bytes, 1, 3);
- verify(stream2, only()).write(bytes, 1, 3);
- }
+ doubleOutputStream.write(bytes, 1, 3);
+ verify(stream1, only()).write(bytes, 1, 3);
+ verify(stream2, only()).write(bytes, 1, 3);
+ }
- @Test
- public void testFlush() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testFlush() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- doubleOutputStream.flush();
+ doubleOutputStream.flush();
- verify(stream1, only()).flush();
- verify(stream2, only()).flush();
- }
+ verify(stream1, only()).flush();
+ verify(stream2, only()).flush();
+ }
- @Test
- public void testClose() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, false);
+ @Test
+ public void testClose() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, false);
- doubleOutputStream.close();
+ doubleOutputStream.close();
- verify(stream1, only()).close();
- verify(stream2, never()).close();
- }
+ verify(stream1, only()).close();
+ verify(stream2, never()).close();
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java
index b54026f1..a307b3f8 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java
@@ -35,79 +35,79 @@ import org.mockito.Mock;
public class JU_IndentPrintWriterTest {
- @Mock
- private OutputStream stream;
+ @Mock
+ private OutputStream stream;
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- @Before
- public void setUp() throws Exception {
- stream = mock(OutputStream.class);
- writer = mock(Writer.class);
- }
+ @Before
+ public void setUp() throws Exception {
+ stream = mock(OutputStream.class);
+ writer = mock(Writer.class);
+ }
- @Test
- public void testWriteInt() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testWriteInt() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.write(123);
+ indentWriter.write(123);
- verify(writer).write(123);
+ verify(writer).write(123);
- assertEquals(indentWriter.getIndent(), 0);
- }
+ assertEquals(indentWriter.getIndent(), 0);
+ }
- @Test
- public void testWriteIntWithNewLineCharacter() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testWriteIntWithNewLineCharacter() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.setIndent(12);
+ indentWriter.setIndent(12);
- indentWriter.println();
+ indentWriter.println();
- indentWriter.write("123", 1, 2);
+ indentWriter.write("123", 1, 2);
- verify(writer).write('\n');
- verify(writer).write('2');
- verify(writer).write('3');
- assertEquals(indentWriter.getIndent(), 12);
- }
+ verify(writer).write('\n');
+ verify(writer).write('2');
+ verify(writer).write('3');
+ assertEquals(indentWriter.getIndent(), 12);
+ }
- @Test
- public void testWriteString() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testWriteString() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.inc();
+ indentWriter.inc();
- indentWriter.write("123");
+ indentWriter.write("123");
- verify(writer).write('1');
- verify(writer).write('2');
- verify(writer).write('3');
- assertEquals(indentWriter.getIndent(), 1);
- }
+ verify(writer).write('1');
+ verify(writer).write('2');
+ verify(writer).write('3');
+ assertEquals(indentWriter.getIndent(), 1);
+ }
- @Test
- public void testSetIndent() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(stream);
+ @Test
+ public void testSetIndent() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(stream);
- indentWriter.setIndent(12);
- indentWriter.dec();
+ indentWriter.setIndent(12);
+ indentWriter.dec();
- assertEquals(indentWriter.getIndent(), 11);
- }
+ assertEquals(indentWriter.getIndent(), 11);
+ }
- @Test
- public void testToCol() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testToCol() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.toCol(5);
- char[] chars = { 'a', 'b', 'c' };
- indentWriter.write(chars, 1, 2);
+ indentWriter.toCol(5);
+ char[] chars = { 'a', 'b', 'c' };
+ indentWriter.write(chars, 1, 2);
- verify(writer, times(5)).write(' ');
- verify(writer).write('c');
- verify(writer).write('b');
- }
+ verify(writer, times(5)).write(' ');
+ verify(writer).write('c');
+ verify(writer).write('b');
+ }
} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
index ce2245bf..f5b4aaa4 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
@@ -27,30 +27,30 @@ import org.junit.Test;
public class JU_SplitTest {
- @Test
- public void testSplit() {
- String[] splits = Split.split('c', "character c to break string");
-
- assertEquals(splits.length, 4);
- assertEquals(splits[0], "");
- assertEquals(splits[1], "hara");
- assertEquals(splits[2], "ter ");
- assertEquals(splits[3], " to break string");
- }
-
- @Test
- public void testSplitTrim() {
- String[] splits = Split.splitTrim('c', "character c to break string", 5);
-
- assertEquals(splits.length, 5);
- assertEquals(splits[0], "");
- assertEquals(splits[1], "hara");
- assertEquals(splits[2], "ter");
- assertEquals(splits[3], "to break string");
- assertEquals(splits[4], null);
-
- splits = Split.splitTrim('c', " character ", 1);
- assertEquals(splits.length, 1);
- assertEquals(splits[0], "character");
- }
+ @Test
+ public void testSplit() {
+ String[] splits = Split.split('c', "character c to break string");
+
+ assertEquals(splits.length, 4);
+ assertEquals(splits[0], "");
+ assertEquals(splits[1], "hara");
+ assertEquals(splits[2], "ter ");
+ assertEquals(splits[3], " to break string");
+ }
+
+ @Test
+ public void testSplitTrim() {
+ String[] splits = Split.splitTrim('c', "character c to break string", 5);
+
+ assertEquals(splits.length, 5);
+ assertEquals(splits[0], "");
+ assertEquals(splits[1], "hara");
+ assertEquals(splits[2], "ter");
+ assertEquals(splits[3], "to break string");
+ assertEquals(splits[4], null);
+
+ splits = Split.splitTrim('c', " character ", 1);
+ assertEquals(splits.length, 1);
+ assertEquals(splits[0], "character");
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java
index 377a2891..b55e2545 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java
@@ -31,105 +31,105 @@ import org.junit.Test;
public class JU_StringBuilderOutputStreamTest {
- StringBuilderOutputStream streamBuilder;
-
- StringBuilder builder = new StringBuilder();
-
- @Before
- public void setUp() throws Exception {
- streamBuilder = new StringBuilderOutputStream(builder);
- }
-
- @Test
- public void testWriteIntAndReset() {
- streamBuilder.write(123);
-
- assertEquals("123", streamBuilder.toString());
- streamBuilder.reset();
- assertEquals("", streamBuilder.toString());
- }
-
- @Test
- public void testWriteByteArrayWithoutException() throws IOException {
- byte[] bytes = { 1, 2, 3, 4 };
- streamBuilder.write(bytes);
- assertEquals(4, streamBuilder.getBuffer().length());
-
- streamBuilder.write(bytes, 1, 2);
- assertEquals(6, streamBuilder.getBuffer().length());
-
- streamBuilder.write(bytes, 1, 0);
- assertEquals(6, streamBuilder.getBuffer().length());
-
- streamBuilder.append(bytes[0]);
- assertEquals(7, streamBuilder.getBuffer().length());
- }
-
- @Test
- public void testWriteByteArrayWithIndexOutOfBoundException() {
- byte[] bytes = { 1, 2, 3, 4 };
-
- try {
- streamBuilder.write(bytes, -1, 2);
- fail("This is supposed to throw IndexOutOfBounds Excetpion");
- } catch (IndexOutOfBoundsException e) {
- } catch (Exception e) {
- fail("This should throw only IndexOutOfBounds Exception");
- }
- assertEquals(0, streamBuilder.getBuffer().length());
-
- }
-
- @Test
- public void testDefaultConstructor() throws IOException {
- StringBuilderOutputStream stream = new StringBuilderOutputStream();
-
- assertNotNull(stream.getBuffer());
- stream.close();
- }
-
- @Test
- public void testConstructorWithPositiveDefaultCapacity() throws IOException {
- StringBuilderOutputStream stream = new StringBuilderOutputStream(10);
-
- assertNotNull(stream.getBuffer());
- assertEquals(10, stream.getBuffer().capacity());
- stream.close();
- }
-
- @Test
- public void testConstructorWithNegativeCapacityException() {
- try {
- StringBuilderOutputStream stream = new StringBuilderOutputStream(-1);
- fail("This should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- } catch (Exception e) {
- fail("This should throw only IllegalArgumentException");
- }
- }
-
- @Test
- public void testWriteString() {
- streamBuilder.write("1234");
-
- assertEquals("1234", streamBuilder.toString());
-
- streamBuilder.write("1234", 1, 2);
- assertEquals("12342", streamBuilder.toString());
- }
-
- @Test
- public void testAppendCharSequence() {
- streamBuilder.append("1234");
- assertEquals("1234", streamBuilder.toString());
-
- streamBuilder.append(null);
- assertEquals("1234null", streamBuilder.toString());
-
- streamBuilder.append("1234", 1, 2);
- assertEquals("1234null2", streamBuilder.toString());
-
- streamBuilder.append(null, 1, 2);
- assertEquals("1234null2u", streamBuilder.toString());
- }
+ StringBuilderOutputStream streamBuilder;
+
+ StringBuilder builder = new StringBuilder();
+
+ @Before
+ public void setUp() throws Exception {
+ streamBuilder = new StringBuilderOutputStream(builder);
+ }
+
+ @Test
+ public void testWriteIntAndReset() {
+ streamBuilder.write(123);
+
+ assertEquals("123", streamBuilder.toString());
+ streamBuilder.reset();
+ assertEquals("", streamBuilder.toString());
+ }
+
+ @Test
+ public void testWriteByteArrayWithoutException() throws IOException {
+ byte[] bytes = { 1, 2, 3, 4 };
+ streamBuilder.write(bytes);
+ assertEquals(4, streamBuilder.getBuffer().length());
+
+ streamBuilder.write(bytes, 1, 2);
+ assertEquals(6, streamBuilder.getBuffer().length());
+
+ streamBuilder.write(bytes, 1, 0);
+ assertEquals(6, streamBuilder.getBuffer().length());
+
+ streamBuilder.append(bytes[0]);
+ assertEquals(7, streamBuilder.getBuffer().length());
+ }
+
+ @Test
+ public void testWriteByteArrayWithIndexOutOfBoundException() {
+ byte[] bytes = { 1, 2, 3, 4 };
+
+ try {
+ streamBuilder.write(bytes, -1, 2);
+ fail("This is supposed to throw IndexOutOfBounds Excetpion");
+ } catch (IndexOutOfBoundsException e) {
+ } catch (Exception e) {
+ fail("This should throw only IndexOutOfBounds Exception");
+ }
+ assertEquals(0, streamBuilder.getBuffer().length());
+
+ }
+
+ @Test
+ public void testDefaultConstructor() throws IOException {
+ StringBuilderOutputStream stream = new StringBuilderOutputStream();
+
+ assertNotNull(stream.getBuffer());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithPositiveDefaultCapacity() throws IOException {
+ StringBuilderOutputStream stream = new StringBuilderOutputStream(10);
+
+ assertNotNull(stream.getBuffer());
+ assertEquals(10, stream.getBuffer().capacity());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithNegativeCapacityException() {
+ try {
+ StringBuilderOutputStream stream = new StringBuilderOutputStream(-1);
+ fail("This should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
+ fail("This should throw only IllegalArgumentException");
+ }
+ }
+
+ @Test
+ public void testWriteString() {
+ streamBuilder.write("1234");
+
+ assertEquals("1234", streamBuilder.toString());
+
+ streamBuilder.write("1234", 1, 2);
+ assertEquals("12342", streamBuilder.toString());
+ }
+
+ @Test
+ public void testAppendCharSequence() {
+ streamBuilder.append("1234");
+ assertEquals("1234", streamBuilder.toString());
+
+ streamBuilder.append(null);
+ assertEquals("1234null", streamBuilder.toString());
+
+ streamBuilder.append("1234", 1, 2);
+ assertEquals("1234null2", streamBuilder.toString());
+
+ streamBuilder.append(null, 1, 2);
+ assertEquals("1234null2u", streamBuilder.toString());
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java
index 6a06e866..9247d0c9 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java
@@ -31,105 +31,105 @@ import org.junit.Test;
public class JU_StringBuilderWriterTest {
- StringBuilderWriter streamWriter;
-
- StringBuilder builder = new StringBuilder();
-
- @Before
- public void setUp() throws Exception {
- streamWriter = new StringBuilderWriter(builder);
- }
-
- @Test
- public void testWriteIntAndReset() {
- streamWriter.write(1);
-
- assertEquals(1, streamWriter.getBuffer().length());
- streamWriter.reset();
- assertEquals("", streamWriter.toString());
- }
-
- @Test
- public void testWriteByteArrayWithoutException() throws IOException {
- char[] bytes = { 1, 2, 3, 4 };
- streamWriter.write(bytes);
- assertEquals(4, streamWriter.getBuffer().length());
-
- streamWriter.write(bytes, 1, 2);
- assertEquals(6, streamWriter.getBuffer().length());
-
- streamWriter.write(bytes, 1, 0);
- assertEquals(6, streamWriter.getBuffer().length());
-
- streamWriter.append(bytes[0]);
- assertEquals(7, streamWriter.getBuffer().length());
- }
-
- @Test
- public void testWriteByteArrayWithIndexOutOfBoundException() {
- char[] bytes = { 1, 2, 3, 4 };
-
- try {
- streamWriter.write(bytes, -1, 2);
- fail("This is supposed to throw IndexOutOfBounds Excetpion");
- } catch (IndexOutOfBoundsException e) {
- } catch (Exception e) {
- fail("This should throw only IndexOutOfBounds Exception");
- }
- assertEquals(0, streamWriter.getBuffer().length());
-
- }
-
- @Test
- public void testDefaultConstructor() throws IOException {
- StringBuilderWriter stream = new StringBuilderWriter();
-
- assertNotNull(stream.getBuffer());
- stream.close();
- }
-
- @Test
- public void testConstructorWithPositiveDefaultCapacity() throws IOException {
- StringBuilderWriter stream = new StringBuilderWriter(10);
-
- assertNotNull(stream.getBuffer());
- assertEquals(10, stream.getBuffer().capacity());
- stream.close();
- }
-
- @Test
- public void testConstructorWithNegativeCapacityException() {
- try {
- StringBuilderWriter stream = new StringBuilderWriter(-1);
- fail("This should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- } catch (Exception e) {
- fail("This should throw only IllegalArgumentException");
- }
- }
-
- @Test
- public void testWriteString() {
- streamWriter.write("1234");
-
- assertEquals("1234", streamWriter.toString());
-
- streamWriter.write("1234", 1, 2);
- assertEquals("123423", streamWriter.toString());
- }
-
- @Test
- public void testAppendCharSequence() {
- streamWriter.append("1234");
- assertEquals("1234", streamWriter.toString());
-
- streamWriter.append(null);
- assertEquals("1234null", streamWriter.toString());
-
- streamWriter.append("1234", 1, 2);
- assertEquals("1234null2", streamWriter.toString());
-
- streamWriter.append(null, 1, 2);
- assertEquals("1234null2u", streamWriter.toString());
- }
+ StringBuilderWriter streamWriter;
+
+ StringBuilder builder = new StringBuilder();
+
+ @Before
+ public void setUp() throws Exception {
+ streamWriter = new StringBuilderWriter(builder);
+ }
+
+ @Test
+ public void testWriteIntAndReset() {
+ streamWriter.write(1);
+
+ assertEquals(1, streamWriter.getBuffer().length());
+ streamWriter.reset();
+ assertEquals("", streamWriter.toString());
+ }
+
+ @Test
+ public void testWriteByteArrayWithoutException() throws IOException {
+ char[] bytes = { 1, 2, 3, 4 };
+ streamWriter.write(bytes);
+ assertEquals(4, streamWriter.getBuffer().length());
+
+ streamWriter.write(bytes, 1, 2);
+ assertEquals(6, streamWriter.getBuffer().length());
+
+ streamWriter.write(bytes, 1, 0);
+ assertEquals(6, streamWriter.getBuffer().length());
+
+ streamWriter.append(bytes[0]);
+ assertEquals(7, streamWriter.getBuffer().length());
+ }
+
+ @Test
+ public void testWriteByteArrayWithIndexOutOfBoundException() {
+ char[] bytes = { 1, 2, 3, 4 };
+
+ try {
+ streamWriter.write(bytes, -1, 2);
+ fail("This is supposed to throw IndexOutOfBounds Excetpion");
+ } catch (IndexOutOfBoundsException e) {
+ } catch (Exception e) {
+ fail("This should throw only IndexOutOfBounds Exception");
+ }
+ assertEquals(0, streamWriter.getBuffer().length());
+
+ }
+
+ @Test
+ public void testDefaultConstructor() throws IOException {
+ StringBuilderWriter stream = new StringBuilderWriter();
+
+ assertNotNull(stream.getBuffer());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithPositiveDefaultCapacity() throws IOException {
+ StringBuilderWriter stream = new StringBuilderWriter(10);
+
+ assertNotNull(stream.getBuffer());
+ assertEquals(10, stream.getBuffer().capacity());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithNegativeCapacityException() {
+ try {
+ StringBuilderWriter stream = new StringBuilderWriter(-1);
+ fail("This should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
+ fail("This should throw only IllegalArgumentException");
+ }
+ }
+
+ @Test
+ public void testWriteString() {
+ streamWriter.write("1234");
+
+ assertEquals("1234", streamWriter.toString());
+
+ streamWriter.write("1234", 1, 2);
+ assertEquals("123423", streamWriter.toString());
+ }
+
+ @Test
+ public void testAppendCharSequence() {
+ streamWriter.append("1234");
+ assertEquals("1234", streamWriter.toString());
+
+ streamWriter.append(null);
+ assertEquals("1234null", streamWriter.toString());
+
+ streamWriter.append("1234", 1, 2);
+ assertEquals("1234null2", streamWriter.toString());
+
+ streamWriter.append(null, 1, 2);
+ assertEquals("1234null2u", streamWriter.toString());
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java
index 3976718f..0ce3a84e 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java
@@ -29,39 +29,39 @@ import org.onap.aaf.misc.env.util.IPValidator;
public class JU_IPValidator {
- @Test
- public void test() {
- assertTrue(IPValidator.ipv4("10.10.10.10"));
- assertTrue(IPValidator.ipv4("127.0.0.0"));
- assertFalse(IPValidator.ipv4("10"));
- assertFalse(IPValidator.ipv4("10.10.10"));
- assertFalse(IPValidator.ipv4("10.10.10."));
- assertFalse(IPValidator.ipv4("10.10.10.10."));
- assertFalse(IPValidator.ipv4("10.10.10.10.10"));
- assertFalse(IPValidator.ipv4("something10.10.10.10"));
- assertTrue(IPValidator.ipv4("0.10.10.10"));
- assertTrue(IPValidator.ipv4("0.0.0.0"));
- assertTrue(IPValidator.ipv4("0.10.10.10"));
- assertFalse(IPValidator.ipv4("011.255.255.255"));
- assertFalse(IPValidator.ipv4("255.01.255.255"));
- assertFalse(IPValidator.ipv4("255.255.255.256"));
- assertFalse(IPValidator.ipv4("255.299.255.255"));
+ @Test
+ public void test() {
+ assertTrue(IPValidator.ipv4("10.10.10.10"));
+ assertTrue(IPValidator.ipv4("127.0.0.0"));
+ assertFalse(IPValidator.ipv4("10"));
+ assertFalse(IPValidator.ipv4("10.10.10"));
+ assertFalse(IPValidator.ipv4("10.10.10."));
+ assertFalse(IPValidator.ipv4("10.10.10.10."));
+ assertFalse(IPValidator.ipv4("10.10.10.10.10"));
+ assertFalse(IPValidator.ipv4("something10.10.10.10"));
+ assertTrue(IPValidator.ipv4("0.10.10.10"));
+ assertTrue(IPValidator.ipv4("0.0.0.0"));
+ assertTrue(IPValidator.ipv4("0.10.10.10"));
+ assertFalse(IPValidator.ipv4("011.255.255.255"));
+ assertFalse(IPValidator.ipv4("255.01.255.255"));
+ assertFalse(IPValidator.ipv4("255.255.255.256"));
+ assertFalse(IPValidator.ipv4("255.299.255.255"));
- assertTrue(IPValidator.ipv6("0000:0000:0000:0000:0000:0000:0000:0000"));
- assertTrue(IPValidator.ipv6("0:0:0:0:0:0:0:0"));
- assertTrue(IPValidator.ipv6("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
- assertTrue(IPValidator.ipv6("2001:8DB:0:0:23:F422:FE3B:AC10"));
- assertTrue(IPValidator.ipv6("2001:8DB::23:F422:FE3B:AC10"));
- assertTrue(IPValidator.ipv6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
- assertTrue(IPValidator.ipv6("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"));
- assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
- assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
- // more than one Double Colons
- assertFalse(IPValidator.ipv6("0000:0000:0000::0000::0000"));
- assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10:FFFF"));
+ assertTrue(IPValidator.ipv6("0000:0000:0000:0000:0000:0000:0000:0000"));
+ assertTrue(IPValidator.ipv6("0:0:0:0:0:0:0:0"));
+ assertTrue(IPValidator.ipv6("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ipv6("2001:8DB:0:0:23:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ipv6("2001:8DB::23:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ipv6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+ assertTrue(IPValidator.ipv6("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"));
+ assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
+ assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
+ // more than one Double Colons
+ assertFalse(IPValidator.ipv6("0000:0000:0000::0000::0000"));
+ assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10:FFFF"));
- assertTrue(IPValidator.ip("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
- assertTrue(IPValidator.ip("192.168.7.2"));
- }
+ assertTrue(IPValidator.ip("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ip("192.168.7.2"));
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
index 11f03d52..32e4080b 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
@@ -30,57 +30,57 @@ import org.onap.aaf.misc.env.util.Pool;
public class JU_PoolTest {
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void test() {
- Pool pool = new Pool<Integer>(new Pool.Creator<Integer>() {
+ @Test
+ public void test() {
+ Pool pool = new Pool<Integer>(new Pool.Creator<Integer>() {
- Integer content = 0;
+ Integer content = 0;
- @Override
- public Integer create() throws APIException {
- return content++;
- }
+ @Override
+ public Integer create() throws APIException {
+ return content++;
+ }
- @Override
- public void destroy(Integer t) {
+ @Override
+ public void destroy(Integer t) {
- }
+ }
- @Override
- public boolean isValid(Integer t) {
- return t == content;
- }
+ @Override
+ public boolean isValid(Integer t) {
+ return t == content;
+ }
- @Override
- public void reuse(Integer t) {
- content = t;
- }
- });
- Pool.Pooled<Integer> pooled = new Pool.Pooled<Integer>(new Integer(123), pool, LogTarget.SYSOUT);
- Pool.Pooled<Integer> pooled1 = new Pool.Pooled<Integer>(new Integer(123), null, LogTarget.SYSOUT);
- try {
- // pool.drain();
- assertEquals("Should return intial value", 0, pool.get().content);
- // pooled.toss();
- pool.prime(LogTarget.SYSOUT, 23);
- assertEquals("Should Return 23 as added at last prime", 23, pool.get(LogTarget.SYSOUT).content);
- pool.prime(LogTarget.SYSERR, 13);
- assertEquals("Should add another 13 from SysErr and remove 1", 35, pool.get(LogTarget.SYSERR).content);
- assertEquals("Create a new creator with create method", 1, pool.get().content);
- assertEquals("Create a new creator with create method", 2, pool.get().content);
- assertEquals("Should remove last from pool", 34, pool.get(LogTarget.SYSOUT).content);
+ @Override
+ public void reuse(Integer t) {
+ content = t;
+ }
+ });
+ Pool.Pooled<Integer> pooled = new Pool.Pooled<Integer>(new Integer(123), pool, LogTarget.SYSOUT);
+ Pool.Pooled<Integer> pooled1 = new Pool.Pooled<Integer>(new Integer(123), null, LogTarget.SYSOUT);
+ try {
+ // pool.drain();
+ assertEquals("Should return intial value", 0, pool.get().content);
+ // pooled.toss();
+ pool.prime(LogTarget.SYSOUT, 23);
+ assertEquals("Should Return 23 as added at last prime", 23, pool.get(LogTarget.SYSOUT).content);
+ pool.prime(LogTarget.SYSERR, 13);
+ assertEquals("Should add another 13 from SysErr and remove 1", 35, pool.get(LogTarget.SYSERR).content);
+ assertEquals("Create a new creator with create method", 1, pool.get().content);
+ assertEquals("Create a new creator with create method", 2, pool.get().content);
+ assertEquals("Should remove last from pool", 34, pool.get(LogTarget.SYSOUT).content);
- pool.drain();
- assertEquals("Should remove last from pool", 17, pool.get(LogTarget.SYSOUT).content);
- pool.setMaxRange(10);
- assertEquals(10, pool.getMaxRange());
- pooled.toss();
- pooled1.toss();
- } catch (APIException e) {
- }
- }
+ pool.drain();
+ assertEquals("Should remove last from pool", 17, pool.get(LogTarget.SYSOUT).content);
+ pool.setMaxRange(10);
+ assertEquals(10, pool.getMaxRange());
+ pooled.toss();
+ pooled1.toss();
+ } catch (APIException e) {
+ }
+ }
}
diff --git a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java
index c6537deb..e118baaa 100644
--- a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java
+++ b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java
@@ -27,61 +27,61 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public class LogFileNamer {
- private final String root;
- private final String ending;
- private final String dir;
+ private final String root;
+ private final String ending;
+ private final String dir;
- public LogFileNamer(final String dir, final String root) {
- this.dir = dir;
- if (root == null || "".equals(root) || root.endsWith("/")) {
- this.root = root;
- } else {
- this.root = root + "-";
- }
- ending = new SimpleDateFormat("YYYYMMdd").format(new Date());
- }
+ public LogFileNamer(final String dir, final String root) {
+ this.dir = dir;
+ if (root == null || "".equals(root) || root.endsWith("/")) {
+ this.root = root;
+ } else {
+ this.root = root + "-";
+ }
+ ending = new SimpleDateFormat("YYYYMMdd").format(new Date());
+ }
- public LogFileNamer noPID() {
- return this;
- }
+ public LogFileNamer noPID() {
+ return this;
+ }
- private static final String FILE_FORMAT_STR = "%s/%s%s%s_%d.log";
+ private static final String FILE_FORMAT_STR = "%s/%s%s%s_%d.log";
- /**
- * Accepts a String. If Separated by "|" then first part is the Appender name,
- * and the second is used in the FileNaming (This is to allow for shortened
- * Logger names, and more verbose file names) ONAP: jna code has license issues.
- * Just do Date + Unique Number
- *
- * @param appender
- *
- * returns the String Appender
- * @throws IOException
- */
- public String setAppender(String appender) throws IOException {
- int i = 0;
- File f;
- while ((f = new File(String.format(FILE_FORMAT_STR, dir, root, appender, ending, i))).exists()) {
- ++i;
- }
-
- f.createNewFile();
- System.setProperty("LOG4J_FILENAME_" + appender, f.getCanonicalPath());
- return appender;
- }
+ /**
+ * Accepts a String. If Separated by "|" then first part is the Appender name,
+ * and the second is used in the FileNaming (This is to allow for shortened
+ * Logger names, and more verbose file names) ONAP: jna code has license issues.
+ * Just do Date + Unique Number
+ *
+ * @param appender
+ *
+ * returns the String Appender
+ * @throws IOException
+ */
+ public String setAppender(String appender) throws IOException {
+ int i = 0;
+ File f;
+ while ((f = new File(String.format(FILE_FORMAT_STR, dir, root, appender, ending, i))).exists()) {
+ ++i;
+ }
+
+ f.createNewFile();
+ System.setProperty("LOG4J_FILENAME_" + appender, f.getCanonicalPath());
+ return appender;
+ }
- public void configure(final String path, final String fname, final String log_level) throws IOException {
- final String fullPath = path + '/' + fname;
- if (new File(fullPath).exists()) {
- org.apache.log4j.PropertyConfigurator.configureAndWatch(fullPath, 60 * 1000L);
- } else {
- URL rsrc = ClassLoader.getSystemResource(fname);
- if (rsrc == null) {
- String msg = "Neither File: " + path + '/' + fname + " nor resource on Classpath " + fname + " exist";
- throw new IOException(msg);
- }
- org.apache.log4j.PropertyConfigurator.configure(rsrc);
- }
+ public void configure(final String path, final String fname, final String log_level) throws IOException {
+ final String fullPath = path + '/' + fname;
+ if (new File(fullPath).exists()) {
+ org.apache.log4j.PropertyConfigurator.configureAndWatch(fullPath, 60 * 1000L);
+ } else {
+ URL rsrc = ClassLoader.getSystemResource(fname);
+ if (rsrc == null) {
+ String msg = "Neither File: " + path + '/' + fname + " nor resource on Classpath " + fname + " exist";
+ throw new IOException(msg);
+ }
+ org.apache.log4j.PropertyConfigurator.configure(rsrc);
+ }
- }
+ }
}
diff --git a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java
index 8c47a409..720ed27f 100644
--- a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java
+++ b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java
@@ -34,60 +34,60 @@ import org.junit.Before;
import org.junit.Test;
public class JU_LogFileNamerTest {
- private File dir = new File(".");
+ private File dir = new File(".");
- private String ending = new SimpleDateFormat("YYYYMMdd").format(new Date());
+ private String ending = new SimpleDateFormat("YYYYMMdd").format(new Date());
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void test() throws IOException {
- LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "log");
- assertEquals(logFileNamer, logFileNamer.noPID());
+ @Test
+ public void test() throws IOException {
+ LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "log");
+ assertEquals(logFileNamer, logFileNamer.noPID());
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
- dir.getCanonicalFile() + File.separator + "log-Append" + ending + "_0.log");
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalFile() + File.separator + "log-Append" + ending + "_0.log");
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
- dir.getCanonicalFile() + File.separator + "log-Append" + ending + "_1.log");
- }
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalFile() + File.separator + "log-Append" + ending + "_1.log");
+ }
- @Test
- public void testBlankRoot() throws IOException {
- LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "");
- assertEquals(logFileNamer, logFileNamer.noPID());
+ @Test
+ public void testBlankRoot() throws IOException {
+ LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "");
+ assertEquals(logFileNamer, logFileNamer.noPID());
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
- dir.getCanonicalPath() + File.separator + "Append" + ending + "_0.log");
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalPath() + File.separator + "Append" + ending + "_0.log");
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
- dir.getCanonicalPath() + File.separator + "Append" + ending + "_1.log");
- }
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalPath() + File.separator + "Append" + ending + "_1.log");
+ }
- @After
- public void tearDown() throws IOException {
- File file = new File("./log-Append" + ending + "_0.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- file = new File("./log-Append" + ending + "_1.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- file = new File("./Append" + ending + "_0.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- file = new File("./Append" + ending + "_1.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- }
+ @After
+ public void tearDown() throws IOException {
+ File file = new File("./log-Append" + ending + "_0.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ file = new File("./log-Append" + ending + "_1.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ file = new File("./Append" + ending + "_0.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ file = new File("./Append" + ending + "_1.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java
index 725389c9..353261a0 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java
@@ -29,126 +29,126 @@ import org.onap.aaf.misc.env.TimeTaken;
import org.onap.aaf.misc.rosetta.InJson.State;
public class InJson implements Parse<Reader, State> {
- public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException {
- // First things first, if there's a "leftover" event, process that immediately
- State state = (State)parsed.state;
- if(state.unsent > 0) {
- parsed.event = state.unsent;
- state.unsent = 0;
- return parsed;
- }
-
- int ch;
- char c;
- StringBuilder sb = parsed.sb;
- boolean inQuotes = false, escaped = false;
- boolean go = true;
- try {
- // Gather data from Reader, looking for special characters when not in Quotes
- while(go && (ch=r.read())>=0) {
- if(state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content
- c=(char)ch;
- // Character is a quote.
- if(c=='"') {
- if(inQuotes) {
- if(escaped) { // if escaped Quote, add to data.
- sb.append(c);
- escaped = false;
- } else {
- inQuotes = false;
- }
- } else {
- parsed.isString=true;
- inQuotes = true;
- }
- } else { // Not a Quote
- if(inQuotes) {
- if(c=='\\') {
- if(escaped) {
- sb.append("\\\\");
- escaped = false;
- } else {
- escaped = true;
- }
- } else {
- sb.append(c);
- }
- } else {
- switch(c) {
- case ':':
- parsed.dataIsName();
- parsed.isString = false;
- break;
- case Parse.START_OBJ:
- if(state.braces++ == 0) {
- parsed.event = START_DOC;
- state.unsent = c;
- } else {
- parsed.event = c;
- }
- go = false;
- break;
- case Parse.END_OBJ:
- if(--state.braces == 0) {
- parsed.event = c;
- state.unsent = END_DOC;
- } else {
- parsed.event = c;
- }
- go = false;
- break;
- // These three end the data gathering, and send it along with the event that is ending the data gathering
- case Parse.NEXT:
- if(parsed.name.startsWith("__")) {
- parsed.event = Parse.ATTRIB;
- parsed.name = parsed.name.substring(2);
- } else {
- parsed.event = c;
- }
- go = false;
- break;
- case Parse.START_ARRAY:
- case Parse.END_ARRAY:
- parsed.event = c;
- go = false;
- break;
-
- // The Escape Sequence, for Quote marks within Quotes
- case '\\':
- // Ignore these, unless within quotes, at which point data-gather
- case ' ':
- case '\b':
- case '\f':
- case '\n':
- case '\r':
- case '\t':
- break;
- // Normal data... gather it
- default:
- sb.append(c);
- }
- }
- }
- }
- }
- return parsed;
- } catch (IOException e) {
- throw new ParseException(e);
- }
- }
+ public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException {
+ // First things first, if there's a "leftover" event, process that immediately
+ State state = (State)parsed.state;
+ if(state.unsent > 0) {
+ parsed.event = state.unsent;
+ state.unsent = 0;
+ return parsed;
+ }
+
+ int ch;
+ char c;
+ StringBuilder sb = parsed.sb;
+ boolean inQuotes = false, escaped = false;
+ boolean go = true;
+ try {
+ // Gather data from Reader, looking for special characters when not in Quotes
+ while(go && (ch=r.read())>=0) {
+ if(state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content
+ c=(char)ch;
+ // Character is a quote.
+ if(c=='"') {
+ if(inQuotes) {
+ if(escaped) { // if escaped Quote, add to data.
+ sb.append(c);
+ escaped = false;
+ } else {
+ inQuotes = false;
+ }
+ } else {
+ parsed.isString=true;
+ inQuotes = true;
+ }
+ } else { // Not a Quote
+ if(inQuotes) {
+ if(c=='\\') {
+ if(escaped) {
+ sb.append("\\\\");
+ escaped = false;
+ } else {
+ escaped = true;
+ }
+ } else {
+ sb.append(c);
+ }
+ } else {
+ switch(c) {
+ case ':':
+ parsed.dataIsName();
+ parsed.isString = false;
+ break;
+ case Parse.START_OBJ:
+ if(state.braces++ == 0) {
+ parsed.event = START_DOC;
+ state.unsent = c;
+ } else {
+ parsed.event = c;
+ }
+ go = false;
+ break;
+ case Parse.END_OBJ:
+ if(--state.braces == 0) {
+ parsed.event = c;
+ state.unsent = END_DOC;
+ } else {
+ parsed.event = c;
+ }
+ go = false;
+ break;
+ // These three end the data gathering, and send it along with the event that is ending the data gathering
+ case Parse.NEXT:
+ if(parsed.name.startsWith("__")) {
+ parsed.event = Parse.ATTRIB;
+ parsed.name = parsed.name.substring(2);
+ } else {
+ parsed.event = c;
+ }
+ go = false;
+ break;
+ case Parse.START_ARRAY:
+ case Parse.END_ARRAY:
+ parsed.event = c;
+ go = false;
+ break;
+
+ // The Escape Sequence, for Quote marks within Quotes
+ case '\\':
+ // Ignore these, unless within quotes, at which point data-gather
+ case ' ':
+ case '\b':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ break;
+ // Normal data... gather it
+ default:
+ sb.append(c);
+ }
+ }
+ }
+ }
+ }
+ return parsed;
+ } catch (IOException e) {
+ throw new ParseException(e);
+ }
+ }
- public static class State {
- public int braces = 0;
- public char unsent = 0;
- }
-
-// @Override
- public Parsed<State> newParsed() {
- return new Parsed<State>(new State()); // no State needed
- }
+ public static class State {
+ public int braces = 0;
+ public char unsent = 0;
+ }
+
+// @Override
+ public Parsed<State> newParsed() {
+ return new Parsed<State>(new State()); // no State needed
+ }
-// @Override
- public TimeTaken start(Env env) {
- return env.start("Rosetta JSON In", Env.JSON);
- }
+// @Override
+ public TimeTaken start(Env env) {
+ return env.start("Rosetta JSON In", Env.JSON);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java
index da66394c..91b7c57d 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java
@@ -34,455 +34,455 @@ import org.onap.aaf.misc.env.TimeTaken;
import org.onap.aaf.misc.rosetta.InXML.State;
public class InXML implements Parse<Reader, State> {
- // package on purpose
- JaxInfo jaxInfo;
+ // package on purpose
+ JaxInfo jaxInfo;
- public InXML(JaxInfo jaxInfo) {
- this.jaxInfo = jaxInfo;
- }
-
- public InXML(Class<?> cls, String ... rootNs) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException {
- jaxInfo = JaxInfo.build(cls,rootNs);
- }
+ public InXML(JaxInfo jaxInfo) {
+ this.jaxInfo = jaxInfo;
+ }
+
+ public InXML(Class<?> cls, String ... rootNs) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException {
+ jaxInfo = JaxInfo.build(cls,rootNs);
+ }
- // @Override
- public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException {
- State state = parsed.state;
-
- // OK, before anything else, see if there is leftover processing, if so, do it!
- if(state.unevaluated!=null) {
- DerTag dt = state.unevaluated;
- state.unevaluated = null;
- if(!state.greatExp.eval(parsed, dt))return parsed;
- }
+ // @Override
+ public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException {
+ State state = parsed.state;
+
+ // OK, before anything else, see if there is leftover processing, if so, do it!
+ if(state.unevaluated!=null) {
+ DerTag dt = state.unevaluated;
+ state.unevaluated = null;
+ if(!state.greatExp.eval(parsed, dt))return parsed;
+ }
- if(state.hasAttributes()) {
- Prop prop = state.pop();
- parsed.event = Parse.ATTRIB;
- parsed.name = prop.tag;
- parsed.sb.append(prop.value);
- parsed.isString=true;
- return parsed;
- }
- int ch;
- char c;
- boolean inQuotes = false, escaped = false;
+ if(state.hasAttributes()) {
+ Prop prop = state.pop();
+ parsed.event = Parse.ATTRIB;
+ parsed.name = prop.tag;
+ parsed.sb.append(prop.value);
+ parsed.isString=true;
+ return parsed;
+ }
+ int ch;
+ char c;
+ boolean inQuotes = false, escaped = false;
- StringBuilder sb = parsed.sb, tempSB = new StringBuilder();
- boolean go = true;
-
- try {
- while(go && (ch=r.read())>=0) {
- c = (char)ch;
- if(c == '"') {
- if(state.greatExp instanceof LeafExpectations) { // within a set of Tags, make a Quote
- sb.append(c);
- } else {
- if(inQuotes) {
- if(escaped) {
- sb.append('\\');
- sb.append(c);
- escaped = false;
- } else {
- inQuotes = false;
- }
- } else {
- parsed.isString=true;
- inQuotes = true;
- }
- }
- } else if(inQuotes) {
- sb.append(c);
- } else if(c=='&') {
- XmlEscape.xmlEscape(sb,r);
- } else if(c=='\\') {
- escaped=true;
- } else {
- switch(c) {
- case '<':
- DerTag tag=new DerTag().parse(r, tempSB);
- go = state.greatExp.eval(parsed, tag);
- break;
- default:
- // don't add Whitespace to start of SB... saves removing later
- if(sb.length()>0) {
- sb.append(c);
- } else if(!Character.isWhitespace(c)) {
- sb.append(c);
- }
- }
- }
- }
- return parsed;
- } catch (IOException e) {
- throw new ParseException(e);
- }
- }
-
- public static final class DerTag {
- public String name;
- public boolean isEndTag;
- public List<Prop> props;
- private boolean isXmlInfo;
- //private String ns;
-
- public DerTag() {
- name=null;
- isEndTag = false;
- props = null;
- isXmlInfo = false;
- }
-
- public DerTag parse(Reader r, StringBuilder sb) throws ParseException {
- int ch;
- char c;
- boolean inQuotes = false, escaped = false;
- boolean go = true;
- String tag = null;
-
- try {
- if((ch = r.read())<0) throw new ParseException("Reader content ended before complete");
- if(ch=='?') {
- isXmlInfo = true;
- }
- // TODO Check for !-- comments
- do {
- c=(char)ch;
- if(c=='"') {
- if(inQuotes) {
- if(escaped) {
- sb.append(c);
- escaped = false;
- } else {
- inQuotes = false;
- }
- } else {
- inQuotes = true;
- }
- } else if(inQuotes) {
- sb.append(c);
- } else {
- switch(c) {
- case '/':
- isEndTag = true;
- break;
- case ' ':
- endField(tag,sb);
- tag = null;
- break;
- case '>':
- endField(tag,sb);
- go = false;
- break;
- case '=':
- tag = sb.toString();
- sb.setLength(0);
- break;
-// case ':':
-// ns = sb.toString();
-// sb.setLength(0);
-// break;
- case '?':
- if(!isXmlInfo)sb.append(c);
- break;
- default:
- sb.append(c);
- }
- }
- } while(go && (ch=r.read())>=0);
- } catch (IOException e) {
- throw new ParseException(e);
- }
- return this;
- }
+ StringBuilder sb = parsed.sb, tempSB = new StringBuilder();
+ boolean go = true;
+
+ try {
+ while(go && (ch=r.read())>=0) {
+ c = (char)ch;
+ if(c == '"') {
+ if(state.greatExp instanceof LeafExpectations) { // within a set of Tags, make a Quote
+ sb.append(c);
+ } else {
+ if(inQuotes) {
+ if(escaped) {
+ sb.append('\\');
+ sb.append(c);
+ escaped = false;
+ } else {
+ inQuotes = false;
+ }
+ } else {
+ parsed.isString=true;
+ inQuotes = true;
+ }
+ }
+ } else if(inQuotes) {
+ sb.append(c);
+ } else if(c=='&') {
+ XmlEscape.xmlEscape(sb,r);
+ } else if(c=='\\') {
+ escaped=true;
+ } else {
+ switch(c) {
+ case '<':
+ DerTag tag=new DerTag().parse(r, tempSB);
+ go = state.greatExp.eval(parsed, tag);
+ break;
+ default:
+ // don't add Whitespace to start of SB... saves removing later
+ if(sb.length()>0) {
+ sb.append(c);
+ } else if(!Character.isWhitespace(c)) {
+ sb.append(c);
+ }
+ }
+ }
+ }
+ return parsed;
+ } catch (IOException e) {
+ throw new ParseException(e);
+ }
+ }
+
+ public static final class DerTag {
+ public String name;
+ public boolean isEndTag;
+ public List<Prop> props;
+ private boolean isXmlInfo;
+ //private String ns;
+
+ public DerTag() {
+ name=null;
+ isEndTag = false;
+ props = null;
+ isXmlInfo = false;
+ }
+
+ public DerTag parse(Reader r, StringBuilder sb) throws ParseException {
+ int ch;
+ char c;
+ boolean inQuotes = false, escaped = false;
+ boolean go = true;
+ String tag = null;
+
+ try {
+ if((ch = r.read())<0) throw new ParseException("Reader content ended before complete");
+ if(ch=='?') {
+ isXmlInfo = true;
+ }
+ // TODO Check for !-- comments
+ do {
+ c=(char)ch;
+ if(c=='"') {
+ if(inQuotes) {
+ if(escaped) {
+ sb.append(c);
+ escaped = false;
+ } else {
+ inQuotes = false;
+ }
+ } else {
+ inQuotes = true;
+ }
+ } else if(inQuotes) {
+ sb.append(c);
+ } else {
+ switch(c) {
+ case '/':
+ isEndTag = true;
+ break;
+ case ' ':
+ endField(tag,sb);
+ tag = null;
+ break;
+ case '>':
+ endField(tag,sb);
+ go = false;
+ break;
+ case '=':
+ tag = sb.toString();
+ sb.setLength(0);
+ break;
+// case ':':
+// ns = sb.toString();
+// sb.setLength(0);
+// break;
+ case '?':
+ if(!isXmlInfo)sb.append(c);
+ break;
+ default:
+ sb.append(c);
+ }
+ }
+ } while(go && (ch=r.read())>=0);
+ } catch (IOException e) {
+ throw new ParseException(e);
+ }
+ return this;
+ }
- private void endField(String tag, StringBuilder sb) {
- if(name==null) {
- name = sb.toString();
- sb.setLength(0);
- } else {
- String value = sb.toString();
- sb.setLength(0);
- if(tag !=null && value != null) {
- if(props==null)props = new ArrayList<>();
- props.add(new Prop(tag,value));
- }
- }
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(isEndTag?"End":"Start");
- sb.append(" Tag\n");
- sb.append(" Name: ");
- sb.append(name);
- if(props!=null) for(Prop p : props) {
- sb.append("\n ");
- sb.append(p.tag);
- sb.append("=\"");
- sb.append(p.value);
- sb.append('"');
- }
- return sb.toString();
- }
- }
-
- private static class ArrayState {
- public boolean firstObj = true;
- public boolean didNext = false;
- }
+ private void endField(String tag, StringBuilder sb) {
+ if(name==null) {
+ name = sb.toString();
+ sb.setLength(0);
+ } else {
+ String value = sb.toString();
+ sb.setLength(0);
+ if(tag !=null && value != null) {
+ if(props==null)props = new ArrayList<>();
+ props.add(new Prop(tag,value));
+ }
+ }
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(isEndTag?"End":"Start");
+ sb.append(" Tag\n");
+ sb.append(" Name: ");
+ sb.append(name);
+ if(props!=null) for(Prop p : props) {
+ sb.append("\n ");
+ sb.append(p.tag);
+ sb.append("=\"");
+ sb.append(p.value);
+ sb.append('"');
+ }
+ return sb.toString();
+ }
+ }
+
+ private static class ArrayState {
+ public boolean firstObj = true;
+ public boolean didNext = false;
+ }
- public static class State {
- public GreatExpectations greatExp;
- public DerTag unevaluated;
- public Stack<ArrayState> arrayInfo;
- private List<Prop> attribs;
- private int idx;
- public State(JaxInfo ji, DerTag dt) throws ParseException {
- greatExp = new RootExpectations(this, ji, null);
- unevaluated = null;
- attribs = null;;
- }
-
- public boolean hasAttributes() {
- return attribs!=null && idx<attribs.size();
- }
+ public static class State {
+ public GreatExpectations greatExp;
+ public DerTag unevaluated;
+ public Stack<ArrayState> arrayInfo;
+ private List<Prop> attribs;
+ private int idx;
+ public State(JaxInfo ji, DerTag dt) throws ParseException {
+ greatExp = new RootExpectations(this, ji, null);
+ unevaluated = null;
+ attribs = null;;
+ }
+
+ public boolean hasAttributes() {
+ return attribs!=null && idx<attribs.size();
+ }
- public void push(Prop prop) {
- if(attribs==null) {
- attribs = new ArrayList<>();
- idx = 0;
- }
- attribs.add(prop);
- }
-
- public Prop pop() {
- Prop rv = null;
- if(attribs!=null) {
- rv = attribs.get(idx++);
- if(idx>=attribs.size())attribs = null;
- }
- return rv;
- }
- }
-
- private static abstract class GreatExpectations {
- protected JaxInfo ji;
- protected GreatExpectations prev;
- private Map<String,String> ns;
-
- public GreatExpectations(State state, JaxInfo curr, GreatExpectations prev, DerTag derTag) throws ParseException {
- this.prev = prev;
- ns = null;
- ji = getDerived(state, curr,derTag);
- }
-
- public abstract boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException;
+ public void push(Prop prop) {
+ if(attribs==null) {
+ attribs = new ArrayList<>();
+ idx = 0;
+ }
+ attribs.add(prop);
+ }
+
+ public Prop pop() {
+ Prop rv = null;
+ if(attribs!=null) {
+ rv = attribs.get(idx++);
+ if(idx>=attribs.size())attribs = null;
+ }
+ return rv;
+ }
+ }
+
+ private static abstract class GreatExpectations {
+ protected JaxInfo ji;
+ protected GreatExpectations prev;
+ private Map<String,String> ns;
+
+ public GreatExpectations(State state, JaxInfo curr, GreatExpectations prev, DerTag derTag) throws ParseException {
+ this.prev = prev;
+ ns = null;
+ ji = getDerived(state, curr,derTag);
+ }
+
+ public abstract boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException;
- // Recursively look back for any namespaces
- protected Map<String,String> getNS() {
- if(ns!=null)return ns;
- if(prev!=null) {
- return prev.getNS();
- }
- return null;
- }
+ // Recursively look back for any namespaces
+ protected Map<String,String> getNS() {
+ if(ns!=null)return ns;
+ if(prev!=null) {
+ return prev.getNS();
+ }
+ return null;
+ }
- private void addNS(Prop prop) {
- Map<String,String> existingNS = getNS();
- if(ns==null)ns = new HashMap<>();
- // First make a copy of previous NSs so that we have everything we need, but can overwrite, if necessary
- if(existingNS!=null && ns!=existingNS) {
- ns.putAll(ns);
- }
- ns.put(prop.tag, prop.value);
- }
+ private void addNS(Prop prop) {
+ Map<String,String> existingNS = getNS();
+ if(ns==null)ns = new HashMap<>();
+ // First make a copy of previous NSs so that we have everything we need, but can overwrite, if necessary
+ if(existingNS!=null && ns!=existingNS) {
+ ns.putAll(ns);
+ }
+ ns.put(prop.tag, prop.value);
+ }
- private JaxInfo getDerived(State state, JaxInfo ji, DerTag derTag) throws ParseException {
- if(derTag==null)return ji;
-
- List<Prop> props = derTag.props;
-
- Prop derived = null;
- if(props!=null) {
- // Load Namespaces (if any)
- for(Prop prop : props) {
- if(prop.tag.startsWith("xmlns:")) {
- addNS(prop);
- }
- }
- for(Prop prop : props) {
- if(prop.tag.endsWith(":type")) {
- int idx = prop.tag.indexOf(':');
- String potentialNS = "xmlns:"+prop.tag.substring(0,idx);
- Map<String,String> ns = getNS();
- boolean noNamespace = false;
- if(ns==null) {
- noNamespace = true;
- } else {
- String nsVal = ns.get(potentialNS);
- if(nsVal==null) noNamespace = true;
- else {
- derived = new Prop(Parsed.EXTENSION_TAG,prop.value);
- state.push(derived);
- }
- }
- if(noNamespace) {
- throw new ParseException(prop.tag + " utilizes an invalid Namespace prefix");
- }
- } else if(!prop.tag.startsWith("xmlns")) {
- state.push(prop);
- }
- }
- }
- return derived==null?ji:ji.getDerived(derived.value);
- }
- }
-
- private static class RootExpectations extends GreatExpectations {
-
- public RootExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException {
- super(state,curr,prev, null);
- }
-
- // @Override
- public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
- if(derTag.isXmlInfo) {
- parsed.event = START_DOC;
- } else if(ji.name.equals(derTag.name)) {
- if(derTag.isEndTag) {
- parsed.event = END_DOC;
- parsed.state.greatExp = prev;
- } else {
- //parsed.name = derTag.name;
- parsed.event = START_OBJ;
- parsed.state.greatExp = new ObjectExpectations(parsed.state,ji, this, false, derTag);
- }
- }
- return false;
- }
- }
-
- private static class ObjectExpectations extends GreatExpectations {
- private boolean printName;
+ private JaxInfo getDerived(State state, JaxInfo ji, DerTag derTag) throws ParseException {
+ if(derTag==null)return ji;
+
+ List<Prop> props = derTag.props;
+
+ Prop derived = null;
+ if(props!=null) {
+ // Load Namespaces (if any)
+ for(Prop prop : props) {
+ if(prop.tag.startsWith("xmlns:")) {
+ addNS(prop);
+ }
+ }
+ for(Prop prop : props) {
+ if(prop.tag.endsWith(":type")) {
+ int idx = prop.tag.indexOf(':');
+ String potentialNS = "xmlns:"+prop.tag.substring(0,idx);
+ Map<String,String> ns = getNS();
+ boolean noNamespace = false;
+ if(ns==null) {
+ noNamespace = true;
+ } else {
+ String nsVal = ns.get(potentialNS);
+ if(nsVal==null) noNamespace = true;
+ else {
+ derived = new Prop(Parsed.EXTENSION_TAG,prop.value);
+ state.push(derived);
+ }
+ }
+ if(noNamespace) {
+ throw new ParseException(prop.tag + " utilizes an invalid Namespace prefix");
+ }
+ } else if(!prop.tag.startsWith("xmlns")) {
+ state.push(prop);
+ }
+ }
+ }
+ return derived==null?ji:ji.getDerived(derived.value);
+ }
+ }
+
+ private static class RootExpectations extends GreatExpectations {
+
+ public RootExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException {
+ super(state,curr,prev, null);
+ }
+
+ // @Override
+ public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
+ if(derTag.isXmlInfo) {
+ parsed.event = START_DOC;
+ } else if(ji.name.equals(derTag.name)) {
+ if(derTag.isEndTag) {
+ parsed.event = END_DOC;
+ parsed.state.greatExp = prev;
+ } else {
+ //parsed.name = derTag.name;
+ parsed.event = START_OBJ;
+ parsed.state.greatExp = new ObjectExpectations(parsed.state,ji, this, false, derTag);
+ }
+ }
+ return false;
+ }
+ }
+
+ private static class ObjectExpectations extends GreatExpectations {
+ private boolean printName;
- public ObjectExpectations(State state, JaxInfo curr, GreatExpectations prev, boolean printName, DerTag derTag) throws ParseException {
- super(state, curr, prev, derTag);
- this.printName=printName;
- }
+ public ObjectExpectations(State state, JaxInfo curr, GreatExpectations prev, boolean printName, DerTag derTag) throws ParseException {
+ super(state, curr, prev, derTag);
+ this.printName=printName;
+ }
- // @Override
- public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
- if(derTag.isEndTag && ji.name.equals(derTag.name)) {
- parsed.state.greatExp = prev;
- parsed.event = END_OBJ;
- if(printName)parsed.name = ji.name;
- } else {
- //Standard Members
- for(JaxInfo memb : ji.members) {
- if(memb.name.equals(derTag.name)) {
- parsed.name = memb.name;
- if(memb.isArray) {
- parsed.state.unevaluated = derTag; // evaluate within Array Context
- parsed.event = START_ARRAY;
- parsed.state.greatExp = new ArrayExpectations(parsed.state,memb,this);
- return false;
- } else if(memb.isObject()) {
- if(derTag.isEndTag) {
- throw new ParseException("Unexpected End Tag </" + derTag.name + '>');
- } else {
- parsed.event = START_OBJ;
+ // @Override
+ public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
+ if(derTag.isEndTag && ji.name.equals(derTag.name)) {
+ parsed.state.greatExp = prev;
+ parsed.event = END_OBJ;
+ if(printName)parsed.name = ji.name;
+ } else {
+ //Standard Members
+ for(JaxInfo memb : ji.members) {
+ if(memb.name.equals(derTag.name)) {
+ parsed.name = memb.name;
+ if(memb.isArray) {
+ parsed.state.unevaluated = derTag; // evaluate within Array Context
+ parsed.event = START_ARRAY;
+ parsed.state.greatExp = new ArrayExpectations(parsed.state,memb,this);
+ return false;
+ } else if(memb.isObject()) {
+ if(derTag.isEndTag) {
+ throw new ParseException("Unexpected End Tag </" + derTag.name + '>');
+ } else {
+ parsed.event = START_OBJ;
- parsed.state.greatExp = new ObjectExpectations(parsed.state, memb,this,true,derTag);
- return false;
- }
- } else { // a leaf
- if(derTag.isEndTag) {
- throw new ParseException("Misplaced End Tag </" + parsed.name + '>');
- } else {
- parsed.state.greatExp = new LeafExpectations(parsed.state,memb, this);
- return true; // finish out Leaf without returning
- }
- }
- }
- }
+ parsed.state.greatExp = new ObjectExpectations(parsed.state, memb,this,true,derTag);
+ return false;
+ }
+ } else { // a leaf
+ if(derTag.isEndTag) {
+ throw new ParseException("Misplaced End Tag </" + parsed.name + '>');
+ } else {
+ parsed.state.greatExp = new LeafExpectations(parsed.state,memb, this);
+ return true; // finish out Leaf without returning
+ }
+ }
+ }
+ }
- throw new ParseException("Unexpected Tag <" + derTag.name + '>');
- }
- return false;
- }
- }
-
- private static class LeafExpectations extends GreatExpectations {
- public LeafExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException {
- super(state, curr, prev, null);
- }
+ throw new ParseException("Unexpected Tag <" + derTag.name + '>');
+ }
+ return false;
+ }
+ }
+
+ private static class LeafExpectations extends GreatExpectations {
+ public LeafExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException {
+ super(state, curr, prev, null);
+ }
- // @Override
- public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
- if(ji.name.equals(derTag.name) && derTag.isEndTag) {
- parsed.event = NEXT;
- parsed.isString = ji.isString;
- parsed.state.greatExp = prev;
- } else {
- throw new ParseException("Expected </" + ji.name + '>');
- }
- return false;
- }
- }
+ // @Override
+ public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
+ if(ji.name.equals(derTag.name) && derTag.isEndTag) {
+ parsed.event = NEXT;
+ parsed.isString = ji.isString;
+ parsed.state.greatExp = prev;
+ } else {
+ throw new ParseException("Expected </" + ji.name + '>');
+ }
+ return false;
+ }
+ }
- private static class ArrayExpectations extends GreatExpectations {
- public ArrayExpectations(State state, JaxInfo ji, GreatExpectations prev) throws ParseException {
- super(state, ji, prev,null);
- if(state.arrayInfo==null)state.arrayInfo=new Stack<ArrayState>();
- state.arrayInfo.push(new ArrayState());
- }
- // @Override
- public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
- if(ji.name.equals(derTag.name) && !derTag.isEndTag) {
- if(ji.isObject()) {
- if(derTag.isEndTag) {
- throw new ParseException("Unexpected End Tag </" + derTag.name + '>');
- } else {
- ArrayState ai = parsed.state.arrayInfo.peek();
- if(ai.firstObj || ai.didNext) {
- ai.firstObj = false;
- ai.didNext = false;
- parsed.event = START_OBJ;
- parsed.name=derTag.name;
- parsed.state.greatExp = new ObjectExpectations(parsed.state,ji,this,true, derTag);
- } else {
- ai.didNext = true;
- parsed.event = NEXT;
- parsed.state.unevaluated = derTag;
- }
- }
- } else { // a leave
- if(derTag.isEndTag) {
- throw new ParseException("Misplaced End Tag </" + parsed.name + '>');
- } else {
- parsed.state.greatExp = new LeafExpectations(parsed.state, ji, this);
- return true; // finish out Leaf without returning
- }
- }
- } else { // Tag now different... Array is done
- parsed.state.unevaluated = derTag;
- parsed.event=END_ARRAY;
- parsed.state.greatExp = prev;
- parsed.state.arrayInfo.pop();
- }
- return false;
- }
- }
- // @Override
- public Parsed<State> newParsed() throws ParseException {
- return new Parsed<State>(new State(jaxInfo, null));
- }
+ private static class ArrayExpectations extends GreatExpectations {
+ public ArrayExpectations(State state, JaxInfo ji, GreatExpectations prev) throws ParseException {
+ super(state, ji, prev,null);
+ if(state.arrayInfo==null)state.arrayInfo=new Stack<ArrayState>();
+ state.arrayInfo.push(new ArrayState());
+ }
+ // @Override
+ public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException {
+ if(ji.name.equals(derTag.name) && !derTag.isEndTag) {
+ if(ji.isObject()) {
+ if(derTag.isEndTag) {
+ throw new ParseException("Unexpected End Tag </" + derTag.name + '>');
+ } else {
+ ArrayState ai = parsed.state.arrayInfo.peek();
+ if(ai.firstObj || ai.didNext) {
+ ai.firstObj = false;
+ ai.didNext = false;
+ parsed.event = START_OBJ;
+ parsed.name=derTag.name;
+ parsed.state.greatExp = new ObjectExpectations(parsed.state,ji,this,true, derTag);
+ } else {
+ ai.didNext = true;
+ parsed.event = NEXT;
+ parsed.state.unevaluated = derTag;
+ }
+ }
+ } else { // a leave
+ if(derTag.isEndTag) {
+ throw new ParseException("Misplaced End Tag </" + parsed.name + '>');
+ } else {
+ parsed.state.greatExp = new LeafExpectations(parsed.state, ji, this);
+ return true; // finish out Leaf without returning
+ }
+ }
+ } else { // Tag now different... Array is done
+ parsed.state.unevaluated = derTag;
+ parsed.event=END_ARRAY;
+ parsed.state.greatExp = prev;
+ parsed.state.arrayInfo.pop();
+ }
+ return false;
+ }
+ }
+ // @Override
+ public Parsed<State> newParsed() throws ParseException {
+ return new Parsed<State>(new State(jaxInfo, null));
+ }
- // @Override
- public TimeTaken start(Env env) {
- return env.start("Rosetta XML In", Env.XML);
- }
-
+ // @Override
+ public TimeTaken start(Env env) {
+ return env.start("Rosetta XML In", Env.XML);
+ }
+
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java
index 2708aa2f..cb6d2f8c 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java
@@ -22,5 +22,5 @@
package org.onap.aaf.misc.rosetta;
public interface JaxEval{
- public abstract JaxEval eval(Parsed<?> p) throws ParseException;
+ public abstract JaxEval eval(Parsed<?> p) throws ParseException;
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java
index 6c20ba25..edc5f787 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java
@@ -35,214 +35,214 @@ import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
public class JaxInfo {
- private static final String DEFAULT = "##default";
- public static final int DATA = 0;
- public static final int ARRAY = 1;
- public static final int OBJECT = 2;
-
- public final String name;
- public final Class<?> clss;
- public Map<String, JaxInfo> extensions; // Classes, which might be found at runtime, that extend this class. Lazy Instantiation
- public final JaxInfo[] members;
- public final boolean isArray;
- public final boolean isString;
- public final boolean required;
- public final boolean nillable;
- public String ns;
- public boolean isObject() {return members!=null;}
-
- private JaxInfo(String n, String ns, Class<?> c, JaxInfo[] members, boolean string, boolean array, boolean required, boolean nillable) {
- name = n;
- this.ns = ns;
- clss = c;
- this.members = members;
- this.isString = string;
- isArray = array;
- this.required = required;
- this.nillable = nillable;
- extensions = null;
- }
-
+ private static final String DEFAULT = "##default";
+ public static final int DATA = 0;
+ public static final int ARRAY = 1;
+ public static final int OBJECT = 2;
+
+ public final String name;
+ public final Class<?> clss;
+ public Map<String, JaxInfo> extensions; // Classes, which might be found at runtime, that extend this class. Lazy Instantiation
+ public final JaxInfo[] members;
+ public final boolean isArray;
+ public final boolean isString;
+ public final boolean required;
+ public final boolean nillable;
+ public String ns;
+ public boolean isObject() {return members!=null;}
+
+ private JaxInfo(String n, String ns, Class<?> c, JaxInfo[] members, boolean string, boolean array, boolean required, boolean nillable) {
+ name = n;
+ this.ns = ns;
+ clss = c;
+ this.members = members;
+ this.isString = string;
+ isArray = array;
+ this.required = required;
+ this.nillable = nillable;
+ extensions = null;
+ }
+
- public int getType() {
- if(isArray)return ARRAY;
- else if(members!=null)return OBJECT;
- return DATA;
- }
-
- public JaxInfo getDerived(String derivedName) {
- JaxInfo derived;
- // Lazy Instantiation
- if(extensions == null) {
- extensions = new HashMap<>();
- derived = null;
- } else {
- derived = extensions.get(derivedName);
- }
-
- if(derived == null) {
- //TODO for the moment, Classes are in same package
- Package pkg = clss.getPackage();
- try {
- Class<?> dc = getClass().getClassLoader().loadClass(pkg.getName()+'.'+Character.toUpperCase(derivedName.charAt(0))+derivedName.substring(1));
- derived = JaxInfo.build(dc, this); // Use this JAXInfo's name so the tags are correct
- extensions.put(derivedName, derived);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return derived;
- }
+ public int getType() {
+ if(isArray)return ARRAY;
+ else if(members!=null)return OBJECT;
+ return DATA;
+ }
+
+ public JaxInfo getDerived(String derivedName) {
+ JaxInfo derived;
+ // Lazy Instantiation
+ if(extensions == null) {
+ extensions = new HashMap<>();
+ derived = null;
+ } else {
+ derived = extensions.get(derivedName);
+ }
+
+ if(derived == null) {
+ //TODO for the moment, Classes are in same package
+ Package pkg = clss.getPackage();
+ try {
+ Class<?> dc = getClass().getClassLoader().loadClass(pkg.getName()+'.'+Character.toUpperCase(derivedName.charAt(0))+derivedName.substring(1));
+ derived = JaxInfo.build(dc, this); // Use this JAXInfo's name so the tags are correct
+ extensions.put(derivedName, derived);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return derived;
+ }
- public static JaxInfo get(JaxInfo[] fields, String name) {
- for(JaxInfo f : fields) {
- if(name.equals(f.name)) return f;
- }
- return null;
- }
+ public static JaxInfo get(JaxInfo[] fields, String name) {
+ for(JaxInfo f : fields) {
+ if(name.equals(f.name)) return f;
+ }
+ return null;
+ }
- /**
- * Build up JAXB Information (recursively)
- *
- * @param cls
- * @param rootNns
- * @return
- * @throws SecurityException
- * @throws NoSuchFieldException
- * @throws ClassNotFoundException
- * @throws ParseException
- */
- public static JaxInfo build(Class<?> cls, JaxInfo parent) throws NoSuchFieldException, ClassNotFoundException, ParseException {
- return new JaxInfo(parent.name,parent.ns, cls,buildFields(cls,parent.ns),parent.isString, parent.isArray,parent.required,parent.nillable);
- }
- /**
- * Build up JAXB Information (recursively)
- *
- * @param cls
- * @param rootNns
- * @return
- * @throws SecurityException
- * @throws NoSuchFieldException
- * @throws ClassNotFoundException
- * @throws ParseException
- */
- public static JaxInfo build(Class<?> cls, String ... rootNns) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException {
- String defaultNS;
- if(rootNns.length>0 && rootNns[0]!=null) {
- defaultNS = rootNns[0];
- } else {
- Package pkg = cls.getPackage();
- XmlSchema xs = pkg.getAnnotation(XmlSchema.class);
- defaultNS = xs==null?"":xs.namespace();
- }
- String name;
- if(rootNns.length>1) {
- name = rootNns[1];
- } else {
- XmlRootElement xre = cls.getAnnotation(XmlRootElement.class);
- if(xre!=null) {
- name = xre.name();
- } else {
- XmlType xt = cls.getAnnotation(XmlType.class);
- if(xt!=null) {
- name=xt.name();
- } else {
- throw new ParseException("Need a JAXB Object with XmlRootElement, or stipulate in parms");
- }
- }
- }
-
- return new JaxInfo(name,defaultNS, cls,buildFields(cls,defaultNS),false,false,false,false);
- }
-
- // Build up the name and members of this particular class
- // This is recursive, if a member is a JAXB Object as well.
- private static JaxInfo[] buildFields(Class<?> clazz, String defaultNS) throws SecurityException, NoSuchFieldException, ClassNotFoundException {
- ArrayList<JaxInfo> fields = null; // allow for lazy instantiation, because many structures won't have XmlType
- Class<?> cls = clazz;
- // Build up Method names from JAXB Annotations
- XmlType xt;
- while((xt = cls.getAnnotation(XmlType.class))!=null) {
- if(fields==null)fields = new ArrayList<>();
- for(String field : xt.propOrder()) {
- if("".equals(field)) break; // odd bug. "" returned when no fields exist, rather than empty array
- Field rf = cls.getDeclaredField(field);
- Class<?> ft = rf.getType();
-
- boolean required = false;
- boolean nillable = false;
- String xmlName = field;
- String namespace = defaultNS;
-
- XmlElement xe = rf.getAnnotation(XmlElement.class);
- if(xe!=null) {
- xmlName=xe.name();
- required = xe.required();
- nillable = false;
- if(DEFAULT.equals(xmlName)) {
- xmlName = field;
- }
- namespace = xe.namespace();
- if(DEFAULT.equals(namespace)) {
- namespace = defaultNS;
- }
- }
- // If object is a List, then it is possible multiple, per XML/JAXB evaluation
- if(ft.isAssignableFrom(List.class)) {
- Type t = rf.getGenericType();
- String classname = t.toString();
- int start = classname.indexOf('<');
- int end = classname.indexOf('>');
- Class<?> genClass = Class.forName(classname.substring(start+1, end));
- xe = genClass.getAnnotation(XmlElement.class);
- if(xe!=null && !DEFAULT.equals(xe.namespace())) {
- namespace = xe.namespace();
- }
- // add recursed recursed member, marked as array
- fields.add(new JaxInfo(xmlName,namespace,genClass,buildFields(genClass,namespace), genClass.equals(String.class),true,required,nillable));
- } else {
- boolean isString = ft.equals(String.class) || ft.equals(XMLGregorianCalendar.class);
- // add recursed member
- fields.add(new JaxInfo(xmlName,namespace,ft,buildFields(ft,namespace),isString,false,required,nillable));
- }
- }
- cls = cls.getSuperclass();
- };
- if(fields!=null) {
- JaxInfo[] rv = new JaxInfo[fields.size()];
- fields.toArray(rv);
- return rv;
- } else {
- return null;
- }
- }
+ /**
+ * Build up JAXB Information (recursively)
+ *
+ * @param cls
+ * @param rootNns
+ * @return
+ * @throws SecurityException
+ * @throws NoSuchFieldException
+ * @throws ClassNotFoundException
+ * @throws ParseException
+ */
+ public static JaxInfo build(Class<?> cls, JaxInfo parent) throws NoSuchFieldException, ClassNotFoundException, ParseException {
+ return new JaxInfo(parent.name,parent.ns, cls,buildFields(cls,parent.ns),parent.isString, parent.isArray,parent.required,parent.nillable);
+ }
+ /**
+ * Build up JAXB Information (recursively)
+ *
+ * @param cls
+ * @param rootNns
+ * @return
+ * @throws SecurityException
+ * @throws NoSuchFieldException
+ * @throws ClassNotFoundException
+ * @throws ParseException
+ */
+ public static JaxInfo build(Class<?> cls, String ... rootNns) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException {
+ String defaultNS;
+ if(rootNns.length>0 && rootNns[0]!=null) {
+ defaultNS = rootNns[0];
+ } else {
+ Package pkg = cls.getPackage();
+ XmlSchema xs = pkg.getAnnotation(XmlSchema.class);
+ defaultNS = xs==null?"":xs.namespace();
+ }
+ String name;
+ if(rootNns.length>1) {
+ name = rootNns[1];
+ } else {
+ XmlRootElement xre = cls.getAnnotation(XmlRootElement.class);
+ if(xre!=null) {
+ name = xre.name();
+ } else {
+ XmlType xt = cls.getAnnotation(XmlType.class);
+ if(xt!=null) {
+ name=xt.name();
+ } else {
+ throw new ParseException("Need a JAXB Object with XmlRootElement, or stipulate in parms");
+ }
+ }
+ }
+
+ return new JaxInfo(name,defaultNS, cls,buildFields(cls,defaultNS),false,false,false,false);
+ }
+
+ // Build up the name and members of this particular class
+ // This is recursive, if a member is a JAXB Object as well.
+ private static JaxInfo[] buildFields(Class<?> clazz, String defaultNS) throws SecurityException, NoSuchFieldException, ClassNotFoundException {
+ ArrayList<JaxInfo> fields = null; // allow for lazy instantiation, because many structures won't have XmlType
+ Class<?> cls = clazz;
+ // Build up Method names from JAXB Annotations
+ XmlType xt;
+ while((xt = cls.getAnnotation(XmlType.class))!=null) {
+ if(fields==null)fields = new ArrayList<>();
+ for(String field : xt.propOrder()) {
+ if("".equals(field)) break; // odd bug. "" returned when no fields exist, rather than empty array
+ Field rf = cls.getDeclaredField(field);
+ Class<?> ft = rf.getType();
+
+ boolean required = false;
+ boolean nillable = false;
+ String xmlName = field;
+ String namespace = defaultNS;
+
+ XmlElement xe = rf.getAnnotation(XmlElement.class);
+ if(xe!=null) {
+ xmlName=xe.name();
+ required = xe.required();
+ nillable = false;
+ if(DEFAULT.equals(xmlName)) {
+ xmlName = field;
+ }
+ namespace = xe.namespace();
+ if(DEFAULT.equals(namespace)) {
+ namespace = defaultNS;
+ }
+ }
+ // If object is a List, then it is possible multiple, per XML/JAXB evaluation
+ if(ft.isAssignableFrom(List.class)) {
+ Type t = rf.getGenericType();
+ String classname = t.toString();
+ int start = classname.indexOf('<');
+ int end = classname.indexOf('>');
+ Class<?> genClass = Class.forName(classname.substring(start+1, end));
+ xe = genClass.getAnnotation(XmlElement.class);
+ if(xe!=null && !DEFAULT.equals(xe.namespace())) {
+ namespace = xe.namespace();
+ }
+ // add recursed recursed member, marked as array
+ fields.add(new JaxInfo(xmlName,namespace,genClass,buildFields(genClass,namespace), genClass.equals(String.class),true,required,nillable));
+ } else {
+ boolean isString = ft.equals(String.class) || ft.equals(XMLGregorianCalendar.class);
+ // add recursed member
+ fields.add(new JaxInfo(xmlName,namespace,ft,buildFields(ft,namespace),isString,false,required,nillable));
+ }
+ }
+ cls = cls.getSuperclass();
+ };
+ if(fields!=null) {
+ JaxInfo[] rv = new JaxInfo[fields.size()];
+ fields.toArray(rv);
+ return rv;
+ } else {
+ return null;
+ }
+ }
- public StringBuilder dump(StringBuilder sb, int idx) {
- for(int i=0;i<idx;++i)sb.append(' ');
- sb.append("Field ");
- sb.append(name);
- sb.append(" [");
- sb.append(clss.getName());
- sb.append("] ");
- if(isArray)sb.append(" (array)");
- if(required)sb.append(" (required)");
- if(nillable)sb.append(" (nillable)");
- if(members!=null) {
- for(JaxInfo f : members) {
- sb.append('\n');
- f.dump(sb,idx+2);
- }
- }
- return sb;
- }
+ public StringBuilder dump(StringBuilder sb, int idx) {
+ for(int i=0;i<idx;++i)sb.append(' ');
+ sb.append("Field ");
+ sb.append(name);
+ sb.append(" [");
+ sb.append(clss.getName());
+ sb.append("] ");
+ if(isArray)sb.append(" (array)");
+ if(required)sb.append(" (required)");
+ if(nillable)sb.append(" (nillable)");
+ if(members!=null) {
+ for(JaxInfo f : members) {
+ sb.append('\n');
+ f.dump(sb,idx+2);
+ }
+ }
+ return sb;
+ }
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("Structure of ");
- sb.append(clss.getName());
- sb.append('\n');
- dump(sb,2);
- return sb.toString();
- }
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Structure of ");
+ sb.append(clss.getName());
+ sb.append('\n');
+ dump(sb,2);
+ return sb.toString();
+ }
} \ No newline at end of file
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java
index 04d61581..6a779fb8 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java
@@ -38,54 +38,54 @@ import javax.xml.bind.annotation.XmlType;
* @param <T>
*/
public class JaxSet<T> {
- private static Map<Class<?>,JaxSet<?>> jsets = new HashMap<>();
- private Map<String,Setter<T>> members;
+ private static Map<Class<?>,JaxSet<?>> jsets = new HashMap<>();
+ private Map<String,Setter<T>> members;
- private JaxSet(Class<?> cls) {
- members = new TreeMap<>();
- XmlType xmltype = cls.getAnnotation(XmlType.class);
- Class<?> paramType[] = new Class[] {String.class};
- for(String str : xmltype.propOrder()) {
- try {
- String setName = "set" + Character.toUpperCase(str.charAt(0)) + str.subSequence(1, str.length());
- Method meth = cls.getMethod(setName,paramType );
- if(meth!=null) {
- members.put(str, new Setter<T>(meth) {
- public void set(T o, Object t) throws ParseException {
- try {
- this.meth.invoke(o, t);
- } catch (Exception e) {
- throw new ParseException(e);
- }
- }
- });
- }
- } catch (Exception e) {
- // oops
- }
- }
- }
-
- public static abstract class Setter<O> {
- protected final Method meth;
- public Setter(Method meth) {
- this.meth = meth;
- }
- public abstract void set(O o, Object obj) throws ParseException;
- }
+ private JaxSet(Class<?> cls) {
+ members = new TreeMap<>();
+ XmlType xmltype = cls.getAnnotation(XmlType.class);
+ Class<?> paramType[] = new Class[] {String.class};
+ for(String str : xmltype.propOrder()) {
+ try {
+ String setName = "set" + Character.toUpperCase(str.charAt(0)) + str.subSequence(1, str.length());
+ Method meth = cls.getMethod(setName,paramType );
+ if(meth!=null) {
+ members.put(str, new Setter<T>(meth) {
+ public void set(T o, Object t) throws ParseException {
+ try {
+ this.meth.invoke(o, t);
+ } catch (Exception e) {
+ throw new ParseException(e);
+ }
+ }
+ });
+ }
+ } catch (Exception e) {
+ // oops
+ }
+ }
+ }
+
+ public static abstract class Setter<O> {
+ protected final Method meth;
+ public Setter(Method meth) {
+ this.meth = meth;
+ }
+ public abstract void set(O o, Object obj) throws ParseException;
+ }
- public static <X> JaxSet<X> get(Class<?> cls) {
- synchronized(jsets) {
- @SuppressWarnings("unchecked")
- JaxSet<X> js = (JaxSet<X>)jsets.get(cls);
- if(js == null) {
- jsets.put(cls, js = new JaxSet<>(cls));
- }
- return js;
- }
- }
+ public static <X> JaxSet<X> get(Class<?> cls) {
+ synchronized(jsets) {
+ @SuppressWarnings("unchecked")
+ JaxSet<X> js = (JaxSet<X>)jsets.get(cls);
+ if(js == null) {
+ jsets.put(cls, js = new JaxSet<>(cls));
+ }
+ return js;
+ }
+ }
- public Setter<T> get(String key) {
- return members.get(key);
- }
+ public Setter<T> get(String key) {
+ return members.get(key);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java
index 51cec078..5e03ac91 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java
@@ -32,82 +32,82 @@ package org.onap.aaf.misc.rosetta;
*
*/
public class Ladder<T> {
- public static final int DEFAULT_INIT_SIZE=8;
- private final int init_size;
- private int rung; // as in ladder
- private Object[] struts;
+ public static final int DEFAULT_INIT_SIZE=8;
+ private final int init_size;
+ private int rung; // as in ladder
+ private Object[] struts;
- public Ladder() {
- rung=0;
- init_size = DEFAULT_INIT_SIZE;
- struts=new Object[init_size];
- }
+ public Ladder() {
+ rung=0;
+ init_size = DEFAULT_INIT_SIZE;
+ struts=new Object[init_size];
+ }
- public Ladder(int initSize) {
- rung=0;
- init_size = initSize;
- struts=new Object[init_size];
- }
+ public Ladder(int initSize) {
+ rung=0;
+ init_size = initSize;
+ struts=new Object[init_size];
+ }
- public void bottom() {
- rung = 0;
- }
-
- public void top() {
- rung = struts.length-1;
- while(rung>0 && struts[rung]==null)--rung;
- }
-
- public int howHigh() {
- return rung;
- }
-
- public void jumpTo(int rung) {
- if(rung>=struts.length) {
- Object[] temp = new Object[init_size*((rung/init_size)+1)];
- System.arraycopy(struts, 0, temp, 0, struts.length);
- struts = temp;
- }
- this.rung = rung;
- }
-
- public int height() {
- return struts.length;
- }
-
- public void cutTo(int rungs) {
- Object[] temp = new Object[rungs];
- System.arraycopy(struts, 0, temp, 0, Math.min(rungs, struts.length));
- struts = temp;
- }
-
- public void ascend() {
- ++rung;
- if(rung>=struts.length) {
- Object[] temp = new Object[struts.length+init_size];
- System.arraycopy(struts, 0, temp, 0, struts.length);
- struts = temp;
- }
- }
-
- public void descend() {
- --rung;
- }
-
- @SuppressWarnings("unchecked")
- public T peek() {
- return (T)struts[rung];
- }
-
- public void push(T t) {
- struts[rung]=t;
- }
-
- @SuppressWarnings("unchecked")
- public T pop() {
- T t = (T)struts[rung];
- struts[rung]=null;
- return t;
- }
+ public void bottom() {
+ rung = 0;
+ }
+
+ public void top() {
+ rung = struts.length-1;
+ while(rung>0 && struts[rung]==null)--rung;
+ }
+
+ public int howHigh() {
+ return rung;
+ }
+
+ public void jumpTo(int rung) {
+ if(rung>=struts.length) {
+ Object[] temp = new Object[init_size*((rung/init_size)+1)];
+ System.arraycopy(struts, 0, temp, 0, struts.length);
+ struts = temp;
+ }
+ this.rung = rung;
+ }
+
+ public int height() {
+ return struts.length;
+ }
+
+ public void cutTo(int rungs) {
+ Object[] temp = new Object[rungs];
+ System.arraycopy(struts, 0, temp, 0, Math.min(rungs, struts.length));
+ struts = temp;
+ }
+
+ public void ascend() {
+ ++rung;
+ if(rung>=struts.length) {
+ Object[] temp = new Object[struts.length+init_size];
+ System.arraycopy(struts, 0, temp, 0, struts.length);
+ struts = temp;
+ }
+ }
+
+ public void descend() {
+ --rung;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T peek() {
+ return (T)struts[rung];
+ }
+
+ public void push(T t) {
+ struts[rung]=t;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T pop() {
+ T t = (T)struts[rung];
+ struts[rung]=null;
+ return t;
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java
index 595bc630..4b8d2bf3 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java
@@ -29,57 +29,57 @@ import org.onap.aaf.misc.env.TimeTaken;
public abstract class Marshal<T> implements Parse<T, Marshal.State> {
- /* (non-Javadoc)
- * @see org.onap.aaf.misc.rosetta.Parse#newParsed()
- */
- @Override
- public Parsed<State> newParsed() throws ParseException {
- return new Parsed<State>(new State());
- }
+ /* (non-Javadoc)
+ * @see org.onap.aaf.misc.rosetta.Parse#newParsed()
+ */
+ @Override
+ public Parsed<State> newParsed() throws ParseException {
+ return new Parsed<State>(new State());
+ }
- @Override
- public TimeTaken start(Env env) {
- //TODO is a way to mark not-JSON?
- return env.start("Rosetta Marshal", Env.JSON);
- };
+ @Override
+ public TimeTaken start(Env env) {
+ //TODO is a way to mark not-JSON?
+ return env.start("Rosetta Marshal", Env.JSON);
+ };
- public static class State {
- // Note: Need a STATEFUL stack... one that will remain stateful until marked as finished
- // "finished" is know by Iterators with no more to do/null
- // Thus the concept of "Ladder", which one ascends and decends
- public Ladder<Iterator<?>> ladder = new Ladder<Iterator<?>>();
- public boolean smallest = true;
- }
+ public static class State {
+ // Note: Need a STATEFUL stack... one that will remain stateful until marked as finished
+ // "finished" is know by Iterators with no more to do/null
+ // Thus the concept of "Ladder", which one ascends and decends
+ public Ladder<Iterator<?>> ladder = new Ladder<Iterator<?>>();
+ public boolean smallest = true;
+ }
- public static final Iterator<Void> DONE_ITERATOR = new Iterator<Void>() {
- @Override
- public boolean hasNext() {
- return false;
- }
+ public static final Iterator<Void> DONE_ITERATOR = new Iterator<Void>() {
+ @Override
+ public boolean hasNext() {
+ return false;
+ }
- @Override
- public Void next() {
- if(!hasNext()) {
- throw new NoSuchElementException();
- }
- return null;
- }
+ @Override
+ public Void next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return null;
+ }
- @Override
- public void remove() {
- }
- };
+ @Override
+ public void remove() {
+ }
+ };
- /**
- * Typical definition of Done is when Iterator in Ladder is "DONE_ITERATOR"
- *
- * It is important, however, that the "Ladder Rung" is set to the right level.
- *
- * @param state
- * @return
- */
- public boolean amFinished(State state) {
- return DONE_ITERATOR.equals(state.ladder.peek());
- }
+ /**
+ * Typical definition of Done is when Iterator in Ladder is "DONE_ITERATOR"
+ *
+ * It is important, however, that the "Ladder Rung" is set to the right level.
+ *
+ * @param state
+ * @return
+ */
+ public boolean amFinished(State state) {
+ return DONE_ITERATOR.equals(state.ladder.peek());
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java
index 38b021ea..d36c07ec 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java
@@ -29,38 +29,38 @@ import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
public class Nulls {
- public static final Parse<Reader, ?> IN = new Parse<Reader, Void>() {
+ public static final Parse<Reader, ?> IN = new Parse<Reader, Void>() {
- // @Override
- public Parsed<Void> parse(Reader r, Parsed<Void> parsed)throws ParseException {
- parsed.event = Parse.END_DOC;
- return parsed;
- }
+ // @Override
+ public Parsed<Void> parse(Reader r, Parsed<Void> parsed)throws ParseException {
+ parsed.event = Parse.END_DOC;
+ return parsed;
+ }
- // @Override
- public Parsed<Void> newParsed() {
- Parsed<Void> parsed = new Parsed<Void>();
- parsed.event = Parse.END_DOC;
- return parsed;
- }
+ // @Override
+ public Parsed<Void> newParsed() {
+ Parsed<Void> parsed = new Parsed<Void>();
+ parsed.event = Parse.END_DOC;
+ return parsed;
+ }
- // @Override
- public TimeTaken start(Env env) {
- return env.start("IN", Env.SUB);
- }
-
- };
-
- public static final Out OUT = new Out() {
+ // @Override
+ public TimeTaken start(Env env) {
+ return env.start("IN", Env.SUB);
+ }
+
+ };
+
+ public static final Out OUT = new Out() {
- // @Override
- public <IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options)throws IOException, ParseException {
- }
- @Override
- public String logName() {
- return "Rosetta NULL";
- }
+ // @Override
+ public <IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options)throws IOException, ParseException {
+ }
+ @Override
+ public String logName() {
+ return "Rosetta NULL";
+ }
- };
+ };
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java
index 567a6261..aa2b2992 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java
@@ -27,17 +27,17 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
public abstract class Out {
- public abstract<IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException;
-
- public<IN,S> void extract(IN in, OutputStream os, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException {
- Writer w = new OutputStreamWriter(os);
- try {
- extract(in, w, parse, options);
- } finally {
- w.flush();
- }
- }
-
- public abstract String logName();
-
+ public abstract<IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException;
+
+ public<IN,S> void extract(IN in, OutputStream os, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException {
+ Writer w = new OutputStreamWriter(os);
+ try {
+ extract(in, w, parse, options);
+ } finally {
+ w.flush();
+ }
+ }
+
+ public abstract String logName();
+
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java
index db7b956c..2716c8be 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java
@@ -25,27 +25,27 @@ import java.io.IOException;
import java.io.Writer;
public class OutJax extends Out {
- private JaxEval jaxEval;
-
- public OutJax(JaxEval je) {
- this.jaxEval = je;
- }
-
- @Override
- public <IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean... options) throws IOException, ParseException {
- Parsed<S> p = parse.newParsed();
- JaxEval je = this.jaxEval;
- while((p = parse.parse(in,p.reuse())).valid()) {
- if(je==null)throw new ParseException("Incomplete content");
- je = je.eval(p);
- }
-
- }
-
- @Override
- public String logName() {
- return "Rosetta JAX";
- }
+ private JaxEval jaxEval;
+
+ public OutJax(JaxEval je) {
+ this.jaxEval = je;
+ }
+
+ @Override
+ public <IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean... options) throws IOException, ParseException {
+ Parsed<S> p = parse.newParsed();
+ JaxEval je = this.jaxEval;
+ while((p = parse.parse(in,p.reuse())).valid()) {
+ if(je==null)throw new ParseException("Incomplete content");
+ je = je.eval(p);
+ }
+
+ }
+
+ @Override
+ public String logName() {
+ return "Rosetta JAX";
+ }
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java
index 2340bdb6..d0a26784 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java
@@ -29,204 +29,204 @@ import org.onap.aaf.misc.env.util.IndentPrintWriter;
public class OutJson extends Out {
- @Override
- public<IN,S> void extract(IN in, Writer writer, Parse<IN, S> prs, boolean ... options) throws IOException, ParseException {
- Parsed<S> p = prs.newParsed();
- IndentPrintWriter ipw;
- if(options.length>0 && options[0]) { // is Pretty
- ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer);
- writer = ipw;
- } else {
- ipw = null;
- }
-
- // If it's a fragment, print first Object Name. If root Object, skip first name
- Stack<LevelStack> jsonLevel = new Stack<LevelStack>();
- jsonLevel.push(new LevelStack(options.length>1 && options[1]));
- boolean print = true, hadData=false;
- char afterName=0, beforeName=0, maybe = 0, prev=0;
-
- int count = 0;
- while((p = prs.parse(in,p.reuse())).valid()) {
- ++count;
- switch(p.event) {
- case 1:
- continue;
- case 2:
- if(count==2) { // it's empty, write open/close on it's own
- writer.append('{');
- writer.append('}');
- }
- writer.flush();
- return;
- case '{':
- afterName = '{';
- if(jsonLevel.peek().printObjectName) {
- print = true;
- } else { // don't print names on first
- print=false;
- }
- maybe=jsonLevel.peek().listItem();
- jsonLevel.push(new LevelStack(true));
- break;
- case '}':
- if(p.hasData()) { // if we have data, we print that, so may need to prepend a comma.
- maybe = jsonLevel.peek().listItem();
- } else { // No data means just print,
- p.name = ""; // XML tags come through with names, but no data
- }
- print = true;
- jsonLevel.pop();
- afterName = p.event;
- break;
- case '[':
- afterName = p.event;
- if((prev==',' && !hadData) || prev==']')maybe=',';
- else maybe = jsonLevel.peek().listItem();
+ @Override
+ public<IN,S> void extract(IN in, Writer writer, Parse<IN, S> prs, boolean ... options) throws IOException, ParseException {
+ Parsed<S> p = prs.newParsed();
+ IndentPrintWriter ipw;
+ if(options.length>0 && options[0]) { // is Pretty
+ ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer);
+ writer = ipw;
+ } else {
+ ipw = null;
+ }
+
+ // If it's a fragment, print first Object Name. If root Object, skip first name
+ Stack<LevelStack> jsonLevel = new Stack<LevelStack>();
+ jsonLevel.push(new LevelStack(options.length>1 && options[1]));
+ boolean print = true, hadData=false;
+ char afterName=0, beforeName=0, maybe = 0, prev=0;
+
+ int count = 0;
+ while((p = prs.parse(in,p.reuse())).valid()) {
+ ++count;
+ switch(p.event) {
+ case 1:
+ continue;
+ case 2:
+ if(count==2) { // it's empty, write open/close on it's own
+ writer.append('{');
+ writer.append('}');
+ }
+ writer.flush();
+ return;
+ case '{':
+ afterName = '{';
+ if(jsonLevel.peek().printObjectName) {
+ print = true;
+ } else { // don't print names on first
+ print=false;
+ }
+ maybe=jsonLevel.peek().listItem();
+ jsonLevel.push(new LevelStack(true));
+ break;
+ case '}':
+ if(p.hasData()) { // if we have data, we print that, so may need to prepend a comma.
+ maybe = jsonLevel.peek().listItem();
+ } else { // No data means just print,
+ p.name = ""; // XML tags come through with names, but no data
+ }
+ print = true;
+ jsonLevel.pop();
+ afterName = p.event;
+ break;
+ case '[':
+ afterName = p.event;
+ if((prev==',' && !hadData) || prev==']')maybe=',';
+ else maybe = jsonLevel.peek().listItem();
- jsonLevel.push(new LevelStack(false));
- print=true;
- break;
- case ']':
- afterName = p.event;
- if(p.hasData()) {
- if(prev==',' && !hadData)maybe=',';
- else maybe = jsonLevel.peek().listItem();
- } else {
- p.name = ""; // XML tags come through with names, but no data
- }
- jsonLevel.pop();
+ jsonLevel.push(new LevelStack(false));
+ print=true;
+ break;
+ case ']':
+ afterName = p.event;
+ if(p.hasData()) {
+ if(prev==',' && !hadData)maybe=',';
+ else maybe = jsonLevel.peek().listItem();
+ } else {
+ p.name = ""; // XML tags come through with names, but no data
+ }
+ jsonLevel.pop();
- print = true;
- break;
- case 3:
- case ',':
- if(!p.hasData()) {
- p.isString=false;
- print=false;
- } else {
- maybe=jsonLevel.peek().listItem();
- print = true;
- }
- break;
- default:
- print = true;
- }
-
- if(maybe!=0) {
- if(ipw==null)writer.append(maybe);
- else ipw.println(maybe);
- maybe = 0;
- }
-
- if(beforeName!=0) {
- if(ipw==null)writer.append(beforeName);
- else ipw.println(beforeName);
- beforeName = 0;
- }
- if(print) {
- if(p.hasName()) {
- writer.append('"');
- if(p.event==3)writer.append("__");
- writer.append(p.name);
- writer.append("\":");
- }
- if(p.hasData()) {
- if(p.isString) {
- writer.append('"');
- escapedWrite(writer, p.sb);
- writer.append('"');
- } else if(p.sb.length()>0) {
- writer.append(p.sb);
- }
- }
- }
- if(afterName!=0) {
- if(ipw==null)writer.append(afterName);
- else {
- switch(afterName) {
- case '{':
- ipw.println(afterName);
- ipw.inc();
- break;
- case '}':
- ipw.dec();
- ipw.println();
- ipw.print(afterName);
- break;
- case ']':
- if(prev=='}' || prev==',')ipw.println();
- ipw.dec();
- ipw.print(afterName);
- break;
+ print = true;
+ break;
+ case 3:
+ case ',':
+ if(!p.hasData()) {
+ p.isString=false;
+ print=false;
+ } else {
+ maybe=jsonLevel.peek().listItem();
+ print = true;
+ }
+ break;
+ default:
+ print = true;
+ }
+
+ if(maybe!=0) {
+ if(ipw==null)writer.append(maybe);
+ else ipw.println(maybe);
+ maybe = 0;
+ }
+
+ if(beforeName!=0) {
+ if(ipw==null)writer.append(beforeName);
+ else ipw.println(beforeName);
+ beforeName = 0;
+ }
+ if(print) {
+ if(p.hasName()) {
+ writer.append('"');
+ if(p.event==3)writer.append("__");
+ writer.append(p.name);
+ writer.append("\":");
+ }
+ if(p.hasData()) {
+ if(p.isString) {
+ writer.append('"');
+ escapedWrite(writer, p.sb);
+ writer.append('"');
+ } else if(p.sb.length()>0) {
+ writer.append(p.sb);
+ }
+ }
+ }
+ if(afterName!=0) {
+ if(ipw==null)writer.append(afterName);
+ else {
+ switch(afterName) {
+ case '{':
+ ipw.println(afterName);
+ ipw.inc();
+ break;
+ case '}':
+ ipw.dec();
+ ipw.println();
+ ipw.print(afterName);
+ break;
+ case ']':
+ if(prev=='}' || prev==',')ipw.println();
+ ipw.dec();
+ ipw.print(afterName);
+ break;
- case ',':
- ipw.println(afterName);
- break;
- default:
- ipw.print(afterName);
- }
- }
- afterName = 0;
- }
-
- if(ipw!=null) {
- switch(p.event) {
- case '[':
- ipw.inc();
- ipw.println();
- break;
- }
- }
- prev = p.event;
- hadData = p.hasData();
+ case ',':
+ ipw.println(afterName);
+ break;
+ default:
+ ipw.print(afterName);
+ }
+ }
+ afterName = 0;
+ }
+
+ if(ipw!=null) {
+ switch(p.event) {
+ case '[':
+ ipw.inc();
+ ipw.println();
+ break;
+ }
+ }
+ prev = p.event;
+ hadData = p.hasData();
- }
- writer.flush();
- }
+ }
+ writer.flush();
+ }
- private void escapedWrite(Writer writer, StringBuilder sb) throws IOException {
- char c;
- for(int i=0;i<sb.length();++i) {
- switch(c=sb.charAt(i)) {
- case '\\':
- writer.append(c);
- if(i<sb.length()) {
- c=sb.charAt(++i);
- writer.append(c);
- }
- break;
- case '"':
- writer.append('\\');
- // Passthrough on purpose
- default:
- writer.append(c);
- }
- }
+ private void escapedWrite(Writer writer, StringBuilder sb) throws IOException {
+ char c;
+ for(int i=0;i<sb.length();++i) {
+ switch(c=sb.charAt(i)) {
+ case '\\':
+ writer.append(c);
+ if(i<sb.length()) {
+ c=sb.charAt(++i);
+ writer.append(c);
+ }
+ break;
+ case '"':
+ writer.append('\\');
+ // Passthrough on purpose
+ default:
+ writer.append(c);
+ }
+ }
-
- }
+
+ }
- @Override
- public String logName() {
- return "Rosetta JSON";
- }
+ @Override
+ public String logName() {
+ return "Rosetta JSON";
+ }
- private static class LevelStack {
- public boolean printObjectName=false;
- private boolean first_n_List=true;
-
- public LevelStack(boolean printObjectName) {
- this.printObjectName = printObjectName;
- }
-
- public char listItem() {
- if(first_n_List) {
- first_n_List=false;
- return 0;
- } else {
- return ',';
- }
- }
- }
+ private static class LevelStack {
+ public boolean printObjectName=false;
+ private boolean first_n_List=true;
+
+ public LevelStack(boolean printObjectName) {
+ this.printObjectName = printObjectName;
+ }
+
+ public char listItem() {
+ if(first_n_List) {
+ first_n_List=false;
+ return 0;
+ } else {
+ return ',';
+ }
+ }
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java
index bf833f7b..babf53de 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java
@@ -26,20 +26,20 @@ import java.io.Writer;
public class OutRaw extends Out{
- @Override
- public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException {
- Parsed<S> p = prs.newParsed();
-
- while((p = prs.parse(in,p.reuse())).valid()) {
- writer.append(p.toString());
- writer.append('\n');
- }
- }
-
- @Override
- public String logName() {
- return "Rosetta RAW";
- }
+ @Override
+ public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException {
+ Parsed<S> p = prs.newParsed();
+
+ while((p = prs.parse(in,p.reuse())).valid()) {
+ writer.append(p.toString());
+ writer.append('\n');
+ }
+ }
+
+ @Override
+ public String logName() {
+ return "Rosetta RAW";
+ }
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java
index 8557c584..a887cb96 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java
@@ -33,193 +33,193 @@ import org.onap.aaf.misc.env.util.IndentPrintWriter;
import org.onap.aaf.misc.env.util.StringBuilderWriter;
public class OutXML extends Out{
- private static final String XMLNS_XSI = "xmlns:xsi";
- public static final String XML_INFO = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
- public static final String XML_SCHEMA_INSTANCE = "http://www.w3.org/2001/XMLSchema-instance";
-
- private String root;
- private List<Prop> props;
+ private static final String XMLNS_XSI = "xmlns:xsi";
+ public static final String XML_INFO = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
+ public static final String XML_SCHEMA_INSTANCE = "http://www.w3.org/2001/XMLSchema-instance";
+
+ private String root;
+ private List<Prop> props;
- public OutXML(String root, String ... params) {
- this.root = root;
- props = new ArrayList<>();
- for(String p : params) {
- String[] tv=p.split("=");
- if(tv.length==2)
- props.add(new Prop(tv[0],tv[1]));
- }
- }
-
- public OutXML(JaxInfo jaxInfo) {
- this(jaxInfo.name,genNS(jaxInfo));
- }
-
- public OutXML(InXML inXML) {
- this(inXML.jaxInfo.name,genNS(inXML.jaxInfo));
- }
-
- private static String[] genNS(JaxInfo jaxInfo) {
- return new String[] {"xmlns=" + jaxInfo.ns};
- }
-
-
- @Override
- public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException {
- Parsed<S> p = prs.newParsed();
- Stack<Level> stack = new Stack<Level>();
- // If it's an IndentPrintWriter, it is pretty printing.
- boolean pretty = (options.length>0&&options[0]);
-
- IndentPrintWriter ipw;
- if(pretty) {
- if(writer instanceof IndentPrintWriter) {
- ipw = (IndentPrintWriter)writer;
- } else {
- writer = ipw = new IndentPrintWriter(writer);
- }
- } else {
- ipw=null;
- }
- boolean closeTag = false;
- Level level = new Level(null);
- while((p = prs.parse(in,p.reuse())).valid()) {
- if(!p.hasName() && level.multi!=null) {
- p.name=level.multi;
- }
- if(closeTag && p.event!=Parse.ATTRIB) {
- writer.append('>');
- if(pretty)writer.append('\n');
- closeTag = false;
- }
- switch(p.event) {
- case Parse.START_DOC:
- if(!(options.length>1&&options[1])) // if not a fragment, print XML Info data
- if(pretty)ipw.println(XML_INFO);
- else writer.append(XML_INFO);
- break;
- case Parse.END_DOC:
- break;
- case Parse.START_OBJ:
- stack.push(level);
- level = new Level(level);
- if(p.hasName()) {
- closeTag = tag(writer,level.sbw,pretty,pretty,p.name,null);
- } else if(root!=null && stack.size()==1) { // first Object
- closeTag = tag(writer,level.sbw,pretty,pretty,root,null);
- // Write Root Props
- for(Prop prop : props) {
- attrib(writer,pretty,prop.tag, prop.value,level);
- }
- }
- if(pretty)ipw.inc();
- break;
- case Parse.END_OBJ:
- if(p.hasData())
- closeTag = tag(writer,writer,pretty,false,p.name, XmlEscape.convert(p.sb));
- if(pretty)ipw.dec();
- writer.append(level.sbw.getBuffer());
- level = stack.pop();
- break;
- case Parse.START_ARRAY:
- level.multi = p.name;
- break;
- case Parse.END_ARRAY:
- if(p.hasData())
- closeTag = tag(writer,writer,pretty,false, p.name, XmlEscape.convert(p.sb));
- level.multi=null;
- break;
- case Parse.ATTRIB:
- if(p.hasData())
- attrib(writer,pretty,p.name, XmlEscape.convert(p.sb), level);
- break;
- case Parse.NEXT:
- if(p.hasData())
- closeTag = tag(writer,writer,pretty, false,p.name, XmlEscape.convert(p.sb));
- break;
- }
- }
- writer.append(level.sbw.getBuffer());
- writer.flush();
- }
-
- private class Level {
- public final StringBuilderWriter sbw;
- public String multi;
- private Level prev;
- private Map<String,String> nses;
-
- public Level(Level level) {
- sbw = new StringBuilderWriter();
- multi = null;
- prev = level;
- }
+ public OutXML(String root, String ... params) {
+ this.root = root;
+ props = new ArrayList<>();
+ for(String p : params) {
+ String[] tv=p.split("=");
+ if(tv.length==2)
+ props.add(new Prop(tv[0],tv[1]));
+ }
+ }
+
+ public OutXML(JaxInfo jaxInfo) {
+ this(jaxInfo.name,genNS(jaxInfo));
+ }
+
+ public OutXML(InXML inXML) {
+ this(inXML.jaxInfo.name,genNS(inXML.jaxInfo));
+ }
+
+ private static String[] genNS(JaxInfo jaxInfo) {
+ return new String[] {"xmlns=" + jaxInfo.ns};
+ }
+
+
+ @Override
+ public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException {
+ Parsed<S> p = prs.newParsed();
+ Stack<Level> stack = new Stack<Level>();
+ // If it's an IndentPrintWriter, it is pretty printing.
+ boolean pretty = (options.length>0&&options[0]);
+
+ IndentPrintWriter ipw;
+ if(pretty) {
+ if(writer instanceof IndentPrintWriter) {
+ ipw = (IndentPrintWriter)writer;
+ } else {
+ writer = ipw = new IndentPrintWriter(writer);
+ }
+ } else {
+ ipw=null;
+ }
+ boolean closeTag = false;
+ Level level = new Level(null);
+ while((p = prs.parse(in,p.reuse())).valid()) {
+ if(!p.hasName() && level.multi!=null) {
+ p.name=level.multi;
+ }
+ if(closeTag && p.event!=Parse.ATTRIB) {
+ writer.append('>');
+ if(pretty)writer.append('\n');
+ closeTag = false;
+ }
+ switch(p.event) {
+ case Parse.START_DOC:
+ if(!(options.length>1&&options[1])) // if not a fragment, print XML Info data
+ if(pretty)ipw.println(XML_INFO);
+ else writer.append(XML_INFO);
+ break;
+ case Parse.END_DOC:
+ break;
+ case Parse.START_OBJ:
+ stack.push(level);
+ level = new Level(level);
+ if(p.hasName()) {
+ closeTag = tag(writer,level.sbw,pretty,pretty,p.name,null);
+ } else if(root!=null && stack.size()==1) { // first Object
+ closeTag = tag(writer,level.sbw,pretty,pretty,root,null);
+ // Write Root Props
+ for(Prop prop : props) {
+ attrib(writer,pretty,prop.tag, prop.value,level);
+ }
+ }
+ if(pretty)ipw.inc();
+ break;
+ case Parse.END_OBJ:
+ if(p.hasData())
+ closeTag = tag(writer,writer,pretty,false,p.name, XmlEscape.convert(p.sb));
+ if(pretty)ipw.dec();
+ writer.append(level.sbw.getBuffer());
+ level = stack.pop();
+ break;
+ case Parse.START_ARRAY:
+ level.multi = p.name;
+ break;
+ case Parse.END_ARRAY:
+ if(p.hasData())
+ closeTag = tag(writer,writer,pretty,false, p.name, XmlEscape.convert(p.sb));
+ level.multi=null;
+ break;
+ case Parse.ATTRIB:
+ if(p.hasData())
+ attrib(writer,pretty,p.name, XmlEscape.convert(p.sb), level);
+ break;
+ case Parse.NEXT:
+ if(p.hasData())
+ closeTag = tag(writer,writer,pretty, false,p.name, XmlEscape.convert(p.sb));
+ break;
+ }
+ }
+ writer.append(level.sbw.getBuffer());
+ writer.flush();
+ }
+
+ private class Level {
+ public final StringBuilderWriter sbw;
+ public String multi;
+ private Level prev;
+ private Map<String,String> nses;
+
+ public Level(Level level) {
+ sbw = new StringBuilderWriter();
+ multi = null;
+ prev = level;
+ }
- public boolean hasPrinted(String ns, String value, boolean create) {
- boolean rv = false;
- if(nses==null) {
- if(prev!=null)rv = prev.hasPrinted(ns, value, false);
- } else {
- String v = nses.get(ns);
- return value.equals(v); // note: accomodates not finding NS as well
- }
-
- if(create && !rv) {
- if(nses == null) nses = new HashMap<>();
- nses.put(ns, value);
- }
- return rv;
- }
-
-
-
- }
-
- private boolean tag(Writer fore, Writer aft, boolean pretty, boolean returns, String tag, String data) throws IOException {
- fore.append('<');
- fore.append(tag);
- if(data!=null) {
- fore.append('>'); // if no data, it may need some attributes...
- fore.append(data);
- if(returns)fore.append('\n');
- }
- aft.append("</");
- aft.append(tag);
- aft.append(">");
- if(pretty)aft.append('\n');
- return data==null;
- }
-
- private void attrib(Writer fore, boolean pretty, String tag, String value, Level level) throws IOException {
- String realTag = tag.startsWith("__")?tag.substring(2):tag; // remove __
- if(realTag.equals(Parsed.EXTENSION_TAG)) { // Convert Derived name into XML defined Inheritance
- fore.append(" xsi:type=\"");
- fore.append(value);
- fore.append('"');
- if(!level.hasPrinted(XMLNS_XSI, XML_SCHEMA_INSTANCE,true)) {
- fore.append(' ');
- fore.append(XMLNS_XSI);
- fore.append("=\"");
- fore.append(XML_SCHEMA_INSTANCE);
- fore.append("\"");
- }
- } else {
- if(realTag.startsWith("xmlns:") ) {
- if(level.hasPrinted(realTag, value, true)) {
- return;
- }
- }
- fore.append(' ');
- fore.append(realTag);
- fore.append("=\"");
- fore.append(value);
- fore.append('"');
- }
- }
+ public boolean hasPrinted(String ns, String value, boolean create) {
+ boolean rv = false;
+ if(nses==null) {
+ if(prev!=null)rv = prev.hasPrinted(ns, value, false);
+ } else {
+ String v = nses.get(ns);
+ return value.equals(v); // note: accomodates not finding NS as well
+ }
+
+ if(create && !rv) {
+ if(nses == null) nses = new HashMap<>();
+ nses.put(ns, value);
+ }
+ return rv;
+ }
+
+
+
+ }
+
+ private boolean tag(Writer fore, Writer aft, boolean pretty, boolean returns, String tag, String data) throws IOException {
+ fore.append('<');
+ fore.append(tag);
+ if(data!=null) {
+ fore.append('>'); // if no data, it may need some attributes...
+ fore.append(data);
+ if(returns)fore.append('\n');
+ }
+ aft.append("</");
+ aft.append(tag);
+ aft.append(">");
+ if(pretty)aft.append('\n');
+ return data==null;
+ }
+
+ private void attrib(Writer fore, boolean pretty, String tag, String value, Level level) throws IOException {
+ String realTag = tag.startsWith("__")?tag.substring(2):tag; // remove __
+ if(realTag.equals(Parsed.EXTENSION_TAG)) { // Convert Derived name into XML defined Inheritance
+ fore.append(" xsi:type=\"");
+ fore.append(value);
+ fore.append('"');
+ if(!level.hasPrinted(XMLNS_XSI, XML_SCHEMA_INSTANCE,true)) {
+ fore.append(' ');
+ fore.append(XMLNS_XSI);
+ fore.append("=\"");
+ fore.append(XML_SCHEMA_INSTANCE);
+ fore.append("\"");
+ }
+ } else {
+ if(realTag.startsWith("xmlns:") ) {
+ if(level.hasPrinted(realTag, value, true)) {
+ return;
+ }
+ }
+ fore.append(' ');
+ fore.append(realTag);
+ fore.append("=\"");
+ fore.append(value);
+ fore.append('"');
+ }
+ }
- @Override
- public String logName() {
- return "Rosetta XML";
- }
+ @Override
+ public String logName() {
+ return "Rosetta XML";
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java
index 657baf5c..d068530c 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java
@@ -25,21 +25,21 @@ import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
public interface Parse<IN, S> {
- public Parsed<S> parse(IN in, Parsed<S> parsed) throws ParseException;
-
- // EVENTS
- public static final char NONE = 0;
- public static final char START_DOC = 1;
- public static final char END_DOC = 2;
- public static final char ATTRIB = 3;
-
- public static final char NEXT = ',';
- public static final char START_OBJ = '{';
- public static final char END_OBJ = '}';
- public static final char START_ARRAY = '[';
- public static final char END_ARRAY = ']';
-
- public Parsed<S> newParsed() throws ParseException;
- public TimeTaken start(Env env);
-
+ public Parsed<S> parse(IN in, Parsed<S> parsed) throws ParseException;
+
+ // EVENTS
+ public static final char NONE = 0;
+ public static final char START_DOC = 1;
+ public static final char END_DOC = 2;
+ public static final char ATTRIB = 3;
+
+ public static final char NEXT = ',';
+ public static final char START_OBJ = '{';
+ public static final char END_OBJ = '}';
+ public static final char START_ARRAY = '[';
+ public static final char END_ARRAY = ']';
+
+ public Parsed<S> newParsed() throws ParseException;
+ public TimeTaken start(Env env);
+
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java
index d986776d..38ea956a 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java
@@ -22,21 +22,21 @@
package org.onap.aaf.misc.rosetta;
public class ParseException extends Exception {
- private static final long serialVersionUID = 7808836939102997012L;
+ private static final long serialVersionUID = 7808836939102997012L;
- public ParseException() {
- }
+ public ParseException() {
+ }
- public ParseException(String message) {
- super(message);
- }
+ public ParseException(String message) {
+ super(message);
+ }
- public ParseException(Throwable cause) {
- super(cause);
- }
+ public ParseException(Throwable cause) {
+ super(cause);
+ }
- public ParseException(String message, Throwable cause) {
- super(message, cause);
- }
+ public ParseException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java
index 326c5bba..a4c679db 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java
@@ -23,67 +23,67 @@ package org.onap.aaf.misc.rosetta;
public class Parsed<S> {
- public static final String EXTENSION_TAG="extension";
-
- public boolean isString;
-
- public StringBuilder sb;
- public char event;
- public String name;
- public S state;
+ public static final String EXTENSION_TAG="extension";
+
+ public boolean isString;
+
+ public StringBuilder sb;
+ public char event;
+ public String name;
+ public S state;
- public Parsed() {
- this(null);
- }
+ public Parsed() {
+ this(null);
+ }
- // Package on purpose
- Parsed(S theState) {
- sb = new StringBuilder();
- isString = false;
- event = Parse.NONE;
- name = "";
- state = theState;
- }
+ // Package on purpose
+ Parsed(S theState) {
+ sb = new StringBuilder();
+ isString = false;
+ event = Parse.NONE;
+ name = "";
+ state = theState;
+ }
- public boolean valid() {
- return event!=Parse.NONE;
- }
-
- public Parsed<S> reuse() {
- isString=false;
- sb.setLength(0);
- event = Parse.NONE;
- name = "";
- // don't touch T...
- return this;
- }
+ public boolean valid() {
+ return event!=Parse.NONE;
+ }
+
+ public Parsed<S> reuse() {
+ isString=false;
+ sb.setLength(0);
+ event = Parse.NONE;
+ name = "";
+ // don't touch T...
+ return this;
+ }
- public void dataIsName() {
- name = sb.toString();
- sb.setLength(0);
- }
+ public void dataIsName() {
+ name = sb.toString();
+ sb.setLength(0);
+ }
- public boolean hasName() {
- return name.length()>0;
- }
+ public boolean hasName() {
+ return name.length()>0;
+ }
- public boolean hasData() {
- return sb.length()>0;
- }
-
- public String toString() {
- StringBuilder sb2 = new StringBuilder();
- if(event<40)sb2.append((int)event);
- else sb2.append(event);
- sb2.append(" - ");
- sb2.append(name);
- if(sb.length()>0) {
- sb2.append(" : ");
- if(isString)sb2.append('"');
- sb2.append(sb);
- if(isString)sb2.append('"');
- }
- return sb2.toString();
- }
+ public boolean hasData() {
+ return sb.length()>0;
+ }
+
+ public String toString() {
+ StringBuilder sb2 = new StringBuilder();
+ if(event<40)sb2.append((int)event);
+ else sb2.append(event);
+ sb2.append(" - ");
+ sb2.append(name);
+ if(sb.length()>0) {
+ sb2.append(" : ");
+ if(isString)sb2.append('"');
+ sb2.append(sb);
+ if(isString)sb2.append('"');
+ }
+ return sb2.toString();
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java
index 07bd40f0..ae9c8934 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java
@@ -22,22 +22,22 @@
package org.onap.aaf.misc.rosetta;
class Prop {
- public String tag;
- public String value;
- public Prop(String t, String v) {
- tag = t;
- value =v;
- }
-
- public Prop(String t_equals_v) {
- String[] tv = t_equals_v.split("=");
- if(tv.length>1) {
- tag = tv[0];
- value = tv[1];
- }
- }
+ public String tag;
+ public String value;
+ public Prop(String t, String v) {
+ tag = t;
+ value =v;
+ }
+
+ public Prop(String t_equals_v) {
+ String[] tv = t_equals_v.split("=");
+ if(tv.length>1) {
+ tag = tv[0];
+ value = tv[1];
+ }
+ }
- public String toString() {
- return tag + '=' + value;
- }
+ public String toString() {
+ return tag + '=' + value;
+ }
} \ No newline at end of file
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java
index 45c27052..a596b705 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java
@@ -38,157 +38,157 @@ import org.onap.aaf.misc.rosetta.Saved.State;
*
*/
public class Saved extends Out implements Parse<Reader, State>{
- private static final String ROSETTA_SAVED = "Rosetta Saved";
- private final static int INIT_SIZE=128;
- private Content content[];
- private int idx;
- private boolean append = false;
-
- /**
- * Read from Parsed Stream and save
- */
- // @Override
- public<IN,S> void extract(IN in, Writer ignore, Parse<IN,S> parser, boolean ... options) throws IOException, ParseException {
- Parsed<S> p = parser.newParsed();
- if(!append) {
- // reuse array if not too big
- if(content==null||content.length>INIT_SIZE*3) {
- content = new Content[INIT_SIZE];
- idx = -1;
- } else do {
- content[idx]=null;
- } while(--idx>=0);
- }
-
- // Note: idx needs to be -1 on initialization and no appendages
- while((p = parser.parse(in,p.reuse())).valid()) {
- if(!(append && (p.event==START_DOC || p.event==END_DOC))) { // skip any start/end of document in appendages
- if(++idx>=content.length) {
- Content temp[] = new Content[content.length*2];
- System.arraycopy(content, 0, temp, 0, idx);
- content = temp;
- }
- content[idx]= new Content(p);
- }
- }
- }
-
- // @Override
- public Parsed<State> parse(Reader ignore, Parsed<State> parsed) throws ParseException {
- int i;
- if((i=parsed.state.count++)<=idx)
- content[i].load(parsed);
- else
- parsed.event = Parse.NONE;
- return parsed;
- }
+ private static final String ROSETTA_SAVED = "Rosetta Saved";
+ private final static int INIT_SIZE=128;
+ private Content content[];
+ private int idx;
+ private boolean append = false;
+
+ /**
+ * Read from Parsed Stream and save
+ */
+ // @Override
+ public<IN,S> void extract(IN in, Writer ignore, Parse<IN,S> parser, boolean ... options) throws IOException, ParseException {
+ Parsed<S> p = parser.newParsed();
+ if(!append) {
+ // reuse array if not too big
+ if(content==null||content.length>INIT_SIZE*3) {
+ content = new Content[INIT_SIZE];
+ idx = -1;
+ } else do {
+ content[idx]=null;
+ } while(--idx>=0);
+ }
+
+ // Note: idx needs to be -1 on initialization and no appendages
+ while((p = parser.parse(in,p.reuse())).valid()) {
+ if(!(append && (p.event==START_DOC || p.event==END_DOC))) { // skip any start/end of document in appendages
+ if(++idx>=content.length) {
+ Content temp[] = new Content[content.length*2];
+ System.arraycopy(content, 0, temp, 0, idx);
+ content = temp;
+ }
+ content[idx]= new Content(p);
+ }
+ }
+ }
+
+ // @Override
+ public Parsed<State> parse(Reader ignore, Parsed<State> parsed) throws ParseException {
+ int i;
+ if((i=parsed.state.count++)<=idx)
+ content[i].load(parsed);
+ else
+ parsed.event = Parse.NONE;
+ return parsed;
+ }
- public Content[] cut(char event, int count) {
- append = true;
- for(int i=idx;i>=0;--i) {
- if(content[i].event==event) count--;
- if(count==0) {
- Content[] appended = new Content[idx-i+1];
- System.arraycopy(content, i, appended, 0, appended.length);
- idx = i-1;
- return appended;
- }
- }
- return new Content[0];
- }
+ public Content[] cut(char event, int count) {
+ append = true;
+ for(int i=idx;i>=0;--i) {
+ if(content[i].event==event) count--;
+ if(count==0) {
+ Content[] appended = new Content[idx-i+1];
+ System.arraycopy(content, i, appended, 0, appended.length);
+ idx = i-1;
+ return appended;
+ }
+ }
+ return new Content[0];
+ }
- public void paste(Content[] appended) {
- if(appended!=null) {
- if(idx+appended.length>content.length) {
- Content temp[] = new Content[content.length*2];
- System.arraycopy(content, 0, temp, 0, idx);
- content = temp;
- }
- System.arraycopy(appended,0,content,idx+1,appended.length);
- idx+=appended.length;
- }
- this.append = false;
- }
+ public void paste(Content[] appended) {
+ if(appended!=null) {
+ if(idx+appended.length>content.length) {
+ Content temp[] = new Content[content.length*2];
+ System.arraycopy(content, 0, temp, 0, idx);
+ content = temp;
+ }
+ System.arraycopy(appended,0,content,idx+1,appended.length);
+ idx+=appended.length;
+ }
+ this.append = false;
+ }
- public static class State {
- public int count = 0;
- }
-
- public static class Content {
- private boolean isString;
- private char event;
- private String name;
- private List<Prop> props;
- private String str;
-
- public Content(Parsed<?> p) {
- isString = p.isString;
- event = p.event;
- name = p.name;
- // avoid copying, because most elements don't have content
- // Cannot set to "equals", because sb ends up being cleared (and reused)
- str = p.sb.length()==0?null:p.sb.toString();
- }
+ public static class State {
+ public int count = 0;
+ }
+
+ public static class Content {
+ private boolean isString;
+ private char event;
+ private String name;
+ private List<Prop> props;
+ private String str;
+
+ public Content(Parsed<?> p) {
+ isString = p.isString;
+ event = p.event;
+ name = p.name;
+ // avoid copying, because most elements don't have content
+ // Cannot set to "equals", because sb ends up being cleared (and reused)
+ str = p.sb.length()==0?null:p.sb.toString();
+ }
- public void load(Parsed<State> p) {
- p.isString = isString;
- p.event = event;
- p.name = name;
- if(str!=null)
- p.sb.append(str);
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(event);
- sb.append(" - ");
- sb.append(name);
- sb.append(": ");
- if(isString)sb.append('"');
- sb.append(str);
- if(isString)sb.append('"');
- sb.append(' ');
- if(props!=null) {
- boolean comma = false;
- for(Prop prop : props) {
- if(comma)sb.append(',');
- else comma = true;
- sb.append(prop.tag);
- sb.append('=');
- sb.append(prop.value);
- }
- }
- return sb.toString();
- }
- }
-
- //// @Override
- public Parsed<State> newParsed() {
- Parsed<State> ps = new Parsed<State>(new State());
- return ps;
- }
+ public void load(Parsed<State> p) {
+ p.isString = isString;
+ p.event = event;
+ p.name = name;
+ if(str!=null)
+ p.sb.append(str);
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(event);
+ sb.append(" - ");
+ sb.append(name);
+ sb.append(": ");
+ if(isString)sb.append('"');
+ sb.append(str);
+ if(isString)sb.append('"');
+ sb.append(' ');
+ if(props!=null) {
+ boolean comma = false;
+ for(Prop prop : props) {
+ if(comma)sb.append(',');
+ else comma = true;
+ sb.append(prop.tag);
+ sb.append('=');
+ sb.append(prop.value);
+ }
+ }
+ return sb.toString();
+ }
+ }
+
+ //// @Override
+ public Parsed<State> newParsed() {
+ Parsed<State> ps = new Parsed<State>(new State());
+ return ps;
+ }
- /**
- * Convenience function
- * @param rdr
- * @param in
- * @throws IOException
- * @throws ParseException
- */
- public<IN,S> void load(IN in, Parse<IN, S> parser) throws IOException, ParseException {
- extract(in,(Writer)null, parser);
- }
+ /**
+ * Convenience function
+ * @param rdr
+ * @param in
+ * @throws IOException
+ * @throws ParseException
+ */
+ public<IN,S> void load(IN in, Parse<IN, S> parser) throws IOException, ParseException {
+ extract(in,(Writer)null, parser);
+ }
- // @Override
- public TimeTaken start(Env env) {
- return env.start(ROSETTA_SAVED, 0);
- }
-
- @Override
- public String logName() {
- return ROSETTA_SAVED;
- }
+ // @Override
+ public TimeTaken start(Env env) {
+ return env.start(ROSETTA_SAVED, 0);
+ }
+
+ @Override
+ public String logName() {
+ return ROSETTA_SAVED;
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java
index aac1e30f..1b0eec07 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java
@@ -27,345 +27,345 @@ import java.util.Map.Entry;
import java.util.TreeMap;
public class XmlEscape {
- private XmlEscape() {}
-
- private static final TreeMap<String,Integer> charMap; // see initialization at end
- private static final TreeMap<Integer,String> intMap; // see initialization at end
+ private XmlEscape() {}
+
+ private static final TreeMap<String,Integer> charMap; // see initialization at end
+ private static final TreeMap<Integer,String> intMap; // see initialization at end
- public static void xmlEscape(StringBuilder sb, Reader r) throws ParseException {
- try {
- int c;
- StringBuilder esc = new StringBuilder();
- for(int cnt = 0;cnt<9 /*max*/; ++cnt) {
- if((c=r.read())<0)throw new ParseException("Invalid Data: Unfinished Escape Sequence");
- if(c!=';') {
- esc.append((char)c);
- } else { // evaluate
- Integer i = charMap.get(esc.toString());
- if(i==null) {
- // leave in nasty XML format for now.
- sb.append('&');
- sb.append(esc);
- sb.append(';');
- } else {
- sb.append((char)i.intValue());
- }
- break;
- }
- }
-
-
- } catch (IOException e) {
- throw new ParseException(e);
- }
- }
-
- public static void xmlEscape(StringBuilder sb, int chr) {
- sb.append('&');
- sb.append(intMap.get(chr));
- sb.append(';');
- }
-
- public static String convert(StringBuilder insb) {
- int idx, ch;
- StringBuilder sb=null;
- for(idx=0;idx<insb.length();++idx) {
- ch = insb.charAt(idx);
- if(ch>=160 || ch==34 || ch==38 || ch==39 || ch==60 || ch==62) {
- sb = new StringBuilder();
- sb.append(insb,0,idx);
- break;
- }
- }
-
- if(sb==null)return insb.toString();
-
- for(int i=idx;i<insb.length();++i) {
- ch = insb.charAt(i);
- if(ch<160) {
- switch(ch) {
- case 34: sb.append("&quot;"); break;
- case 38: sb.append("&amp;"); break;
- case 39: sb.append("&apos;"); break;
- case 60: sb.append("&lt;"); break;
- case 62: sb.append("&gt;"); break;
- default:
- sb.append((char)ch);
- }
- } else { // use map
- String s = intMap.get(ch);
- if(s==null)sb.append((char)ch);
- else {
- sb.append('&');
- sb.append(s);
- sb.append(';');
- }
- }
- }
- return sb.toString();
- }
+ public static void xmlEscape(StringBuilder sb, Reader r) throws ParseException {
+ try {
+ int c;
+ StringBuilder esc = new StringBuilder();
+ for(int cnt = 0;cnt<9 /*max*/; ++cnt) {
+ if((c=r.read())<0)throw new ParseException("Invalid Data: Unfinished Escape Sequence");
+ if(c!=';') {
+ esc.append((char)c);
+ } else { // evaluate
+ Integer i = charMap.get(esc.toString());
+ if(i==null) {
+ // leave in nasty XML format for now.
+ sb.append('&');
+ sb.append(esc);
+ sb.append(';');
+ } else {
+ sb.append((char)i.intValue());
+ }
+ break;
+ }
+ }
+
+
+ } catch (IOException e) {
+ throw new ParseException(e);
+ }
+ }
+
+ public static void xmlEscape(StringBuilder sb, int chr) {
+ sb.append('&');
+ sb.append(intMap.get(chr));
+ sb.append(';');
+ }
+
+ public static String convert(StringBuilder insb) {
+ int idx, ch;
+ StringBuilder sb=null;
+ for(idx=0;idx<insb.length();++idx) {
+ ch = insb.charAt(idx);
+ if(ch>=160 || ch==34 || ch==38 || ch==39 || ch==60 || ch==62) {
+ sb = new StringBuilder();
+ sb.append(insb,0,idx);
+ break;
+ }
+ }
+
+ if(sb==null)return insb.toString();
+
+ for(int i=idx;i<insb.length();++i) {
+ ch = insb.charAt(i);
+ if(ch<160) {
+ switch(ch) {
+ case 34: sb.append("&quot;"); break;
+ case 38: sb.append("&amp;"); break;
+ case 39: sb.append("&apos;"); break;
+ case 60: sb.append("&lt;"); break;
+ case 62: sb.append("&gt;"); break;
+ default:
+ sb.append((char)ch);
+ }
+ } else { // use map
+ String s = intMap.get(ch);
+ if(s==null)sb.append((char)ch);
+ else {
+ sb.append('&');
+ sb.append(s);
+ sb.append(';');
+ }
+ }
+ }
+ return sb.toString();
+ }
- static {
- charMap = new TreeMap<>();
- intMap = new TreeMap<>();
- charMap.put("quot", 34);
- charMap.put("amp",38);
- charMap.put("apos",39);
- charMap.put("lt",60);
- charMap.put("gt",62);
- charMap.put("nbsp",160);
- charMap.put("iexcl",161);
- charMap.put("cent",162);
- charMap.put("pound",163);
- charMap.put("curren",164);
- charMap.put("yen",165);
- charMap.put("brvbar",166);
- charMap.put("sect",167);
- charMap.put("uml",168);
- charMap.put("copy",169);
- charMap.put("ordf",170);
- charMap.put("laquo",171);
- charMap.put("not",172);
- charMap.put("shy",173);
- charMap.put("reg",174);
- charMap.put("macr",175);
- charMap.put("deg",176);
- charMap.put("plusmn",177);
- charMap.put("sup2",178);
- charMap.put("sup3",179);
- charMap.put("acute",180);
- charMap.put("micro",181);
- charMap.put("para",182);
- charMap.put("middot",183);
- charMap.put("cedil",184);
- charMap.put("sup1",185);
- charMap.put("ordm",186);
- charMap.put("raquo",187);
- charMap.put("frac14",188);
- charMap.put("frac12",189);
- charMap.put("frac34",190);
- charMap.put("iquest",191);
- charMap.put("Agrave",192);
- charMap.put("Aacute",193);
- charMap.put("Acirc",194);
- charMap.put("Atilde",195);
- charMap.put("Auml",196);
- charMap.put("Aring",197);
- charMap.put("AElig",198);
- charMap.put("Ccedil",199);
- charMap.put("Egrave",200);
- charMap.put("Eacute",201);
- charMap.put("Ecirc",202);
- charMap.put("Euml",203);
- charMap.put("Igrave",204);
- charMap.put("Iacute",205);
- charMap.put("Icirc",206);
- charMap.put("Iuml",207);
- charMap.put("ETH",208);
- charMap.put("Ntilde",209);
- charMap.put("Ograve",210);
- charMap.put("Oacute",211);
- charMap.put("Ocirc",212);
- charMap.put("Otilde",213);
- charMap.put("Ouml",214);
- charMap.put("times",215);
- charMap.put("Oslash",216);
- charMap.put("Ugrave",217);
- charMap.put("Uacute",218);
- charMap.put("Ucirc",219);
- charMap.put("Uuml",220);
- charMap.put("Yacute",221);
- charMap.put("THORN",222);
- charMap.put("szlig",223);
- charMap.put("agrave",224);
- charMap.put("aacute",225);
- charMap.put("acirc",226);
- charMap.put("atilde",227);
- charMap.put("auml",228);
- charMap.put("aring",229);
- charMap.put("aelig",230);
- charMap.put("ccedil",231);
- charMap.put("egrave",232);
- charMap.put("eacute",233);
- charMap.put("ecirc",234);
- charMap.put("euml",235);
- charMap.put("igrave",236);
- charMap.put("iacute",237);
- charMap.put("icirc",238);
- charMap.put("iuml",239);
- charMap.put("eth",240);
- charMap.put("ntilde",241);
- charMap.put("ograve",242);
- charMap.put("oacute",243);
- charMap.put("ocirc",244);
- charMap.put("otilde",245);
- charMap.put("ouml",246);
- charMap.put("divide",247);
- charMap.put("oslash",248);
- charMap.put("ugrave",249);
- charMap.put("uacute",250);
- charMap.put("ucirc",251);
- charMap.put("uuml",252);
- charMap.put("yacute",253);
- charMap.put("thorn",254);
- charMap.put("yuml",255);
- charMap.put("OElig",338);
- charMap.put("oelig",339);
- charMap.put("Scaron",352);
- charMap.put("scaron",353);
- charMap.put("Yuml",376);
- charMap.put("fnof",402);
- charMap.put("circ",710);
- charMap.put("tilde",732);
- charMap.put("Alpha",913);
- charMap.put("Beta",914);
- charMap.put("Gamma",915);
- charMap.put("Delta",916);
- charMap.put("Epsilon",917);
- charMap.put("Zeta",918);
- charMap.put("Eta",919);
- charMap.put("Theta",920);
- charMap.put("Iota",921);
- charMap.put("Kappa",922);
- charMap.put("Lambda",923);
- charMap.put("Mu",924);
- charMap.put("Nu",925);
- charMap.put("Xi",926);
- charMap.put("Omicron",927);
- charMap.put("Pi",928);
- charMap.put("Rho",929);
- charMap.put("Sigma",931);
- charMap.put("Tau",932);
- charMap.put("Upsilon",933);
- charMap.put("Phi",934);
- charMap.put("Chi",935);
- charMap.put("Psi",936);
- charMap.put("Omega",937);
- charMap.put("alpha",945);
- charMap.put("beta",946);
- charMap.put("gamma",947);
- charMap.put("delta",948);
- charMap.put("epsilon",949);
- charMap.put("zeta",950);
- charMap.put("eta",951);
- charMap.put("theta",952);
- charMap.put("iota",953);
- charMap.put("kappa",954);
- charMap.put("lambda",955);
- charMap.put("mu",956);
- charMap.put("nu",957);
- charMap.put("xi",958);
- charMap.put("omicron",959);
- charMap.put("pi",960);
- charMap.put("rho",961);
- charMap.put("sigmaf",962);
- charMap.put("sigma",963);
- charMap.put("tau",964);
- charMap.put("upsilon",965);
- charMap.put("phi",966);
- charMap.put("chi",967);
- charMap.put("psi",968);
- charMap.put("omega",969);
- charMap.put("thetasym",977);
- charMap.put("upsih",978);
- charMap.put("piv",982);
- charMap.put("ensp",8194);
- charMap.put("emsp",8195);
- charMap.put("thinsp",8201);
- charMap.put("zwnj",8204);
- charMap.put("zwj",8205);
- charMap.put("lrm",8206);
- charMap.put("rlm",8207);
- charMap.put("ndash",8211);
- charMap.put("mdash",8212);
- charMap.put("lsquo",8216);
- charMap.put("rsquo",8217);
- charMap.put("sbquo",8218);
- charMap.put("ldquo",8220);
- charMap.put("rdquo",8221);
- charMap.put("bdquo",8222);
- charMap.put("dagger",8224);
- charMap.put("Dagger",8225);
- charMap.put("bull",8226);
- charMap.put("hellip",8230);
- charMap.put("permil",8240);
- charMap.put("prime",8242);
- charMap.put("Prime",8243);
- charMap.put("lsaquo",8249);
- charMap.put("rsaquo",8250);
- charMap.put("oline",8254);
- charMap.put("frasl",8260);
- charMap.put("euro",8364);
- charMap.put("image",8465);
- charMap.put("weierp",8472);
- charMap.put("real",8476);
- charMap.put("trade",8482);
- charMap.put("alefsym",8501);
- charMap.put("larr",8592);
- charMap.put("uarr",8593);
- charMap.put("rarr",8594);
- charMap.put("darr",8595);
- charMap.put("harr",8596);
- charMap.put("crarr",8629);
- charMap.put("lArr",8656);
- charMap.put("uArr",8657);
- charMap.put("rArr",8658);
- charMap.put("dArr",8659);
- charMap.put("hArr",8660);
- charMap.put("forall",8704);
- charMap.put("part",8706);
- charMap.put("exist",8707);
- charMap.put("empty",8709);
- charMap.put("nabla",8711);
- charMap.put("isin",8712);
- charMap.put("notin",8713);
- charMap.put("ni",8715);
- charMap.put("prod",8719);
- charMap.put("sum",8721);
- charMap.put("minus",8722);
- charMap.put("lowast",8727);
- charMap.put("radic",8730);
- charMap.put("prop",8733);
- charMap.put("infin",8734);
- charMap.put("ang",8736);
- charMap.put("and",8743);
- charMap.put("or",8744);
- charMap.put("cap",8745);
- charMap.put("cup",8746);
- charMap.put("int",8747);
- charMap.put("there4",8756);
- charMap.put("sim",8764);
- charMap.put("cong",8773);
- charMap.put("asymp",8776);
- charMap.put("ne",8800);
- charMap.put("equiv",8801);
- charMap.put("le",8804);
- charMap.put("ge",8805);
- charMap.put("sub",8834);
- charMap.put("sup",8835);
- charMap.put("nsub",8836);
- charMap.put("sube",8838);
- charMap.put("supe",8839);
- charMap.put("oplus",8853);
- charMap.put("otimes",8855);
- charMap.put("perp",8869);
- charMap.put("sdot",8901);
- charMap.put("lceil",8968);
- charMap.put("rceil",8969);
- charMap.put("lfloor",8970);
- charMap.put("rfloor",8971);
- charMap.put("lang",9001);
- charMap.put("rang",9002);
- charMap.put("loz",9674);
- charMap.put("spades",9824);
- charMap.put("clubs",9827);
- charMap.put("hearts",9829);
- charMap.put("diams",9830);
-
- for( Entry<String, Integer> es: charMap.entrySet()) {
- if(es.getValue()>=160); // save small space... note that no longer has amp, etc.
- intMap.put(es.getValue(), es.getKey());
- }
- }
+ static {
+ charMap = new TreeMap<>();
+ intMap = new TreeMap<>();
+ charMap.put("quot", 34);
+ charMap.put("amp",38);
+ charMap.put("apos",39);
+ charMap.put("lt",60);
+ charMap.put("gt",62);
+ charMap.put("nbsp",160);
+ charMap.put("iexcl",161);
+ charMap.put("cent",162);
+ charMap.put("pound",163);
+ charMap.put("curren",164);
+ charMap.put("yen",165);
+ charMap.put("brvbar",166);
+ charMap.put("sect",167);
+ charMap.put("uml",168);
+ charMap.put("copy",169);
+ charMap.put("ordf",170);
+ charMap.put("laquo",171);
+ charMap.put("not",172);
+ charMap.put("shy",173);
+ charMap.put("reg",174);
+ charMap.put("macr",175);
+ charMap.put("deg",176);
+ charMap.put("plusmn",177);
+ charMap.put("sup2",178);
+ charMap.put("sup3",179);
+ charMap.put("acute",180);
+ charMap.put("micro",181);
+ charMap.put("para",182);
+ charMap.put("middot",183);
+ charMap.put("cedil",184);
+ charMap.put("sup1",185);
+ charMap.put("ordm",186);
+ charMap.put("raquo",187);
+ charMap.put("frac14",188);
+ charMap.put("frac12",189);
+ charMap.put("frac34",190);
+ charMap.put("iquest",191);
+ charMap.put("Agrave",192);
+ charMap.put("Aacute",193);
+ charMap.put("Acirc",194);
+ charMap.put("Atilde",195);
+ charMap.put("Auml",196);
+ charMap.put("Aring",197);
+ charMap.put("AElig",198);
+ charMap.put("Ccedil",199);
+ charMap.put("Egrave",200);
+ charMap.put("Eacute",201);
+ charMap.put("Ecirc",202);
+ charMap.put("Euml",203);
+ charMap.put("Igrave",204);
+ charMap.put("Iacute",205);
+ charMap.put("Icirc",206);
+ charMap.put("Iuml",207);
+ charMap.put("ETH",208);
+ charMap.put("Ntilde",209);
+ charMap.put("Ograve",210);
+ charMap.put("Oacute",211);
+ charMap.put("Ocirc",212);
+ charMap.put("Otilde",213);
+ charMap.put("Ouml",214);
+ charMap.put("times",215);
+ charMap.put("Oslash",216);
+ charMap.put("Ugrave",217);
+ charMap.put("Uacute",218);
+ charMap.put("Ucirc",219);
+ charMap.put("Uuml",220);
+ charMap.put("Yacute",221);
+ charMap.put("THORN",222);
+ charMap.put("szlig",223);
+ charMap.put("agrave",224);
+ charMap.put("aacute",225);
+ charMap.put("acirc",226);
+ charMap.put("atilde",227);
+ charMap.put("auml",228);
+ charMap.put("aring",229);
+ charMap.put("aelig",230);
+ charMap.put("ccedil",231);
+ charMap.put("egrave",232);
+ charMap.put("eacute",233);
+ charMap.put("ecirc",234);
+ charMap.put("euml",235);
+ charMap.put("igrave",236);
+ charMap.put("iacute",237);
+ charMap.put("icirc",238);
+ charMap.put("iuml",239);
+ charMap.put("eth",240);
+ charMap.put("ntilde",241);
+ charMap.put("ograve",242);
+ charMap.put("oacute",243);
+ charMap.put("ocirc",244);
+ charMap.put("otilde",245);
+ charMap.put("ouml",246);
+ charMap.put("divide",247);
+ charMap.put("oslash",248);
+ charMap.put("ugrave",249);
+ charMap.put("uacute",250);
+ charMap.put("ucirc",251);
+ charMap.put("uuml",252);
+ charMap.put("yacute",253);
+ charMap.put("thorn",254);
+ charMap.put("yuml",255);
+ charMap.put("OElig",338);
+ charMap.put("oelig",339);
+ charMap.put("Scaron",352);
+ charMap.put("scaron",353);
+ charMap.put("Yuml",376);
+ charMap.put("fnof",402);
+ charMap.put("circ",710);
+ charMap.put("tilde",732);
+ charMap.put("Alpha",913);
+ charMap.put("Beta",914);
+ charMap.put("Gamma",915);
+ charMap.put("Delta",916);
+ charMap.put("Epsilon",917);
+ charMap.put("Zeta",918);
+ charMap.put("Eta",919);
+ charMap.put("Theta",920);
+ charMap.put("Iota",921);
+ charMap.put("Kappa",922);
+ charMap.put("Lambda",923);
+ charMap.put("Mu",924);
+ charMap.put("Nu",925);
+ charMap.put("Xi",926);
+ charMap.put("Omicron",927);
+ charMap.put("Pi",928);
+ charMap.put("Rho",929);
+ charMap.put("Sigma",931);
+ charMap.put("Tau",932);
+ charMap.put("Upsilon",933);
+ charMap.put("Phi",934);
+ charMap.put("Chi",935);
+ charMap.put("Psi",936);
+ charMap.put("Omega",937);
+ charMap.put("alpha",945);
+ charMap.put("beta",946);
+ charMap.put("gamma",947);
+ charMap.put("delta",948);
+ charMap.put("epsilon",949);
+ charMap.put("zeta",950);
+ charMap.put("eta",951);
+ charMap.put("theta",952);
+ charMap.put("iota",953);
+ charMap.put("kappa",954);
+ charMap.put("lambda",955);
+ charMap.put("mu",956);
+ charMap.put("nu",957);
+ charMap.put("xi",958);
+ charMap.put("omicron",959);
+ charMap.put("pi",960);
+ charMap.put("rho",961);
+ charMap.put("sigmaf",962);
+ charMap.put("sigma",963);
+ charMap.put("tau",964);
+ charMap.put("upsilon",965);
+ charMap.put("phi",966);
+ charMap.put("chi",967);
+ charMap.put("psi",968);
+ charMap.put("omega",969);
+ charMap.put("thetasym",977);
+ charMap.put("upsih",978);
+ charMap.put("piv",982);
+ charMap.put("ensp",8194);
+ charMap.put("emsp",8195);
+ charMap.put("thinsp",8201);
+ charMap.put("zwnj",8204);
+ charMap.put("zwj",8205);
+ charMap.put("lrm",8206);
+ charMap.put("rlm",8207);
+ charMap.put("ndash",8211);
+ charMap.put("mdash",8212);
+ charMap.put("lsquo",8216);
+ charMap.put("rsquo",8217);
+ charMap.put("sbquo",8218);
+ charMap.put("ldquo",8220);
+ charMap.put("rdquo",8221);
+ charMap.put("bdquo",8222);
+ charMap.put("dagger",8224);
+ charMap.put("Dagger",8225);
+ charMap.put("bull",8226);
+ charMap.put("hellip",8230);
+ charMap.put("permil",8240);
+ charMap.put("prime",8242);
+ charMap.put("Prime",8243);
+ charMap.put("lsaquo",8249);
+ charMap.put("rsaquo",8250);
+ charMap.put("oline",8254);
+ charMap.put("frasl",8260);
+ charMap.put("euro",8364);
+ charMap.put("image",8465);
+ charMap.put("weierp",8472);
+ charMap.put("real",8476);
+ charMap.put("trade",8482);
+ charMap.put("alefsym",8501);
+ charMap.put("larr",8592);
+ charMap.put("uarr",8593);
+ charMap.put("rarr",8594);
+ charMap.put("darr",8595);
+ charMap.put("harr",8596);
+ charMap.put("crarr",8629);
+ charMap.put("lArr",8656);
+ charMap.put("uArr",8657);
+ charMap.put("rArr",8658);
+ charMap.put("dArr",8659);
+ charMap.put("hArr",8660);
+ charMap.put("forall",8704);
+ charMap.put("part",8706);
+ charMap.put("exist",8707);
+ charMap.put("empty",8709);
+ charMap.put("nabla",8711);
+ charMap.put("isin",8712);
+ charMap.put("notin",8713);
+ charMap.put("ni",8715);
+ charMap.put("prod",8719);
+ charMap.put("sum",8721);
+ charMap.put("minus",8722);
+ charMap.put("lowast",8727);
+ charMap.put("radic",8730);
+ charMap.put("prop",8733);
+ charMap.put("infin",8734);
+ charMap.put("ang",8736);
+ charMap.put("and",8743);
+ charMap.put("or",8744);
+ charMap.put("cap",8745);
+ charMap.put("cup",8746);
+ charMap.put("int",8747);
+ charMap.put("there4",8756);
+ charMap.put("sim",8764);
+ charMap.put("cong",8773);
+ charMap.put("asymp",8776);
+ charMap.put("ne",8800);
+ charMap.put("equiv",8801);
+ charMap.put("le",8804);
+ charMap.put("ge",8805);
+ charMap.put("sub",8834);
+ charMap.put("sup",8835);
+ charMap.put("nsub",8836);
+ charMap.put("sube",8838);
+ charMap.put("supe",8839);
+ charMap.put("oplus",8853);
+ charMap.put("otimes",8855);
+ charMap.put("perp",8869);
+ charMap.put("sdot",8901);
+ charMap.put("lceil",8968);
+ charMap.put("rceil",8969);
+ charMap.put("lfloor",8970);
+ charMap.put("rfloor",8971);
+ charMap.put("lang",9001);
+ charMap.put("rang",9002);
+ charMap.put("loz",9674);
+ charMap.put("spades",9824);
+ charMap.put("clubs",9827);
+ charMap.put("hearts",9829);
+ charMap.put("diams",9830);
+
+ for( Entry<String, Integer> es: charMap.entrySet()) {
+ if(es.getValue()>=160); // save small space... note that no longer has amp, etc.
+ intMap.put(es.getValue(), es.getKey());
+ }
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java
index 68baebb6..69926974 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java
@@ -56,210 +56,210 @@ import org.onap.aaf.misc.rosetta.ParseException;
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 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 inType;
- private TYPE outType;
- private int defOption;
- Marshal<T> marshal = null;
-
+ 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 inType;
+ private TYPE outType;
+ private int defOption;
+ Marshal<T> marshal = null;
+
- /**
- * Private constructor to setup Type specific data manipulators
- * @param schema
- * @param rootNs
- * @param cls
- * @throws SecurityException
- * @throws NoSuchFieldException
- * @throws ClassNotFoundException
- * @throws ParseException
- * @throws JAXBException
- */
- // package on purpose
- 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.
- 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;
- defOption = 0;
- } catch (Exception e) {
- throw new APIException(e);
- }
- }
-
+ /**
+ * Private constructor to setup Type specific data manipulators
+ * @param schema
+ * @param rootNs
+ * @param cls
+ * @throws SecurityException
+ * @throws NoSuchFieldException
+ * @throws ClassNotFoundException
+ * @throws ParseException
+ * @throws JAXBException
+ */
+ // package on purpose
+ 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.
+ 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;
+ defOption = 0;
+ } catch (Exception e) {
+ throw new APIException(e);
+ }
+ }
+
- // @Override
- public RosettaData<T> newData() {
- RosettaData<T> data = new RosettaData<T>(env, this)
- .in(inType)
- .out(outType)
- .option(defOption);
- return data;
- }
+ // @Override
+ public RosettaData<T> newData() {
+ RosettaData<T> data = new RosettaData<T>(env, this)
+ .in(inType)
+ .out(outType)
+ .option(defOption);
+ return data;
+ }
- // @Override
- public RosettaData<T> newData(Env trans) {
- RosettaData<T> data = new RosettaData<T>(trans, this)
- .in(inType)
- .out(outType)
- .option(defOption);
- return data;
- }
+ // @Override
+ public RosettaData<T> newData(Env trans) {
+ RosettaData<T> data = new RosettaData<T>(trans, this)
+ .in(inType)
+ .out(outType)
+ .option(defOption);
+ return data;
+ }
- @SuppressWarnings("unchecked")
- // @Override
- public Class<T> getTypeClass() {
- return (Class<T>)jaxMar.getMarshalClass();
- }
+ @SuppressWarnings("unchecked")
+ // @Override
+ public Class<T> getTypeClass() {
+ return (Class<T>)jaxMar.getMarshalClass();
+ }
- public RosettaDF<T> in(Data.TYPE type) {
- inType = type;
- defaultIn=getIn(type==Data.TYPE.DEFAULT?Data.TYPE.JSON:type);
- return this;
- }
+ public RosettaDF<T> in(Data.TYPE type) {
+ inType = type;
+ defaultIn=getIn(type==Data.TYPE.DEFAULT?Data.TYPE.JSON:type);
+ return this;
+ }
- /**
- * If exists, first option is "Pretty", second is "Fragment"
- *
- * @param options
- * @return
- */
- public RosettaDF<T> out(Data.TYPE type) {
- outType = type;
- 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;
- case JSON:
- return inJSON;
- case XML:
- return inXML;
- default:
- return defaultIn;
- }
- }
-
- public Out getOut(Data.TYPE type) {
- switch(type) {
- case DEFAULT:
- return defaultOut;
- case JSON:
- return outJSON;
- case XML:
- return outXML;
- case RAW:
- return outRAW;
- default:
- return defaultOut;
- }
- }
-
- public int logType(org.onap.aaf.misc.env.Data.TYPE ot) {
- switch(ot) {
- case JSON:
- return Env.JSON;
- default:
- return Env.XML;
- }
- }
+ /**
+ * If exists, first option is "Pretty", second is "Fragment"
+ *
+ * @param options
+ * @return
+ */
+ public RosettaDF<T> out(Data.TYPE type) {
+ outType = type;
+ 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;
+ case JSON:
+ return inJSON;
+ case XML:
+ return inXML;
+ default:
+ return defaultIn;
+ }
+ }
+
+ public Out getOut(Data.TYPE type) {
+ switch(type) {
+ case DEFAULT:
+ return defaultOut;
+ case JSON:
+ return outJSON;
+ case XML:
+ return outXML;
+ case RAW:
+ return outRAW;
+ default:
+ return defaultOut;
+ }
+ }
+
+ public int logType(org.onap.aaf.misc.env.Data.TYPE ot) {
+ switch(ot) {
+ case JSON:
+ return Env.JSON;
+ default:
+ return Env.XML;
+ }
+ }
- public RosettaEnv getEnv() {
- return env;
- }
+ public RosettaEnv getEnv() {
+ return env;
+ }
- public Data.TYPE getInType() {
- return inType;
- }
+ public Data.TYPE getInType() {
+ return inType;
+ }
- public Data.TYPE getOutType() {
- return outType;
- }
+ public Data.TYPE getOutType() {
+ return outType;
+ }
- public RosettaDF<T> option(int option) {
- defOption = option;
-
- return this;
- }
+ 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
- */
- public RosettaDF<T> rootMarshal(Marshal<T> marshal) {
- if(marshal instanceof DocMarshal) {
- this.marshal = marshal;
- } else {
- this.marshal = DocMarshal.root(marshal);
- }
- 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?
- try {
- if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction
- StringWriter sw = new StringWriter();
- jaxMar.marshal(trans.debug(), t, sw, options);
- out.extract(new StringReader(sw.toString()), new OutputStreamWriter(os), inXML,options);
- } else {
- out.extract(t, new OutputStreamWriter(os), marshal,options);
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ /**
+ * Assigning Root Marshal Object
+ *
+ * Will wrap with DocMarshal Object if not already
+ *
+ * @param marshal
+ * @return
+ */
+ public RosettaDF<T> rootMarshal(Marshal<T> marshal) {
+ if(marshal instanceof DocMarshal) {
+ this.marshal = marshal;
+ } else {
+ this.marshal = DocMarshal.root(marshal);
+ }
+ 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?
+ try {
+ if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction
+ StringWriter sw = new StringWriter();
+ jaxMar.marshal(trans.debug(), t, sw, options);
+ out.extract(new StringReader(sw.toString()), new OutputStreamWriter(os), inXML,options);
+ } else {
+ out.extract(t, new OutputStreamWriter(os), marshal,options);
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
- public void direct(Trans trans, T t, Writer writer, boolean ... options) throws APIException, IOException {
- Out out = getOut(outType);
- TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env?
- try {
- if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction
- StringWriter sw = new StringWriter();
- jaxMar.marshal(trans.debug(), t, sw, options);
- out.extract(new StringReader(sw.toString()), writer, inXML,options);
- } else {
- out.extract(t, writer, marshal,options);
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ public void direct(Trans trans, T t, Writer writer, boolean ... options) throws APIException, IOException {
+ Out out = getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction
+ StringWriter sw = new StringWriter();
+ jaxMar.marshal(trans.debug(), t, sw, options);
+ out.extract(new StringReader(sw.toString()), writer, inXML,options);
+ } else {
+ out.extract(t, writer, marshal,options);
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java
index 446c3c9c..97f68dae 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java
@@ -40,273 +40,273 @@ import org.onap.aaf.misc.rosetta.Parse;
import org.onap.aaf.misc.rosetta.Saved;
public class RosettaData<T> implements Data<T>{
- private Env trans;
- private RosettaDF<T> df;
- private Saved saved;
- private TYPE inType, outType;
- // Note: This is an array of boolean in order to pass into other methods
- private boolean options[] = new boolean[] {false, false};
- // Temp Storage of XML. Only when we must use JAXB to read in Objects
- private String xml,json;
-
- // package on purpose
- RosettaData(Env env, RosettaDF<T> rosettaDF) {
- df = rosettaDF;
- saved = new Saved(); // Note: Saved constructs storage as needed...
- trans = env;
- inType = df.getInType();
- outType = df.getOutType(); // take defaults
- }
+ private Env trans;
+ private RosettaDF<T> df;
+ private Saved saved;
+ private TYPE inType, outType;
+ // Note: This is an array of boolean in order to pass into other methods
+ private boolean options[] = new boolean[] {false, false};
+ // Temp Storage of XML. Only when we must use JAXB to read in Objects
+ private String xml,json;
+
+ // package on purpose
+ RosettaData(Env env, RosettaDF<T> rosettaDF) {
+ df = rosettaDF;
+ saved = new Saved(); // Note: Saved constructs storage as needed...
+ trans = env;
+ inType = df.getInType();
+ outType = df.getOutType(); // take defaults
+ }
-// // @Override
- public RosettaData<T> in(TYPE rosettaType) {
- inType = rosettaType;
- return this;
- }
-
-// // @Override
- public RosettaData<T> out(TYPE rosettaType) {
- outType = rosettaType;
- return this;
- }
+// // @Override
+ public RosettaData<T> in(TYPE rosettaType) {
+ inType = rosettaType;
+ return this;
+ }
+
+// // @Override
+ public RosettaData<T> out(TYPE rosettaType) {
+ outType = rosettaType;
+ return this;
+ }
-// // @Override
- public RosettaData<T> load(Reader rdr) throws APIException {
- Parse<Reader,?> in = df.getIn(inType);
- TimeTaken tt = in.start(trans);
- try {
- saved.extract(rdr, (Writer)null, in);
- xml=json=null;
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- return this;
- }
-
- // @Override
- public RosettaData<T> load(InputStream is) throws APIException {
- Parse<Reader,?> in = df.getIn(inType);
- TimeTaken tt = in.start(trans);
- try {
- saved.extract(new InputStreamReader(is), (Writer)null, in);
- xml=json=null;
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- return this;
- }
+// // @Override
+ public RosettaData<T> load(Reader rdr) throws APIException {
+ Parse<Reader,?> in = df.getIn(inType);
+ TimeTaken tt = in.start(trans);
+ try {
+ saved.extract(rdr, (Writer)null, in);
+ xml=json=null;
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ return this;
+ }
+
+ // @Override
+ public RosettaData<T> load(InputStream is) throws APIException {
+ Parse<Reader,?> in = df.getIn(inType);
+ TimeTaken tt = in.start(trans);
+ try {
+ saved.extract(new InputStreamReader(is), (Writer)null, in);
+ xml=json=null;
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ return this;
+ }
- // @Override
- public RosettaData<T> load(String str) throws APIException {
- Parse<Reader,?> in = df.getIn(inType);
- TimeTaken tt = in.start(trans);
- try {
- saved.extract(new StringReader(str), (Writer)null, in);
- switch(inType) {
- case XML:
- xml = str;
- break;
- case JSON:
- json = str;
- break;
- default:
-
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- return this;
- }
+ // @Override
+ public RosettaData<T> load(String str) throws APIException {
+ Parse<Reader,?> in = df.getIn(inType);
+ TimeTaken tt = in.start(trans);
+ try {
+ saved.extract(new StringReader(str), (Writer)null, in);
+ switch(inType) {
+ case XML:
+ xml = str;
+ break;
+ case JSON:
+ json = str;
+ break;
+ default:
+
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ return this;
+ }
- // @Override
- public RosettaData<T> load(T t) throws APIException {
- Parse<?,?> in = df.getIn(inType);
- TimeTaken tt = in.start(trans);
- try {
- if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction
- StringWriter sw = new StringWriter();
- df.jaxMar.marshal(trans.debug(), t, sw, options);
- saved.extract(new StringReader(xml = sw.toString()), (Writer)null, df.inXML);
- } else {
- saved.extract(t, (Writer)null, df.marshal);
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- return this;
- }
+ // @Override
+ public RosettaData<T> load(T t) throws APIException {
+ Parse<?,?> in = df.getIn(inType);
+ TimeTaken tt = in.start(trans);
+ try {
+ if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction
+ StringWriter sw = new StringWriter();
+ df.jaxMar.marshal(trans.debug(), t, sw, options);
+ saved.extract(new StringReader(xml = sw.toString()), (Writer)null, df.inXML);
+ } else {
+ saved.extract(t, (Writer)null, df.marshal);
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ return this;
+ }
- public Saved getEvents() {
- return saved;
- }
-
- // @Override
- public T asObject() throws APIException {
- Out out = df.getOut(TYPE.XML);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- //TODO Replace JAXB with Direct Object method!!!
- StringWriter sw = new StringWriter();
- out.extract(null, sw, saved);
- return df.jaxUmar.unmarshal(trans.debug(), sw.toString());
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ public Saved getEvents() {
+ return saved;
+ }
+
+ // @Override
+ public T asObject() throws APIException {
+ Out out = df.getOut(TYPE.XML);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ //TODO Replace JAXB with Direct Object method!!!
+ StringWriter sw = new StringWriter();
+ out.extract(null, sw, saved);
+ return df.jaxUmar.unmarshal(trans.debug(), sw.toString());
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
- // @Override
- public String asString() throws APIException {
- Out out = df.getOut(outType);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- if(outType==TYPE.XML) {
- if(xml==null) {
- StringWriter sw = new StringWriter();
- out.extract(null, sw, saved, options);
- xml = sw.toString();
- }
- return xml;
- } else { // is JSON
- if(json==null) {
- StringWriter sw = new StringWriter();
- out.extract(null, sw, saved, options);
- json = sw.toString();
- }
- return json;
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ // @Override
+ public String asString() throws APIException {
+ Out out = df.getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ if(outType==TYPE.XML) {
+ if(xml==null) {
+ StringWriter sw = new StringWriter();
+ out.extract(null, sw, saved, options);
+ xml = sw.toString();
+ }
+ return xml;
+ } else { // is JSON
+ if(json==null) {
+ StringWriter sw = new StringWriter();
+ out.extract(null, sw, saved, options);
+ json = sw.toString();
+ }
+ return json;
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
- // @Override
- public RosettaData<T> to(OutputStream os) throws APIException, IOException {
- Out out = df.getOut(outType);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- if(outType==TYPE.XML && xml!=null) {
- os.write(xml.getBytes());
- } else if(outType==TYPE.JSON && json!=null) {
- os.write(json.getBytes());
- } else {
- out.extract(null, os, saved, options);
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- return this;
- }
+ // @Override
+ public RosettaData<T> to(OutputStream os) throws APIException, IOException {
+ Out out = df.getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ if(outType==TYPE.XML && xml!=null) {
+ os.write(xml.getBytes());
+ } else if(outType==TYPE.JSON && json!=null) {
+ os.write(json.getBytes());
+ } else {
+ out.extract(null, os, saved, options);
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ return this;
+ }
- // @Override
- public RosettaData<T> to(Writer writer) throws APIException, IOException {
- Out out = df.getOut(outType);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- if(outType==TYPE.XML && xml!=null) {
- writer.append(xml);
- } else if(outType==TYPE.JSON && json!=null) {
- writer.append(json);
- } else {
- out.extract(null, writer, saved, options);
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- return this;
- }
-
- // @Override
- public Class<T> getTypeClass() {
- return df.getTypeClass();
- }
+ // @Override
+ public RosettaData<T> to(Writer writer) throws APIException, IOException {
+ Out out = df.getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ if(outType==TYPE.XML && xml!=null) {
+ writer.append(xml);
+ } else if(outType==TYPE.JSON && json!=null) {
+ writer.append(json);
+ } else {
+ out.extract(null, writer, saved, options);
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ return this;
+ }
+
+ // @Override
+ public Class<T> getTypeClass() {
+ return df.getTypeClass();
+ }
- private static final boolean[] emptyOption = new boolean[0];
-
- public void direct(InputStream is, OutputStream os) throws APIException, IOException {
- direct(is,os,emptyOption);
- }
-
- public void direct(Reader reader, Writer writer, boolean ... options) throws APIException, IOException {
- Parse<Reader,?> in = df.getIn(inType);
- Out out = df.getOut(outType);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- out.extract(reader, writer, in,options);
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ private static final boolean[] emptyOption = new boolean[0];
+
+ public void direct(InputStream is, OutputStream os) throws APIException, IOException {
+ direct(is,os,emptyOption);
+ }
+
+ public void direct(Reader reader, Writer writer, boolean ... options) throws APIException, IOException {
+ Parse<Reader,?> in = df.getIn(inType);
+ Out out = df.getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ out.extract(reader, writer, in,options);
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
- public void direct(T t, Writer writer, boolean ... options) throws APIException, IOException {
- Out out = df.getOut(outType);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction
- StringWriter sw = new StringWriter();
- df.jaxMar.marshal(trans.debug(), t, sw, options);
- out.extract(new StringReader(xml = sw.toString()), writer, df.inXML,options);
- } else {
- out.extract(t, writer, df.marshal,options);
- }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ public void direct(T t, Writer writer, boolean ... options) throws APIException, IOException {
+ Out out = df.getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction
+ StringWriter sw = new StringWriter();
+ df.jaxMar.marshal(trans.debug(), t, sw, options);
+ out.extract(new StringReader(xml = sw.toString()), writer, df.inXML,options);
+ } else {
+ out.extract(t, writer, df.marshal,options);
+ }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
- public void direct(T t, OutputStream os, boolean ... options) throws APIException, IOException {
- Out out = df.getOut(outType);
- TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
- try {
- if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction
- if(outType.equals(TYPE.XML)) {
- df.jaxMar.marshal(trans.debug(), t, os, options);
- } else {
- StringWriter sw = new StringWriter();
- df.jaxMar.marshal(trans.debug(), t, sw, options);
- out.extract(new StringReader(xml = sw.toString()), new OutputStreamWriter(os), df.inXML,options);
- }
- } else {
- out.extract(t, new OutputStreamWriter(os), df.marshal,options);
- }
+ public void direct(T t, OutputStream os, boolean ... options) throws APIException, IOException {
+ Out out = df.getOut(outType);
+ TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env?
+ try {
+ if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction
+ if(outType.equals(TYPE.XML)) {
+ df.jaxMar.marshal(trans.debug(), t, os, options);
+ } else {
+ StringWriter sw = new StringWriter();
+ df.jaxMar.marshal(trans.debug(), t, sw, options);
+ out.extract(new StringReader(xml = sw.toString()), new OutputStreamWriter(os), df.inXML,options);
+ }
+ } else {
+ out.extract(t, new OutputStreamWriter(os), df.marshal,options);
+ }
- } catch (Exception e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
+ } catch (Exception e) {
+ throw new APIException(e);
+ } finally {
+ tt.done();
+ }
+ }
-
- public void direct(InputStream is, OutputStream os, boolean ... options) throws APIException, IOException {
- direct(new InputStreamReader(is),new OutputStreamWriter(os), options);
- }
+
+ public void direct(InputStream is, OutputStream os, boolean ... options) throws APIException, IOException {
+ direct(new InputStreamReader(is),new OutputStreamWriter(os), options);
+ }
- // // @Override
- public RosettaData<T> option(int option) {
- options[0] = (option&Data.PRETTY)==Data.PRETTY;
- options[1] = (option&Data.FRAGMENT)==Data.FRAGMENT;
- return this;
- }
+ // // @Override
+ public RosettaData<T> option(int option) {
+ options[0] = (option&Data.PRETTY)==Data.PRETTY;
+ options[1] = (option&Data.FRAGMENT)==Data.FRAGMENT;
+ return this;
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java
index 05c75b7e..43855d6c 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java
@@ -39,51 +39,51 @@ import org.onap.aaf.misc.env.APIException;
*/
public class RosettaEnv extends org.onap.aaf.misc.env.impl.BasicEnv {
- public RosettaEnv() {
- super();
- }
+ public RosettaEnv() {
+ super();
+ }
- public RosettaEnv(Applet applet, String... tags) {
- super(applet, tags);
- }
+ public RosettaEnv(Applet applet, String... tags) {
+ super(applet, tags);
+ }
- public RosettaEnv(String[] args) {
- super(args);
- }
+ public RosettaEnv(String[] args) {
+ super(args);
+ }
- public RosettaEnv(String tag, String[] args) {
- super(tag, args);
- }
+ public RosettaEnv(String tag, String[] args) {
+ super(tag, args);
+ }
- public RosettaEnv(String tag, Properties props) {
- super(tag, props);
- }
+ public RosettaEnv(String tag, Properties props) {
+ super(tag, props);
+ }
- public RosettaEnv(Properties props) {
- super(props);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> RosettaDF<T> newDataFactory(Class<?>... classes) throws APIException {
- return new RosettaDF<T>(this, null, null, (Class<T>)classes[0]);
- }
+ public RosettaEnv(Properties props) {
+ super(props);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> RosettaDF<T> newDataFactory(Class<?>... classes) throws APIException {
+ return new RosettaDF<T>(this, null, null, (Class<T>)classes[0]);
+ }
- @SuppressWarnings("unchecked")
- @Override
- public <T> RosettaDF<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException {
- return new RosettaDF<T>(this, schema, null, (Class<T>)classes[0]);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> RosettaDF<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException {
+ return new RosettaDF<T>(this, schema, null, (Class<T>)classes[0]);
+ }
- @SuppressWarnings("unchecked")
- @Override
- public<T> RosettaDF<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException {
- return new RosettaDF<T>(this, null, qName.getNamespaceURI(),(Class<T>)classes[0]);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public<T> RosettaDF<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException {
+ return new RosettaDF<T>(this, null, qName.getNamespaceURI(),(Class<T>)classes[0]);
+ }
- @SuppressWarnings("unchecked")
- @Override
- public<T> RosettaDF<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException {
- return new RosettaDF<T>(this, schema,qName.getNamespaceURI(),(Class<T>)classes[0]);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public<T> RosettaDF<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException {
+ return new RosettaDF<T>(this, schema,qName.getNamespaceURI(),(Class<T>)classes[0]);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java
index 1655928d..849a3214 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java
@@ -34,106 +34,106 @@ import org.onap.aaf.misc.env.util.Chrono;
* @param <T>
*/
public abstract class DataWriter<T> {
- public abstract boolean write(T t, StringBuilder sb);
-
- public final static DataWriter<String> STRING = new DataWriter<String>() {
- @Override
- public boolean write(String s, StringBuilder sb) {
- sb.append(s);
- return true;
- }
- };
-
- public final static DataWriter<Integer> INTEGER = new DataWriter<Integer>() {
- @Override
- public boolean write(Integer i, StringBuilder sb) {
- sb.append(i);
- return false;
- }
- };
-
- public final static DataWriter<Long> LONG = new DataWriter<Long>() {
- @Override
- public boolean write(Long t, StringBuilder sb) {
- sb.append(t);
- return false;
- }
- };
+ public abstract boolean write(T t, StringBuilder sb);
+
+ public final static DataWriter<String> STRING = new DataWriter<String>() {
+ @Override
+ public boolean write(String s, StringBuilder sb) {
+ sb.append(s);
+ return true;
+ }
+ };
+
+ public final static DataWriter<Integer> INTEGER = new DataWriter<Integer>() {
+ @Override
+ public boolean write(Integer i, StringBuilder sb) {
+ sb.append(i);
+ return false;
+ }
+ };
+
+ public final static DataWriter<Long> LONG = new DataWriter<Long>() {
+ @Override
+ public boolean write(Long t, StringBuilder sb) {
+ sb.append(t);
+ return false;
+ }
+ };
- public final static DataWriter<Byte> BYTE = new DataWriter<Byte>() {
- @Override
- public boolean write(Byte t, StringBuilder sb) {
- sb.append(t);
- return false;
- }
- };
+ public final static DataWriter<Byte> BYTE = new DataWriter<Byte>() {
+ @Override
+ public boolean write(Byte t, StringBuilder sb) {
+ sb.append(t);
+ return false;
+ }
+ };
- public final static DataWriter<Character> CHAR = new DataWriter<Character>() {
- @Override
- public boolean write(Character t, StringBuilder sb) {
- sb.append(t);
- return true;
- }
- };
+ public final static DataWriter<Character> CHAR = new DataWriter<Character>() {
+ @Override
+ public boolean write(Character t, StringBuilder sb) {
+ sb.append(t);
+ return true;
+ }
+ };
- public final static DataWriter<Boolean> BOOL = new DataWriter<Boolean>() {
- @Override
- public boolean write(Boolean t, StringBuilder sb) {
- sb.append(t);
- return true;
- }
- };
+ public final static DataWriter<Boolean> BOOL = new DataWriter<Boolean>() {
+ @Override
+ public boolean write(Boolean t, StringBuilder sb) {
+ sb.append(t);
+ return true;
+ }
+ };
- /*
- public final static DataWriter<byte[]> BYTE_ARRAY = new DataWriter<byte[]>() {
- @Override
- public boolean write(byte[] ba, StringBuilder sb) {
- ByteArrayInputStream bais = new ByteArrayInputStream(ba);
- StringBuilderOutputStream sbos = new StringBuilderOutputStream(sb);
-// try {
- //TODO find Base64
-// Symm.base64noSplit().encode(bais, sbos);
-// } catch (IOException e) {
-// // leave blank
-// }
- return true;
- }
-
- };
- */
+ /*
+ public final static DataWriter<byte[]> BYTE_ARRAY = new DataWriter<byte[]>() {
+ @Override
+ public boolean write(byte[] ba, StringBuilder sb) {
+ ByteArrayInputStream bais = new ByteArrayInputStream(ba);
+ StringBuilderOutputStream sbos = new StringBuilderOutputStream(sb);
+// try {
+ //TODO find Base64
+// Symm.base64noSplit().encode(bais, sbos);
+// } catch (IOException e) {
+// // leave blank
+// }
+ return true;
+ }
+
+ };
+ */
- public final static DataWriter<XMLGregorianCalendar> DATE = new DataWriter<XMLGregorianCalendar>() {
- @Override
- public boolean write(XMLGregorianCalendar t, StringBuilder sb) {
- sb.append(Chrono.dateOnlyStamp(t));
- return true;
- }
- };
-
- public final static DataWriter<XMLGregorianCalendar> DATE_TIME = new DataWriter<XMLGregorianCalendar>() {
- @Override
- public boolean write(XMLGregorianCalendar t, StringBuilder sb) {
- sb.append(Chrono.dateTime(t));
- return true;
- }
- };
+ public final static DataWriter<XMLGregorianCalendar> DATE = new DataWriter<XMLGregorianCalendar>() {
+ @Override
+ public boolean write(XMLGregorianCalendar t, StringBuilder sb) {
+ sb.append(Chrono.dateOnlyStamp(t));
+ return true;
+ }
+ };
+
+ public final static DataWriter<XMLGregorianCalendar> DATE_TIME = new DataWriter<XMLGregorianCalendar>() {
+ @Override
+ public boolean write(XMLGregorianCalendar t, StringBuilder sb) {
+ sb.append(Chrono.dateTime(t));
+ return true;
+ }
+ };
- private static final char[] chars="0123456789ABCDEF".toCharArray();
- public final static DataWriter<byte[]> HEX_BINARY = new DataWriter<byte[]>() {
- @Override
- public boolean write(byte[] ba, StringBuilder sb) {
- // FYI, doing this because don't want intermediate
- // String in "HexString" or the processing in
- // "String.format"
- //sb.append("0x");
- for(int i=0;i<ba.length;++i) {
- byte b = ba[i];
- sb.append(chars[((b&0xF0)>>4)]);
- sb.append(chars[b&0xF]);
- }
- return true;
- }
- };
+ private static final char[] chars="0123456789ABCDEF".toCharArray();
+ public final static DataWriter<byte[]> HEX_BINARY = new DataWriter<byte[]>() {
+ @Override
+ public boolean write(byte[] ba, StringBuilder sb) {
+ // FYI, doing this because don't want intermediate
+ // String in "HexString" or the processing in
+ // "String.format"
+ //sb.append("0x");
+ for(int i=0;i<ba.length;++i) {
+ byte b = ba[i];
+ sb.append(chars[((b&0xF0)>>4)]);
+ sb.append(chars[b&0xF]);
+ }
+ return true;
+ }
+ };
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java
index 2776546f..6cabe068 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java
@@ -30,57 +30,57 @@ import org.onap.aaf.misc.rosetta.ParseException;
import org.onap.aaf.misc.rosetta.Parsed;
public class DocMarshal<T> extends Marshal<T> {
- private Marshal<T> root;
-
- public DocMarshal(Marshal<T> root) {
- this.root = root;
- }
-
- @Override
- public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException {
- Ladder<Iterator<?>> ladder = parsed.state.ladder;
- Iterator<?> iter = ladder.peek();
- if(iter==null) {
- ladder.push(PENDING_ITERATOR);
- parsed.event = START_DOC;
- } else if (DONE_ITERATOR.equals(iter)) {
- } else {
- ladder.ascend(); // look at field info
- Iterator<?> currFieldIter = ladder.peek();
- if(!DONE_ITERATOR.equals(currFieldIter)){
- parsed = root.parse(t, parsed);
- }
- ladder.descend();
- if(DONE_ITERATOR.equals(currFieldIter) || parsed.event==NONE) {
- parsed.event = END_DOC;
- ladder.push(DONE_ITERATOR);
- }
- }
- return parsed; // if unchanged, then it will end process
+ private Marshal<T> root;
+
+ public DocMarshal(Marshal<T> root) {
+ this.root = root;
+ }
+
+ @Override
+ public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException {
+ Ladder<Iterator<?>> ladder = parsed.state.ladder;
+ Iterator<?> iter = ladder.peek();
+ if(iter==null) {
+ ladder.push(PENDING_ITERATOR);
+ parsed.event = START_DOC;
+ } else if (DONE_ITERATOR.equals(iter)) {
+ } else {
+ ladder.ascend(); // look at field info
+ Iterator<?> currFieldIter = ladder.peek();
+ if(!DONE_ITERATOR.equals(currFieldIter)){
+ parsed = root.parse(t, parsed);
+ }
+ ladder.descend();
+ if(DONE_ITERATOR.equals(currFieldIter) || parsed.event==NONE) {
+ parsed.event = END_DOC;
+ ladder.push(DONE_ITERATOR);
+ }
+ }
+ return parsed; // if unchanged, then it will end process
- }
+ }
- public static final Iterator<Void> PENDING_ITERATOR = new Iterator<Void>() {
- @Override
- public boolean hasNext() {
- return false;
- }
+ public static final Iterator<Void> PENDING_ITERATOR = new Iterator<Void>() {
+ @Override
+ public boolean hasNext() {
+ return false;
+ }
- @Override
- public Void next() {
- if(!hasNext()) {
- throw new NoSuchElementException();
- }
- return null;
- }
+ @Override
+ public Void next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return null;
+ }
- @Override
- public void remove() {
- }
- };
+ @Override
+ public void remove() {
+ }
+ };
- public static<T> DocMarshal<T> root(Marshal<T> m) {
- return (DocMarshal<T>)new DocMarshal<T>(m);
- }
+ public static<T> DocMarshal<T> root(Marshal<T> m) {
+ return (DocMarshal<T>)new DocMarshal<T>(m);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java
index 3006f897..48f3608d 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java
@@ -31,62 +31,62 @@ import org.onap.aaf.misc.rosetta.Parsed;
public abstract class FieldArray<T,S> extends Marshal<T> {
- private DataWriter<S> dataWriter;
- private String name;
+ private DataWriter<S> dataWriter;
+ private String name;
- public FieldArray(String name, DataWriter<S> dw) {
- this.name = name;
- dataWriter = dw;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException {
- Ladder<Iterator<?>> ladder = parsed.state.ladder;
- Iterator<?> iter = ladder.peek();
- if(iter==null) {
- List<S> list = data(t);
- if(list.isEmpty() && parsed.state.smallest) {
- ladder.push(DONE_ITERATOR);
- } else {
- ladder.push(new ListIterator<S>(list));
- parsed.event = START_ARRAY;
- parsed.name = name;
- }
- } else if (DONE_ITERATOR.equals(iter)) {
- } else {
- ladder.ascend(); // look at field info
- Iterator<?> memIter = ladder.peek();
- ListIterator<S> mems = (ListIterator<S>)iter;
- S mem;
- if(memIter==null) {
- mem=mems.next();
- } else if(!DONE_ITERATOR.equals(memIter)) {
- mem=mems.peek();
- } else if(iter.hasNext()) {
- mem=null;
- ladder.push(null);
- } else {
- mem=null;
- }
-
- if(mem!=null) {
- parsed.isString=dataWriter.write(mem, parsed.sb);
- parsed.event = NEXT;
- }
- ladder.descend();
- if(mem==null) {
- if(iter.hasNext()) {
- parsed.event = NEXT;
- } else {
- parsed.event = END_ARRAY;
- ladder.push(DONE_ITERATOR);
- }
- }
- }
- return parsed; // if unchanged, then it will end process
- }
+ public FieldArray(String name, DataWriter<S> dw) {
+ this.name = name;
+ dataWriter = dw;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException {
+ Ladder<Iterator<?>> ladder = parsed.state.ladder;
+ Iterator<?> iter = ladder.peek();
+ if(iter==null) {
+ List<S> list = data(t);
+ if(list.isEmpty() && parsed.state.smallest) {
+ ladder.push(DONE_ITERATOR);
+ } else {
+ ladder.push(new ListIterator<S>(list));
+ parsed.event = START_ARRAY;
+ parsed.name = name;
+ }
+ } else if (DONE_ITERATOR.equals(iter)) {
+ } else {
+ ladder.ascend(); // look at field info
+ Iterator<?> memIter = ladder.peek();
+ ListIterator<S> mems = (ListIterator<S>)iter;
+ S mem;
+ if(memIter==null) {
+ mem=mems.next();
+ } else if(!DONE_ITERATOR.equals(memIter)) {
+ mem=mems.peek();
+ } else if(iter.hasNext()) {
+ mem=null;
+ ladder.push(null);
+ } else {
+ mem=null;
+ }
+
+ if(mem!=null) {
+ parsed.isString=dataWriter.write(mem, parsed.sb);
+ parsed.event = NEXT;
+ }
+ ladder.descend();
+ if(mem==null) {
+ if(iter.hasNext()) {
+ parsed.event = NEXT;
+ } else {
+ parsed.event = END_ARRAY;
+ ladder.push(DONE_ITERATOR);
+ }
+ }
+ }
+ return parsed; // if unchanged, then it will end process
+ }
- protected abstract List<S> data(T t);
+ protected abstract List<S> data(T t);
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java
index 1de14e82..34fa5dd6 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java
@@ -22,17 +22,17 @@
package org.onap.aaf.misc.rosetta.marshal;
public abstract class FieldBlob<T> extends FieldMarshal<T>{
- public FieldBlob(String name) {
- super(name);
- }
+ public FieldBlob(String name) {
+ super(name);
+ }
- protected abstract byte[] data(T t);
+ protected abstract byte[] data(T t);
- @Override
- protected boolean data(T t, StringBuilder sb) {
- return false;
- // unimplemented
- //return DataWriter.BYTE_ARRAY.write(data(t),sb);
- }
+ @Override
+ protected boolean data(T t, StringBuilder sb) {
+ return false;
+ // unimplemented
+ //return DataWriter.BYTE_ARRAY.write(data(t),sb);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java
index b3632a14..2418d7af 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java
@@ -24,14 +24,14 @@ package org.onap.aaf.misc.rosetta.marshal;
import javax.xml.datatype.XMLGregorianCalendar;
public abstract class FieldDate<T> extends FieldMarshal<T> {
- public FieldDate(String name) {
- super(name);
- }
+ public FieldDate(String name) {
+ super(name);
+ }
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- return DataWriter.DATE.write(data(t), sb);
- }
+ @Override
+ final protected boolean data(T t, StringBuilder sb) {
+ return DataWriter.DATE.write(data(t), sb);
+ }
- protected abstract XMLGregorianCalendar data(T t);
+ protected abstract XMLGregorianCalendar data(T t);
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java
index 8aa29829..ae125617 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java
@@ -24,14 +24,14 @@ package org.onap.aaf.misc.rosetta.marshal;
import javax.xml.datatype.XMLGregorianCalendar;
public abstract class FieldDateTime<T> extends FieldMarshal<T> {
- public FieldDateTime(String name) {
- super(name);
- }
+ public FieldDateTime(String name) {
+ super(name);
+ }
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- return DataWriter.DATE_TIME.write(data(t), sb);
- }
+ @Override
+ final protected boolean data(T t, StringBuilder sb) {
+ return DataWriter.DATE_TIME.write(data(t), sb);
+ }
- protected abstract XMLGregorianCalendar data(T t);
+ protected abstract XMLGregorianCalendar data(T t);
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java
index 589d0920..fa9e6323 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java
@@ -22,14 +22,14 @@
package org.onap.aaf.misc.rosetta.marshal;
public abstract class FieldHexBinary<T> extends FieldMarshal<T>{
- public FieldHexBinary(String name) {
- super(name);
- }
+ public FieldHexBinary(String name) {
+ super(name);
+ }
- protected abstract byte[] data(T t);
+ protected abstract byte[] data(T t);
- @Override
- protected boolean data(T t, StringBuilder sb) {
- return DataWriter.HEX_BINARY.write(data(t), sb);
- }
+ @Override
+ protected boolean data(T t, StringBuilder sb) {
+ return DataWriter.HEX_BINARY.write(data(t), sb);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java
index cb8b6557..2e77618b 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java
@@ -27,33 +27,33 @@ import org.onap.aaf.misc.rosetta.Parse;
import org.onap.aaf.misc.rosetta.Parsed;
public abstract class FieldMarshal<T> extends Marshal<T> {
- private String name;
+ private String name;
- public FieldMarshal(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public Parsed<State> parse(T t, Parsed<State> parsed) {
- parsed.state.ladder.push(DONE_ITERATOR);
- parsed.event = Parse.NEXT;
- parsed.name = name;
- parsed.isString = data(t,parsed.sb);
- return parsed;
- }
+ public FieldMarshal(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Parsed<State> parse(T t, Parsed<State> parsed) {
+ parsed.state.ladder.push(DONE_ITERATOR);
+ parsed.event = Parse.NEXT;
+ parsed.name = name;
+ parsed.isString = data(t,parsed.sb);
+ return parsed;
+ }
- /**
- * Write Value to StringBuilder
- * Return true if value looks like a String
- * false if it is Numeric
- * @param t
- * @param sb
- * @return
- */
- protected abstract boolean data(T t, StringBuilder sb);
-
+ /**
+ * Write Value to StringBuilder
+ * Return true if value looks like a String
+ * false if it is Numeric
+ * @param t
+ * @param sb
+ * @return
+ */
+ protected abstract boolean data(T t, StringBuilder sb);
+
} \ No newline at end of file
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java
index aac9ac69..0a5c28ad 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java
@@ -22,15 +22,15 @@
package org.onap.aaf.misc.rosetta.marshal;
public abstract class FieldNumeric<N,T> extends FieldMarshal<T> {
- public FieldNumeric(String name) {
- super(name);
- }
+ public FieldNumeric(String name) {
+ super(name);
+ }
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- sb.append(data(t));
- return false;
- }
+ @Override
+ final protected boolean data(T t, StringBuilder sb) {
+ sb.append(data(t));
+ return false;
+ }
- protected abstract N data(T t);
+ protected abstract N data(T t);
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java
index 2337c3c9..e96b6967 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java
@@ -22,15 +22,15 @@
package org.onap.aaf.misc.rosetta.marshal;
public abstract class FieldString<T> extends FieldMarshal<T> {
- public FieldString(String name) {
- super(name);
- }
+ public FieldString(String name) {
+ super(name);
+ }
- protected abstract String data(T t);
+ protected abstract String data(T t);
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- return DataWriter.STRING.write(data(t), sb);
- }
+ @Override
+ final protected boolean data(T t, StringBuilder sb) {
+ return DataWriter.STRING.write(data(t), sb);
+ }
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java
index 6045141d..ed8b98c4 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java
@@ -31,29 +31,29 @@ import java.util.List;
* @param <T>
*/
final class ListIterator<T> implements Iterator<T> {
- private T curr;
- private Iterator<T> delg;
- public ListIterator(List<T> list) {
- curr = null;
- delg = list.iterator();
- }
- @Override
- public boolean hasNext() {
- return delg.hasNext();
- }
+ private T curr;
+ private Iterator<T> delg;
+ public ListIterator(List<T> list) {
+ curr = null;
+ delg = list.iterator();
+ }
+ @Override
+ public boolean hasNext() {
+ return delg.hasNext();
+ }
- @Override
- public T next() {
- return curr = delg.hasNext()?delg.next():null;
- }
-
- public T peek() {
- return curr==null?next():curr;
- }
+ @Override
+ public T next() {
+ return curr = delg.hasNext()?delg.next():null;
+ }
+
+ public T peek() {
+ return curr==null?next():curr;
+ }
- @Override
- public void remove() {
- delg.remove();
- }
-
+ @Override
+ public void remove() {
+ delg.remove();
+ }
+
} \ No newline at end of file
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java
index fa95dee5..384e0c98 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java
@@ -31,59 +31,59 @@ import org.onap.aaf.misc.rosetta.Parsed;
public abstract class ObjArray<T,S> extends Marshal<T> {
- private String name;
- private Marshal<S> subMarshaller;
+ private String name;
+ private Marshal<S> subMarshaller;
- public ObjArray(String name, Marshal<S> subMarshaller) {
- this.name = name;
- this.subMarshaller = subMarshaller;
- }
+ public ObjArray(String name, Marshal<S> subMarshaller) {
+ this.name = name;
+ this.subMarshaller = subMarshaller;
+ }
- @SuppressWarnings("unchecked")
- @Override
- public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException {
- Ladder<Iterator<?>> ladder = parsed.state.ladder;
- Iterator<?> iter = ladder.peek();
- if(iter==null) {
- List<S> list = data(t);
- if(list.isEmpty() && parsed.state.smallest) {
- ladder.push(DONE_ITERATOR);
- } else {
- ladder.push(new ListIterator<S>(list));
- parsed.event = START_ARRAY;
- parsed.name = name;
- }
- } else if (!DONE_ITERATOR.equals(iter)) {
- ladder.ascend(); // look at field info
- Iterator<?> memIter = ladder.peek();
- ListIterator<S> mems = (ListIterator<S>)iter;
- S mem;
- if(memIter==null) {
- mem=mems.next();
- } else if(!DONE_ITERATOR.equals(memIter)) {
- mem=mems.peek();
- } else if(iter.hasNext()) {
- mem=null;
- ladder.push(null);
- } else {
- mem=null;
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException {
+ Ladder<Iterator<?>> ladder = parsed.state.ladder;
+ Iterator<?> iter = ladder.peek();
+ if(iter==null) {
+ List<S> list = data(t);
+ if(list.isEmpty() && parsed.state.smallest) {
+ ladder.push(DONE_ITERATOR);
+ } else {
+ ladder.push(new ListIterator<S>(list));
+ parsed.event = START_ARRAY;
+ parsed.name = name;
+ }
+ } else if (!DONE_ITERATOR.equals(iter)) {
+ ladder.ascend(); // look at field info
+ Iterator<?> memIter = ladder.peek();
+ ListIterator<S> mems = (ListIterator<S>)iter;
+ S mem;
+ if(memIter==null) {
+ mem=mems.next();
+ } else if(!DONE_ITERATOR.equals(memIter)) {
+ mem=mems.peek();
+ } else if(iter.hasNext()) {
+ mem=null;
+ ladder.push(null);
+ } else {
+ mem=null;
+ }
- if(mem!=null)
- parsed = subMarshaller.parse(mem, parsed);
- ladder.descend();
- if(mem==null) {
- if(iter.hasNext()) {
- parsed.event = NEXT;
- } else {
- parsed.event = END_ARRAY;
- ladder.push(DONE_ITERATOR);
- }
- }
- }
- return parsed; // if unchanged, then it will end process
- }
+ if(mem!=null)
+ parsed = subMarshaller.parse(mem, parsed);
+ ladder.descend();
+ if(mem==null) {
+ if(iter.hasNext()) {
+ parsed.event = NEXT;
+ } else {
+ parsed.event = END_ARRAY;
+ ladder.push(DONE_ITERATOR);
+ }
+ }
+ }
+ return parsed; // if unchanged, then it will end process
+ }
- protected abstract List<S> data(T t);
+ protected abstract List<S> data(T t);
}
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java
index cb2c478a..31e214b5 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java
@@ -38,94 +38,94 @@ import org.onap.aaf.misc.rosetta.Parsed;
* @param <T>
*/
public abstract class ObjMarshal<T> extends Marshal<T> {
- // Note: Not Using List or ArrayList, because there is no "Peek" concept in their iterator.
- private Marshal<T>[] pml;
- private int end=0;
-
- /**
- * @param pm
- */
- @SuppressWarnings("unchecked")
- protected void add(Marshal<T> pm) {
- if(pml==null) {
- pml = new Marshal[Ladder.DEFAULT_INIT_SIZE];
- } else if(end>pml.length) {
- Object temp[] = pml;
- pml = new Marshal[pml.length+Ladder.DEFAULT_INIT_SIZE];
- System.arraycopy(temp, 0, pml, 0, pml.length);
- }
- pml[end]=pm;
- ++end;
- }
-
- /* (non-Javadoc)
- * @see org.onap.aaf.misc.rosetta.Parse#parse(java.lang.Object, org.onap.aaf.misc.rosetta.Parsed)
- */
- @SuppressWarnings("unchecked")
- @Override
- public Parsed<State> parse(T in, Parsed<State> parsed) throws ParseException {
- Ladder<Iterator<?>> ladder = parsed.state.ladder;
- Iterator<Marshal<T>> iter = (Iterator<Marshal<T>>)ladder.peek();
- if(iter==null) {
- if(pml.length>0) {
- ladder.push(new FieldsIterator());
- parsed.event = START_OBJ;
- } else {
- ladder.push(DONE_ITERATOR);
- }
- } else if (!DONE_ITERATOR.equals(iter)) {
- FieldsIterator fields = (FieldsIterator)iter;
- ladder.ascend(); // look at field info
- Iterator<?> currFieldIter = ladder.peek();
- Marshal<T> marshal;
- if(currFieldIter==null) {
- marshal=fields.next();
- } else if(!DONE_ITERATOR.equals(currFieldIter)) {
- marshal=fields.peek();
- if(marshal==null && fields.hasNext())marshal=fields.next();
- } else if(fields.hasNext()) {
- marshal=fields.next();
- ladder.push(null);
- } else {
- marshal=null;
- }
+ // Note: Not Using List or ArrayList, because there is no "Peek" concept in their iterator.
+ private Marshal<T>[] pml;
+ private int end=0;
+
+ /**
+ * @param pm
+ */
+ @SuppressWarnings("unchecked")
+ protected void add(Marshal<T> pm) {
+ if(pml==null) {
+ pml = new Marshal[Ladder.DEFAULT_INIT_SIZE];
+ } else if(end>pml.length) {
+ Object temp[] = pml;
+ pml = new Marshal[pml.length+Ladder.DEFAULT_INIT_SIZE];
+ System.arraycopy(temp, 0, pml, 0, pml.length);
+ }
+ pml[end]=pm;
+ ++end;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.aaf.misc.rosetta.Parse#parse(java.lang.Object, org.onap.aaf.misc.rosetta.Parsed)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Parsed<State> parse(T in, Parsed<State> parsed) throws ParseException {
+ Ladder<Iterator<?>> ladder = parsed.state.ladder;
+ Iterator<Marshal<T>> iter = (Iterator<Marshal<T>>)ladder.peek();
+ if(iter==null) {
+ if(pml.length>0) {
+ ladder.push(new FieldsIterator());
+ parsed.event = START_OBJ;
+ } else {
+ ladder.push(DONE_ITERATOR);
+ }
+ } else if (!DONE_ITERATOR.equals(iter)) {
+ FieldsIterator fields = (FieldsIterator)iter;
+ ladder.ascend(); // look at field info
+ Iterator<?> currFieldIter = ladder.peek();
+ Marshal<T> marshal;
+ if(currFieldIter==null) {
+ marshal=fields.next();
+ } else if(!DONE_ITERATOR.equals(currFieldIter)) {
+ marshal=fields.peek();
+ if(marshal==null && fields.hasNext())marshal=fields.next();
+ } else if(fields.hasNext()) {
+ marshal=fields.next();
+ ladder.push(null);
+ } else {
+ marshal=null;
+ }
- if(marshal!=null)
- parsed = marshal.parse(in, parsed);
- ladder.descend();
- if(marshal==null || parsed.event==NONE) {
- parsed.event = END_OBJ;
- ladder.push(DONE_ITERATOR);
- }
- }
- return parsed; // if unchanged, then it will end process
- }
+ if(marshal!=null)
+ parsed = marshal.parse(in, parsed);
+ ladder.descend();
+ if(marshal==null || parsed.event==NONE) {
+ parsed.event = END_OBJ;
+ ladder.push(DONE_ITERATOR);
+ }
+ }
+ return parsed; // if unchanged, then it will end process
+ }
- private class FieldsIterator implements Iterator<Marshal<T>> {
- private int idx = -1;
+ private class FieldsIterator implements Iterator<Marshal<T>> {
+ private int idx = -1;
- @Override
- public boolean hasNext() {
- return idx<end;
- }
+ @Override
+ public boolean hasNext() {
+ return idx<end;
+ }
- @Override
- public Marshal<T> next() {
- if(!hasNext()) {
- throw new NoSuchElementException();
- }
- return pml[++idx];
- }
+ @Override
+ public Marshal<T> next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return pml[++idx];
+ }
- public Marshal<T> peek() {
- return idx<0?null:pml[idx];
- }
-
- @Override
- public void remove() {
- pml[idx]=null;
- }
-
- }
+ public Marshal<T> peek() {
+ return idx<0?null:pml[idx];
+ }
+
+ @Override
+ public void remove() {
+ pml[idx]=null;
+ }
+
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java
index 121deea0..3e12f594 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java
@@ -44,225 +44,225 @@ import s.xsd.LargerData;
import s.xsd.SampleData;
public class JU_FromJSON {
- private static int ITERATIONS = 10000;
- static String str = "{\"SampleData\":[" +
- "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," +
- "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}";
- InJson inJSON = new InJson();
+ private static int ITERATIONS = 10000;
+ static String str = "{\"SampleData\":[" +
+ "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," +
+ "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}";
+ InJson inJSON = new InJson();
- @Test
- public void rawParse() throws Exception {
- System.out.println("*** PARSE JSON -> RAW Dump ***");
- System.out.println(str);
- StringBuilderWriter sbw = new StringBuilderWriter();
- new OutRaw().extract(new StringReader(str),sbw,inJSON);
- System.out.println(sbw.getBuffer());
- }
-
- @Test
- public void parseJSON2Dump() throws Exception {
- System.out.println("*** PARSE JSON -> Dump ***");
- System.out.println(str);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- new OutDump().extract(new StringReader(str), sbw, inJSON);
-
- System.out.println(sbw.getBuffer());
- }
-
- @Test
- public void nonprettyJSON() throws Exception {
- System.out.println("*** JSON -> (Intermediate Stream) -> Non-pretty JSON ***");
- System.out.println(str);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ @Test
+ public void rawParse() throws Exception {
+ System.out.println("*** PARSE JSON -> RAW Dump ***");
+ System.out.println(str);
+ StringBuilderWriter sbw = new StringBuilderWriter();
+ new OutRaw().extract(new StringReader(str),sbw,inJSON);
+ System.out.println(sbw.getBuffer());
+ }
+
+ @Test
+ public void parseJSON2Dump() throws Exception {
+ System.out.println("*** PARSE JSON -> Dump ***");
+ System.out.println(str);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ new OutDump().extract(new StringReader(str), sbw, inJSON);
+
+ System.out.println(sbw.getBuffer());
+ }
+
+ @Test
+ public void nonprettyJSON() throws Exception {
+ System.out.println("*** JSON -> (Intermediate Stream) -> Non-pretty JSON ***");
+ System.out.println(str);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
- Out jout = new OutJson();
- Trans trans;
- Report report = new Report(ITERATIONS,"JSON");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(str);
- TimeTaken tt = trans.start("Parse JSON", Env.JSON);
- try {
- jout.extract(sr, sbw, inJSON);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.JSON);
- } while(report.go());
-
- String result = sbw.toString();
- System.out.println(result);
- Assert.assertEquals(result, str);
- report.report(sbw);
- System.out.println(sbw.toString());
- }
-
- @Test
- public void parseJSON2JSON() throws Exception {
- System.out.println("*** JSON -> (Intermediate Stream) -> Pretty JSON ***");
- System.out.println(str);
+ Out jout = new OutJson();
+ Trans trans;
+ Report report = new Report(ITERATIONS,"JSON");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(str);
+ TimeTaken tt = trans.start("Parse JSON", Env.JSON);
+ try {
+ jout.extract(sr, sbw, inJSON);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.JSON);
+ } while(report.go());
+
+ String result = sbw.toString();
+ System.out.println(result);
+ Assert.assertEquals(result, str);
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
+
+ @Test
+ public void parseJSON2JSON() throws Exception {
+ System.out.println("*** JSON -> (Intermediate Stream) -> Pretty JSON ***");
+ System.out.println(str);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- Out jout = new OutJson();
- Trans trans;
- Report report = new Report(ITERATIONS,"JSON");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(str);
- TimeTaken tt = trans.start("Parse JSON", Env.JSON);
- try {
- jout.extract(sr, sbw, inJSON,true);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.JSON);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ Out jout = new OutJson();
+ Trans trans;
+ Report report = new Report(ITERATIONS,"JSON");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(str);
+ TimeTaken tt = trans.start("Parse JSON", Env.JSON);
+ try {
+ jout.extract(sr, sbw, inJSON,true);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.JSON);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
- @Test
- public void parseJSON2XML() throws Exception {
- System.out.println("*** PARSE JSON -> XML ***");
- System.out.println(str);
+ @Test
+ public void parseJSON2XML() throws Exception {
+ System.out.println("*** PARSE JSON -> XML ***");
+ System.out.println(str);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- Out xout = new OutXML("LargerData","xmlns=urn:s:xsd");
- Trans trans;
- Report report = new Report(ITERATIONS,"JSON");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(str);
- TimeTaken tt = trans.start("Parse JSON", Env.JSON);
- try {
- xout.extract(sr, sbw, inJSON);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.JSON);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ Out xout = new OutXML("LargerData","xmlns=urn:s:xsd");
+ Trans trans;
+ Report report = new Report(ITERATIONS,"JSON");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(str);
+ TimeTaken tt = trans.start("Parse JSON", Env.JSON);
+ try {
+ xout.extract(sr, sbw, inJSON);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.JSON);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
- @Test
- public void parseJSON2PrettyXML() throws Exception {
- System.out.println("*** PARSE JSON -> Pretty XML ***");
- System.out.println(str);
+ @Test
+ public void parseJSON2PrettyXML() throws Exception {
+ System.out.println("*** PARSE JSON -> Pretty XML ***");
+ System.out.println(str);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
- IndentPrintWriter ipw = new IndentPrintWriter(sbw);
-
- Out xout = new OutXML("LargerData","xmlns=urn:s:xsd");
- Trans trans;
- Report report = new Report(ITERATIONS,"JSON");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(str);
- TimeTaken tt = trans.start("Parse JSON", Env.JSON);
- try {
- xout.extract(sr, ipw, inJSON);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.JSON);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
-
-
- @Test
- public void jaxbObj2XML() throws Exception {
- System.out.println("*** JAXB Object -> XML ***");
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ IndentPrintWriter ipw = new IndentPrintWriter(sbw);
+
+ Out xout = new OutXML("LargerData","xmlns=urn:s:xsd");
+ Trans trans;
+ Report report = new Report(ITERATIONS,"JSON");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(str);
+ TimeTaken tt = trans.start("Parse JSON", Env.JSON);
+ try {
+ xout.extract(sr, ipw, inJSON);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.JSON);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
+
+
+ @Test
+ public void jaxbObj2XML() throws Exception {
+ System.out.println("*** JAXB Object -> XML ***");
- LargerData ld = new LargerData();
- SampleData sd = new SampleData();
- sd.setDate(System.currentTimeMillis());
- sd.setId("sd object \"1\"");
- sd.getItem().add("Item 1.1");
- sd.getItem().add("Item 1.2");
- ld.getSampleData().add(sd);
- sd = new SampleData();
- sd.setDate(System.currentTimeMillis());
- sd.setId("sd object \"2\"");
- sd.getItem().add("Item 2.1");
- sd.getItem().add("Item 2.2");
- ld.getSampleData().add(sd);
- ld.setFluff("MyFluff");
-
- JAXBmar jaxBmar = new JAXBmar(LargerData.class);
- //jaxBmar.asFragment(true);
- //jaxBmar.pretty(true);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ LargerData ld = new LargerData();
+ SampleData sd = new SampleData();
+ sd.setDate(System.currentTimeMillis());
+ sd.setId("sd object \"1\"");
+ sd.getItem().add("Item 1.1");
+ sd.getItem().add("Item 1.2");
+ ld.getSampleData().add(sd);
+ sd = new SampleData();
+ sd.setDate(System.currentTimeMillis());
+ sd.setId("sd object \"2\"");
+ sd.getItem().add("Item 2.1");
+ sd.getItem().add("Item 2.2");
+ ld.getSampleData().add(sd);
+ ld.setFluff("MyFluff");
+
+ JAXBmar jaxBmar = new JAXBmar(LargerData.class);
+ //jaxBmar.asFragment(true);
+ //jaxBmar.pretty(true);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
- Trans trans;
- Report report = new Report(ITERATIONS,"XML");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- TimeTaken tt = trans.start("JAXB", Env.XML);
- try {
- jaxBmar.marshal(LogTarget.NULL, ld, sbw);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.XML);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
+ Trans trans;
+ Report report = new Report(ITERATIONS,"XML");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ TimeTaken tt = trans.start("JAXB", Env.XML);
+ try {
+ jaxBmar.marshal(LogTarget.NULL, ld, sbw);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.XML);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
- @Test
- public void jaxbObj2PrettyXML() throws Exception {
- System.out.println("*** JAXB Object -> Pretty XML ***");
+ @Test
+ public void jaxbObj2PrettyXML() throws Exception {
+ System.out.println("*** JAXB Object -> Pretty XML ***");
- LargerData ld = new LargerData();
- SampleData sd = new SampleData();
- sd.setDate(System.currentTimeMillis());
- sd.setId("sd object \"1\"");
- sd.getItem().add("Item 1.1");
- sd.getItem().add("Item 1.2");
- ld.getSampleData().add(sd);
- sd = new SampleData();
- sd.setDate(System.currentTimeMillis());
- sd.setId("sd object \"2\"");
- sd.getItem().add("Item 2.1");
- sd.getItem().add("Item 2.2");
- ld.getSampleData().add(sd);
- ld.setFluff("MyFluff");
-
- JAXBmar jaxBmar = new JAXBmar(LargerData.class);
- //jaxBmar.asFragment(true);
- jaxBmar.pretty(true);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ LargerData ld = new LargerData();
+ SampleData sd = new SampleData();
+ sd.setDate(System.currentTimeMillis());
+ sd.setId("sd object \"1\"");
+ sd.getItem().add("Item 1.1");
+ sd.getItem().add("Item 1.2");
+ ld.getSampleData().add(sd);
+ sd = new SampleData();
+ sd.setDate(System.currentTimeMillis());
+ sd.setId("sd object \"2\"");
+ sd.getItem().add("Item 2.1");
+ sd.getItem().add("Item 2.2");
+ ld.getSampleData().add(sd);
+ ld.setFluff("MyFluff");
+
+ JAXBmar jaxBmar = new JAXBmar(LargerData.class);
+ //jaxBmar.asFragment(true);
+ jaxBmar.pretty(true);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
- Trans trans;
- Report report = new Report(ITERATIONS,"XML");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- TimeTaken tt = trans.start("JAXB", Env.XML);
- try {
- jaxBmar.marshal(LogTarget.NULL, ld, sbw);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.XML);
- } while(report.go());
+ Trans trans;
+ Report report = new Report(ITERATIONS,"XML");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ TimeTaken tt = trans.start("JAXB", Env.XML);
+ try {
+ jaxBmar.marshal(LogTarget.NULL, ld, sbw);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.XML);
+ } while(report.go());
- report.report(sbw);
- System.out.println(sbw.toString());
- }
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java
index 58813621..2a4e3d2d 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java
@@ -43,217 +43,217 @@ import org.onap.aaf.misc.rosetta.OutXML;
import s.xsd.LargerData;
public class JU_FromXML {
- private static int ITERATIONS = 1;
- ;
-
- private final static String xml =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
- "<LargerData xmlns=\"urn:s:xsd\">\n" +
- " <SampleData>\n" +
- " <id>sd object 1</id>\n" +
- " <date>1346765355134</date>\n" +
- " <item>Item 1.1</item>\n" +
- " <item>Item 1.2</item>\n" +
- " </SampleData>\n" +
- " <SampleData>\n" +
- " <id>sd object 2</id>\n" +
- " <date>1346765355134</date>\n" +
- " <item>Item 2.1</item>\n" +
- " <item>Item 2.2</item>\n" +
- " </SampleData>\n" +
- " <fluff>MyFluff</fluff>\n" +
- "</LargerData>\n";
-
-
- @Test
- public void test() throws Exception {
- InXML inXML = new InXML(LargerData.class);
-
- System.out.println(xml);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- Reader rdr = new StringReader(xml);
-
- new OutRaw().extract(rdr, sbw, inXML);
- System.out.println(sbw.getBuffer());
- }
-
+ private static int ITERATIONS = 1;
+ ;
+
+ private final static String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
+ "<LargerData xmlns=\"urn:s:xsd\">\n" +
+ " <SampleData>\n" +
+ " <id>sd object 1</id>\n" +
+ " <date>1346765355134</date>\n" +
+ " <item>Item 1.1</item>\n" +
+ " <item>Item 1.2</item>\n" +
+ " </SampleData>\n" +
+ " <SampleData>\n" +
+ " <id>sd object 2</id>\n" +
+ " <date>1346765355134</date>\n" +
+ " <item>Item 2.1</item>\n" +
+ " <item>Item 2.2</item>\n" +
+ " </SampleData>\n" +
+ " <fluff>MyFluff</fluff>\n" +
+ "</LargerData>\n";
+
+
+ @Test
+ public void test() throws Exception {
+ InXML inXML = new InXML(LargerData.class);
+
+ System.out.println(xml);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ Reader rdr = new StringReader(xml);
+
+ new OutRaw().extract(rdr, sbw, inXML);
+ System.out.println(sbw.getBuffer());
+ }
+
- @Test
- public void xml2JSON() throws Exception {
- System.out.println("*** XML -> JSON (No Warm up) ***");
- Out jout = new OutJson();
- InXML inXML = new InXML(LargerData.class);
+ @Test
+ public void xml2JSON() throws Exception {
+ System.out.println("*** XML -> JSON (No Warm up) ***");
+ Out jout = new OutJson();
+ InXML inXML = new InXML(LargerData.class);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- Trans trans;
- Report report = new Report(ITERATIONS,"XML");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(xml);
- TimeTaken tt = trans.start("Parse XML", Env.XML);
- try {
- jout.extract(sr, sbw, inXML);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.XML);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ Trans trans;
+ Report report = new Report(ITERATIONS,"XML");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(xml);
+ TimeTaken tt = trans.start("Parse XML", Env.XML);
+ try {
+ jout.extract(sr, sbw, inXML);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.XML);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
- @Test
- public void xml2XML() throws Exception {
- System.out.println("*** XML -> (Event Queue) -> XML (No Warm up) ***");
- Out xout = new OutXML("LargerData");
- InXML inXML = new InXML(LargerData.class);
+ @Test
+ public void xml2XML() throws Exception {
+ System.out.println("*** XML -> (Event Queue) -> XML (No Warm up) ***");
+ Out xout = new OutXML("LargerData");
+ InXML inXML = new InXML(LargerData.class);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- Trans trans;
- Report report = new Report(ITERATIONS,"XML");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(xml);
- TimeTaken tt = trans.start("Parse XML", Env.XML);
- try {
- xout.extract(sr, sbw, inXML);
- } finally {
- tt.done();
- }
- report.glean(trans,Env.XML);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
-
-
- @Test
- public void warmup() throws Exception {
- if(ITERATIONS>20) {
- System.out.println("*** Warmup JAXB ***");
-
- JAXBumar jaxbUmar = new JAXBumar(LargerData.class);
- JAXBmar jaxBmar = new JAXBmar(LargerData.class);
- //jaxBmar.asFragment(true);
- //jaxBmar.pretty(true);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ Trans trans;
+ Report report = new Report(ITERATIONS,"XML");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(xml);
+ TimeTaken tt = trans.start("Parse XML", Env.XML);
+ try {
+ xout.extract(sr, sbw, inXML);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,Env.XML);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
+
+
+ @Test
+ public void warmup() throws Exception {
+ if(ITERATIONS>20) {
+ System.out.println("*** Warmup JAXB ***");
+
+ JAXBumar jaxbUmar = new JAXBumar(LargerData.class);
+ JAXBmar jaxBmar = new JAXBmar(LargerData.class);
+ //jaxBmar.asFragment(true);
+ //jaxBmar.pretty(true);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
- LargerData ld;
- Trans trans;
- Report report = new Report(ITERATIONS,"XML");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- TimeTaken all = trans.start("Combo", Env.SUB);
- try {
- TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML);
- try {
- ld = jaxbUmar.unmarshal(LogTarget.NULL, xml);
- } finally {
- tt.done();
- }
- tt = trans.start("JAXB marshal", Env.XML);
- try {
- jaxBmar.marshal(LogTarget.NULL, ld, sbw);
- } finally {
- tt.done();
- }
- } finally {
- all.done();
- }
- report.glean(trans,Env.XML);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
- }
- }
- @Test
- public void xml2jaxb2xml() throws Exception {
- System.out.println("*** XML -> JAXB Object -> XML ***");
- JAXBumar jaxbUmar = new JAXBumar(LargerData.class);
- JAXBmar jaxBmar = new JAXBmar(LargerData.class);
- //jaxBmar.asFragment(true);
- //jaxBmar.pretty(true);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ LargerData ld;
+ Trans trans;
+ Report report = new Report(ITERATIONS,"XML");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ TimeTaken all = trans.start("Combo", Env.SUB);
+ try {
+ TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML);
+ try {
+ ld = jaxbUmar.unmarshal(LogTarget.NULL, xml);
+ } finally {
+ tt.done();
+ }
+ tt = trans.start("JAXB marshal", Env.XML);
+ try {
+ jaxBmar.marshal(LogTarget.NULL, ld, sbw);
+ } finally {
+ tt.done();
+ }
+ } finally {
+ all.done();
+ }
+ report.glean(trans,Env.XML);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
+ }
+ }
+ @Test
+ public void xml2jaxb2xml() throws Exception {
+ System.out.println("*** XML -> JAXB Object -> XML ***");
+ JAXBumar jaxbUmar = new JAXBumar(LargerData.class);
+ JAXBmar jaxBmar = new JAXBmar(LargerData.class);
+ //jaxBmar.asFragment(true);
+ //jaxBmar.pretty(true);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
- LargerData ld;
- Trans trans;
- Report report = new Report(ITERATIONS,"XML");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- TimeTaken all = trans.start("Combo", Env.SUB);
- try {
- TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML);
- try {
- ld = jaxbUmar.unmarshal(LogTarget.NULL, xml);
- } finally {
- tt.done();
- }
- tt = trans.start("JAXB marshal", Env.XML);
- try {
- jaxBmar.marshal(LogTarget.NULL, ld, sbw);
- } finally {
- tt.done();
- }
- } finally {
- all.done();
- }
- report.glean(trans,Env.XML);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString()); }
+ LargerData ld;
+ Trans trans;
+ Report report = new Report(ITERATIONS,"XML");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ TimeTaken all = trans.start("Combo", Env.SUB);
+ try {
+ TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML);
+ try {
+ ld = jaxbUmar.unmarshal(LogTarget.NULL, xml);
+ } finally {
+ tt.done();
+ }
+ tt = trans.start("JAXB marshal", Env.XML);
+ try {
+ jaxBmar.marshal(LogTarget.NULL, ld, sbw);
+ } finally {
+ tt.done();
+ }
+ } finally {
+ all.done();
+ }
+ report.glean(trans,Env.XML);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString()); }
- @Test
- public void xml2jaxb2PrettyXml() throws Exception {
- System.out.println("*** XML -> JAXB Object -> Pretty XML ***");
- JAXBumar jaxbUmar = new JAXBumar(LargerData.class);
- JAXBmar jaxBmar = new JAXBmar(LargerData.class);
- //jaxBmar.asFragment(true);
- jaxBmar.pretty(true);
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ @Test
+ public void xml2jaxb2PrettyXml() throws Exception {
+ System.out.println("*** XML -> JAXB Object -> Pretty XML ***");
+ JAXBumar jaxbUmar = new JAXBumar(LargerData.class);
+ JAXBmar jaxBmar = new JAXBmar(LargerData.class);
+ //jaxBmar.asFragment(true);
+ jaxBmar.pretty(true);
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
- Trans trans = EnvFactory.newTrans();
- LargerData ld;
- for(int i=0;i<ITERATIONS;++i) {
- sbw.reset();
- TimeTaken all = trans.start("Combo", Env.SUB);
- try {
- TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML);
- try {
- ld = jaxbUmar.unmarshal(LogTarget.NULL, xml);
- } finally {
- tt.done();
- }
- tt = trans.start("JAXB marshal", Env.XML);
- try {
- jaxBmar.marshal(LogTarget.NULL, ld, sbw);
- } finally {
- tt.done();
- }
- } finally {
- all.done();
- }
- }
- sbw.append('\n');
- Metric m;
- if(ITERATIONS>20) {
- m = trans.auditTrail(0,null);
- } else {
- m = trans.auditTrail(0, sbw.getBuffer());
- System.out.println(sbw.getBuffer());
- }
- System.out.println(ITERATIONS + " entries, Total Time: " + m.total + "ms, Avg Time: " + m.total/ITERATIONS + "ms");
- }
+ Trans trans = EnvFactory.newTrans();
+ LargerData ld;
+ for(int i=0;i<ITERATIONS;++i) {
+ sbw.reset();
+ TimeTaken all = trans.start("Combo", Env.SUB);
+ try {
+ TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML);
+ try {
+ ld = jaxbUmar.unmarshal(LogTarget.NULL, xml);
+ } finally {
+ tt.done();
+ }
+ tt = trans.start("JAXB marshal", Env.XML);
+ try {
+ jaxBmar.marshal(LogTarget.NULL, ld, sbw);
+ } finally {
+ tt.done();
+ }
+ } finally {
+ all.done();
+ }
+ }
+ sbw.append('\n');
+ Metric m;
+ if(ITERATIONS>20) {
+ m = trans.auditTrail(0,null);
+ } else {
+ m = trans.auditTrail(0, sbw.getBuffer());
+ System.out.println(sbw.getBuffer());
+ }
+ System.out.println(ITERATIONS + " entries, Total Time: " + m.total + "ms, Avg Time: " + m.total/ITERATIONS + "ms");
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java
index 080fc973..9ab06e7c 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java
@@ -38,99 +38,99 @@ import org.onap.aaf.misc.rosetta.ParseException;
public class JU_JSON {
- @Test
- public void test() throws IOException, ParseException {
- InJson jin = new InJson();
- Out jout = new OutJson();
-
- go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}");
-
- go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\"],\"utc\":1360418381310}");
- go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\",\"My Comment 2\"],\"utc\":1360418381310}");
-
- go(jin, jout, "{\"SampleData\":[" +
- "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," +
- "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}"
- );
-
- go(jin, jout, "{\"SampleData\":[{\"date\":1316084945343}],\"fluff\":\"MyFluff\"}");
-
- go(jin, jout, "{\"id\":\"Me,[}[eg[)(:x,\\\" Myself\",\"date\":1353094689100}");
-
- // TODO: Clean out AT&T specific data
- go(jin,jout, "{\"userid\":\"xk3233\",\"timestamp\":1353097388531,\"item\":[{\"tag\":\"color\",\"value\":\"Mauve\"},{\"tag\":\"shirtsize\",\"value\":\"Xtra Large\"}]}");
- //go()
- //"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><vote xmlns=\"urn:poll.att.com\"><userid>xk3233</userid><timestamp>1353082669667</timestamp></vote>");
-
- // 3/11/2015 Jonathan found a case with missing comma
- go(jin,jout, "{\"start\":\"2015-03-11T18:18:05.580-05:00\",\"end\":\"2015-09-11-05:00\",\"force\":\"false\",\"perm\":{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myInstance\",\"action\":\"myAction\"}"
- + ",\"role\":\"org.osaaf.myns.myrole\"}");
-
- // 3/12/2015 Jonathan Kurt Schurenberg noticed an issue of object names in an array. This is valid code.
- go(jin,jout, "{\"role\":[{\"name\":\"org.osaaf.myns.myrole\",\"perms\":[{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myOtherAction\"}]}"
- + ",{\"name\":\"org.osaaf.myns.myOtherRole\",\"perms\":[{\"type\":\"org.osaaf.myns.myOtherType\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.myOthertype\",\"instance\":\"myOtherAction\"}]}]}");
-
- // 3/13/2015 - discovered with complex Response
- go(jin,jout, "{\"meth\":\"GET\",\"path\":\"/authz/perms/:type\",\"desc\":\"GetPermsByType\",\"comments\":[\"List All Permissions that match :type listed\"],"
- + "\"contentType\":[\"application/Permissions+json;q=1.0;charset=utf-8;version=1.1,application/json;q=1.0;version=1.1\""
- + ",\"application/Perms+xml;q=1.0;charset=utf-8;version=2.0,text/xml;q=1.0;version=2.0\",\"application/Perms+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0\""
- + ",\"application/Permissions+xml;q=1.0;charset=utf-8;version=1.1,text/xml;q=1.0;version=1.1\"]}");
-
-
- // Test a Windoze "Pretty Print", validate skipping of Windoze characters as well as other odd control characters listed
- // in json.org
- StringWriter sw = new StringWriter();
- jout.extract(new StringReader(
- "{\b\f\n\r\t \"id\""
- + ":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100"
- + "\b\f\n\r\t }"
- ),sw,jin);
- Assert.assertEquals("{\"id\":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100}",sw.toString());
- System.out.println(sw.toString());
-
- // 10/01/2015 Jonathan AAF-703 Ron Gallagher, this response is ok
- go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"something\"}]}");
- // but when description:"" causes extra comma at end
- go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\"}]}");
- // Test other empty string scenarios
- go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"\"}]}","{\"perm\":[{}]}");
- go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"hi\"}]}","{\"perm\":[{\"description\":\"hi\"}]}");
- go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"action\":\"myAction\"}]}");
-
-
- go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":,\"description\":\"something\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"description\":\"something\"}]}");
-
- go(jin, jout, "{\"name\":\"\\\"hello\\\"\"}");
-
- go(jin, jout, "{\"name\":\"\\\\\"}");
-
- go(jin, jout, "{\"role\":\"org.osaaf.scamper.UserStory0152 7_IT-00323-a-admin\",\"perm\":{\"type\":\"org.osaaf.scamper.application\",\"instance\":\"_()`!@#\\\\$%^=+][{}<>/.-valid.app.name-is_good\",\"action\":\"Administrator\"}}");
-
-
- }
-
-
- private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException {
- go(in,out,str,str);
- }
-
-
- private void go(Parse<Reader, ?> in, Out out, String str, String cmp) throws IOException, ParseException {
-
- System.out.println(str);
- StringWriter sw = new StringWriter(1024);
- out.extract(new StringReader(str), sw, in);
- System.out.println(sw);
- String result = sw.toString();
-
- if(!result.equals(cmp)) {
- sw.getBuffer().setLength(0);
- new OutRaw().extract(new StringReader(str), sw, in);
- System.out.println(sw);
- }
-
- Assert.assertEquals(cmp,result);
- System.out.println();
-
- }
+ @Test
+ public void test() throws IOException, ParseException {
+ InJson jin = new InJson();
+ Out jout = new OutJson();
+
+ go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}");
+
+ go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\"],\"utc\":1360418381310}");
+ go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\",\"My Comment 2\"],\"utc\":1360418381310}");
+
+ go(jin, jout, "{\"SampleData\":[" +
+ "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," +
+ "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}"
+ );
+
+ go(jin, jout, "{\"SampleData\":[{\"date\":1316084945343}],\"fluff\":\"MyFluff\"}");
+
+ go(jin, jout, "{\"id\":\"Me,[}[eg[)(:x,\\\" Myself\",\"date\":1353094689100}");
+
+ // TODO: Clean out AT&T specific data
+ go(jin,jout, "{\"userid\":\"xk3233\",\"timestamp\":1353097388531,\"item\":[{\"tag\":\"color\",\"value\":\"Mauve\"},{\"tag\":\"shirtsize\",\"value\":\"Xtra Large\"}]}");
+ //go()
+ //"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><vote xmlns=\"urn:poll.att.com\"><userid>xk3233</userid><timestamp>1353082669667</timestamp></vote>");
+
+ // 3/11/2015 Jonathan found a case with missing comma
+ go(jin,jout, "{\"start\":\"2015-03-11T18:18:05.580-05:00\",\"end\":\"2015-09-11-05:00\",\"force\":\"false\",\"perm\":{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myInstance\",\"action\":\"myAction\"}"
+ + ",\"role\":\"org.osaaf.myns.myrole\"}");
+
+ // 3/12/2015 Jonathan Kurt Schurenberg noticed an issue of object names in an array. This is valid code.
+ go(jin,jout, "{\"role\":[{\"name\":\"org.osaaf.myns.myrole\",\"perms\":[{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myOtherAction\"}]}"
+ + ",{\"name\":\"org.osaaf.myns.myOtherRole\",\"perms\":[{\"type\":\"org.osaaf.myns.myOtherType\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.myOthertype\",\"instance\":\"myOtherAction\"}]}]}");
+
+ // 3/13/2015 - discovered with complex Response
+ go(jin,jout, "{\"meth\":\"GET\",\"path\":\"/authz/perms/:type\",\"desc\":\"GetPermsByType\",\"comments\":[\"List All Permissions that match :type listed\"],"
+ + "\"contentType\":[\"application/Permissions+json;q=1.0;charset=utf-8;version=1.1,application/json;q=1.0;version=1.1\""
+ + ",\"application/Perms+xml;q=1.0;charset=utf-8;version=2.0,text/xml;q=1.0;version=2.0\",\"application/Perms+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0\""
+ + ",\"application/Permissions+xml;q=1.0;charset=utf-8;version=1.1,text/xml;q=1.0;version=1.1\"]}");
+
+
+ // Test a Windoze "Pretty Print", validate skipping of Windoze characters as well as other odd control characters listed
+ // in json.org
+ StringWriter sw = new StringWriter();
+ jout.extract(new StringReader(
+ "{\b\f\n\r\t \"id\""
+ + ":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100"
+ + "\b\f\n\r\t }"
+ ),sw,jin);
+ Assert.assertEquals("{\"id\":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100}",sw.toString());
+ System.out.println(sw.toString());
+
+ // 10/01/2015 Jonathan AAF-703 Ron Gallagher, this response is ok
+ go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"something\"}]}");
+ // but when description:"" causes extra comma at end
+ go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\"}]}");
+ // Test other empty string scenarios
+ go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"\"}]}","{\"perm\":[{}]}");
+ go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"hi\"}]}","{\"perm\":[{\"description\":\"hi\"}]}");
+ go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"action\":\"myAction\"}]}");
+
+
+ go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":,\"description\":\"something\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"description\":\"something\"}]}");
+
+ go(jin, jout, "{\"name\":\"\\\"hello\\\"\"}");
+
+ go(jin, jout, "{\"name\":\"\\\\\"}");
+
+ go(jin, jout, "{\"role\":\"org.osaaf.scamper.UserStory0152 7_IT-00323-a-admin\",\"perm\":{\"type\":\"org.osaaf.scamper.application\",\"instance\":\"_()`!@#\\\\$%^=+][{}<>/.-valid.app.name-is_good\",\"action\":\"Administrator\"}}");
+
+
+ }
+
+
+ private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException {
+ go(in,out,str,str);
+ }
+
+
+ private void go(Parse<Reader, ?> in, Out out, String str, String cmp) throws IOException, ParseException {
+
+ System.out.println(str);
+ StringWriter sw = new StringWriter(1024);
+ out.extract(new StringReader(str), sw, in);
+ System.out.println(sw);
+ String result = sw.toString();
+
+ if(!result.equals(cmp)) {
+ sw.getBuffer().setLength(0);
+ new OutRaw().extract(new StringReader(str), sw, in);
+ System.out.println(sw);
+ }
+
+ Assert.assertEquals(cmp,result);
+ System.out.println();
+
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java
index f72b6e69..229f1bf4 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java
@@ -28,49 +28,49 @@ import static org.junit.Assert.*;
public class JU_Ladder {
- @Test
- public void test() {
- Ladder<String> ladder = new Ladder<String>();
-
- for(int i=0;i<30;++i) {
- for(int j=0;j<i;++j)ladder.ascend();
- String str = "Rung " + i;
- assertEquals(ladder.peek(),null);
- ladder.push(str);
- assertEquals(str,ladder.peek());
- assertEquals(str,ladder.pop());
- assertEquals(null,ladder.peek());
- for(int j=0;j<i;++j)ladder.descend();
- }
- assertEquals(ladder.height(),32); // Sizing, when naturally created is by 8
-
- ladder.cutTo(8);
- assertEquals(ladder.height(),8);
-
- for(int i=0;i<30;++i) {
- ladder.jumpTo(i);
- String str = "Rung " + i;
- assertEquals(ladder.peek(),null);
- ladder.push(str);
- assertEquals(ladder.peek(),str);
- }
+ @Test
+ public void test() {
+ Ladder<String> ladder = new Ladder<String>();
+
+ for(int i=0;i<30;++i) {
+ for(int j=0;j<i;++j)ladder.ascend();
+ String str = "Rung " + i;
+ assertEquals(ladder.peek(),null);
+ ladder.push(str);
+ assertEquals(str,ladder.peek());
+ assertEquals(str,ladder.pop());
+ assertEquals(null,ladder.peek());
+ for(int j=0;j<i;++j)ladder.descend();
+ }
+ assertEquals(ladder.height(),32); // Sizing, when naturally created is by 8
+
+ ladder.cutTo(8);
+ assertEquals(ladder.height(),8);
+
+ for(int i=0;i<30;++i) {
+ ladder.jumpTo(i);
+ String str = "Rung " + i;
+ assertEquals(ladder.peek(),null);
+ ladder.push(str);
+ assertEquals(ladder.peek(),str);
+ }
- ladder.bottom();
-
- for(int i=0;i<30;++i) {
- assertEquals("Rung " + i,ladder.peek());
- ladder.ascend();
- }
-
- ladder.bottom();
- ladder.top();
- assertEquals("Rung 29",ladder.peek());
-
- for(int i=0;i<30;++i) {
- ladder.jumpTo(i);
- assertEquals("Rung " + i,ladder.peek());
- }
+ ladder.bottom();
+
+ for(int i=0;i<30;++i) {
+ assertEquals("Rung " + i,ladder.peek());
+ ladder.ascend();
+ }
+
+ ladder.bottom();
+ ladder.top();
+ assertEquals("Rung 29",ladder.peek());
+
+ for(int i=0;i<30;++i) {
+ ladder.jumpTo(i);
+ assertEquals("Rung " + i,ladder.peek());
+ }
- }
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java
index cff5b43a..a1e94c51 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java
@@ -35,36 +35,36 @@ import s.xsd.SampleData;
public class JU_Nulls {
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
- @Test
- public void test() {
- RosettaEnv env = new RosettaEnv();
- try {
- RosettaDF<LargerData> df = env.newDataFactory(LargerData.class);
- df.out(Data.TYPE.JSON);
- LargerData urr = new LargerData();
- SampleData sd = new SampleData();
- sd.setDate(1444125487798L);
- sd.setId(null);
- urr.getSampleData().add(sd);
- urr.setFluff(null);
- RosettaData<LargerData> data = df.newData();
-// StringWriter sw = new StringWriter();
-// df.direct(trans, urr, sw);
-// System.out.println(sw.toString());
- data.load(urr);
- System.out.println(data.asString());
- Assert.assertEquals("{\"SampleData\":[{\"date\":1444125487798}]}", data.asString());
-
- System.out.println(data.out(Data.TYPE.RAW).asString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
+ @Test
+ public void test() {
+ RosettaEnv env = new RosettaEnv();
+ try {
+ RosettaDF<LargerData> df = env.newDataFactory(LargerData.class);
+ df.out(Data.TYPE.JSON);
+ LargerData urr = new LargerData();
+ SampleData sd = new SampleData();
+ sd.setDate(1444125487798L);
+ sd.setId(null);
+ urr.getSampleData().add(sd);
+ urr.setFluff(null);
+ RosettaData<LargerData> data = df.newData();
+// StringWriter sw = new StringWriter();
+// df.direct(trans, urr, sw);
+// System.out.println(sw.toString());
+ data.load(urr);
+ System.out.println(data.asString());
+ Assert.assertEquals("{\"SampleData\":[{\"date\":1444125487798}]}", data.asString());
+
+ System.out.println(data.out(Data.TYPE.RAW).asString());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java
index 07c73196..1a5f86f3 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java
@@ -41,122 +41,122 @@ import s.xsd.Multi;
import s.xsd.SampleData;
public class JU_RosettaDF {
- public static int ITERATIONS = 1;
-
- @Test
- public void testCached() throws Exception {
- RosettaEnv env = new RosettaEnv();
- RosettaDF<LargerData> df = env.newDataFactory(LargerData.class);
- JAXBmar jmar = new JAXBmar(LargerData.class);
-
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
- Trans trans = EnvFactory.newTrans();
-
- Report report = new Report(ITERATIONS,"Load JSON","Extract JAXB", "JAXB Marshal", "Cached to XML", "Cached to JSON");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Data<LargerData> data;
- TimeTaken tt = trans.start("Load JSON", 1);
- try {
- data = df.newData(trans).out(Data.TYPE.JSON).in(Data.TYPE.JSON).load(JU_FromJSON.str);
- } finally {
- tt.done();
- }
- LargerData ld;
- tt = trans.start("Extract JAXB", 2);
- try {
- ld = data.asObject();
- } finally {
- tt.done();
- }
-
- tt = trans.start("JAXB marshal", 3);
- try {
- jmar.marshal(trans.debug(), ld, sbw);
- } finally {
- tt.done();
- }
- sbw.append('\n');
-
- tt = trans.start("To XML from Cache",4);
- try {
- data.out(Data.TYPE.XML).to(sbw);
- } finally {
- tt.done();
- }
-
- sbw.append('\n');
-
- tt = trans.start("To JSON from Cache",5);
- try {
- data.out(Data.TYPE.JSON).to(sbw);
- } finally {
- tt.done();
- }
- report.glean(trans, 1,2,3,4,5);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw);
-
- }
-
- @Test
- public void testDirect() throws Exception {
- RosettaEnv env = new RosettaEnv();
- RosettaDF<LargerData> df = env.newDataFactory(LargerData.class);
-
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
- Trans trans = EnvFactory.newTrans();
-
- Report report = new Report(ITERATIONS);
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- RosettaData<?> data = df.newData(trans).in(Data.TYPE.JSON).out(Data.TYPE.XML);
- data.direct(new StringReader(JU_FromJSON.str), sbw);
- report.glean(trans);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw);
-
- }
-
- @Test
- public void testMulti() throws Exception {
- RosettaEnv env = new RosettaEnv();
- RosettaDF<Multi> df = env.newDataFactory(Multi.class);
-
-// StringBuilderWriter sbw = new StringBuilderWriter(1024);
-// Trans trans = EnvFactory.newTrans();
-
- Multi m = new Multi();
- m.getF1().add("String1");
- m.getF2().add("String2");
-
- System.out.println(df.newData().load(m).out(TYPE.RAW).asString());
- System.out.println(df.newData().load(m).out(TYPE.JSON).asString());
-
- }
-
- @Test
- public void testQuotes() throws Exception {
- RosettaEnv env = new RosettaEnv();
- RosettaDF<SampleData> df = env.newDataFactory(SampleData.class);
-
- SampleData sd = new SampleData();
- sd.setId("\"AT&T Services, Inc.\"");
- System.out.println(sd.getId());
- String out =df.newData().load(sd).out(TYPE.JSON).asString();
- System.out.println(out);
- Assert.assertEquals(
- "{\"id\":\"\\\"AT&T Services, Inc.\\\"\",\"date\":0}",
- out);
-
- SampleData sd2 = df.newData().in(TYPE.JSON).load(out).asObject();
- System.out.println(sd2.getId());
- Assert.assertEquals(sd.getId(),sd2.getId());
- }
+ public static int ITERATIONS = 1;
+
+ @Test
+ public void testCached() throws Exception {
+ RosettaEnv env = new RosettaEnv();
+ RosettaDF<LargerData> df = env.newDataFactory(LargerData.class);
+ JAXBmar jmar = new JAXBmar(LargerData.class);
+
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ Trans trans = EnvFactory.newTrans();
+
+ Report report = new Report(ITERATIONS,"Load JSON","Extract JAXB", "JAXB Marshal", "Cached to XML", "Cached to JSON");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Data<LargerData> data;
+ TimeTaken tt = trans.start("Load JSON", 1);
+ try {
+ data = df.newData(trans).out(Data.TYPE.JSON).in(Data.TYPE.JSON).load(JU_FromJSON.str);
+ } finally {
+ tt.done();
+ }
+ LargerData ld;
+ tt = trans.start("Extract JAXB", 2);
+ try {
+ ld = data.asObject();
+ } finally {
+ tt.done();
+ }
+
+ tt = trans.start("JAXB marshal", 3);
+ try {
+ jmar.marshal(trans.debug(), ld, sbw);
+ } finally {
+ tt.done();
+ }
+ sbw.append('\n');
+
+ tt = trans.start("To XML from Cache",4);
+ try {
+ data.out(Data.TYPE.XML).to(sbw);
+ } finally {
+ tt.done();
+ }
+
+ sbw.append('\n');
+
+ tt = trans.start("To JSON from Cache",5);
+ try {
+ data.out(Data.TYPE.JSON).to(sbw);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans, 1,2,3,4,5);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw);
+
+ }
+
+ @Test
+ public void testDirect() throws Exception {
+ RosettaEnv env = new RosettaEnv();
+ RosettaDF<LargerData> df = env.newDataFactory(LargerData.class);
+
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+ Trans trans = EnvFactory.newTrans();
+
+ Report report = new Report(ITERATIONS);
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ RosettaData<?> data = df.newData(trans).in(Data.TYPE.JSON).out(Data.TYPE.XML);
+ data.direct(new StringReader(JU_FromJSON.str), sbw);
+ report.glean(trans);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw);
+
+ }
+
+ @Test
+ public void testMulti() throws Exception {
+ RosettaEnv env = new RosettaEnv();
+ RosettaDF<Multi> df = env.newDataFactory(Multi.class);
+
+// StringBuilderWriter sbw = new StringBuilderWriter(1024);
+// Trans trans = EnvFactory.newTrans();
+
+ Multi m = new Multi();
+ m.getF1().add("String1");
+ m.getF2().add("String2");
+
+ System.out.println(df.newData().load(m).out(TYPE.RAW).asString());
+ System.out.println(df.newData().load(m).out(TYPE.JSON).asString());
+
+ }
+
+ @Test
+ public void testQuotes() throws Exception {
+ RosettaEnv env = new RosettaEnv();
+ RosettaDF<SampleData> df = env.newDataFactory(SampleData.class);
+
+ SampleData sd = new SampleData();
+ sd.setId("\"AT&T Services, Inc.\"");
+ System.out.println(sd.getId());
+ String out =df.newData().load(sd).out(TYPE.JSON).asString();
+ System.out.println(out);
+ Assert.assertEquals(
+ "{\"id\":\"\\\"AT&T Services, Inc.\\\"\",\"date\":0}",
+ out);
+
+ SampleData sd2 = df.newData().in(TYPE.JSON).load(out).asObject();
+ System.out.println(sd2.getId());
+ Assert.assertEquals(sd.getId(),sd2.getId());
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java
index 47953007..de1b5500 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java
@@ -38,67 +38,67 @@ import org.onap.aaf.misc.rosetta.Saved;
import s.xsd.LargerData;
public class JU_Saved<b> {
- private static int ITERATIONS = 100000;
+ private static int ITERATIONS = 100000;
- @Test
- public void test() throws Exception {
- InJson inJSON = new InJson();
- OutDump dump = new OutDump();
- JaxInfo ji = JaxInfo.build(LargerData.class);
- OutXML xml = new OutXML(ji);;
- OutJson json = new OutJson();
-
- Saved saved = new Saved();
-
- StringBuilderWriter sbw = new StringBuilderWriter(1024);
-
- Trans trans;
- Report report = new Report(ITERATIONS,"Save","Dump","XML ","JSON");
- do {
- sbw.reset();
- trans = EnvFactory.newTrans();
- Reader sr = new StringReader(JU_FromJSON.str);
- TimeTaken tt = trans.start("Parse Text, and Save", 1);
- try {
- saved.load(sr, inJSON);
- } finally {
- tt.done();
- }
+ @Test
+ public void test() throws Exception {
+ InJson inJSON = new InJson();
+ OutDump dump = new OutDump();
+ JaxInfo ji = JaxInfo.build(LargerData.class);
+ OutXML xml = new OutXML(ji);;
+ OutJson json = new OutJson();
+
+ Saved saved = new Saved();
+
+ StringBuilderWriter sbw = new StringBuilderWriter(1024);
+
+ Trans trans;
+ Report report = new Report(ITERATIONS,"Save","Dump","XML ","JSON");
+ do {
+ sbw.reset();
+ trans = EnvFactory.newTrans();
+ Reader sr = new StringReader(JU_FromJSON.str);
+ TimeTaken tt = trans.start("Parse Text, and Save", 1);
+ try {
+ saved.load(sr, inJSON);
+ } finally {
+ tt.done();
+ }
-// sbw.append("==== Start Direct Raw =====\n");
-// new OutRaw().extract(new StringReader(JU_FromJSON.str), sbw, inJSON);
-//
-// sbw.append("==== Start Raw from Saved =====\n");
-// new OutRaw().extract(null,sbw,saved);
+// sbw.append("==== Start Direct Raw =====\n");
+// new OutRaw().extract(new StringReader(JU_FromJSON.str), sbw, inJSON);
+//
+// sbw.append("==== Start Raw from Saved =====\n");
+// new OutRaw().extract(null,sbw,saved);
- sbw.append("==== Start Dump from Saved =====\n");
- tt = trans.start("Dump", 2);
- try {
- dump.extract(null,sbw,saved);
- } finally {
- tt.done();
- }
-
- sbw.append("\n==== Start XML =====\n");
- tt = trans.start("XML", 3);
- try {
- xml.extract(null,sbw,saved);
- } finally {
- tt.done();
- }
-
- sbw.append("\n==== Start JSON =====\n");
- tt = trans.start("JSON", 4);
- try {
- json.extract(null,sbw,saved);
- } finally {
- tt.done();
- }
- report.glean(trans,1,2,3,4);
- } while(report.go());
-
- report.report(sbw);
- System.out.println(sbw.toString());
+ sbw.append("==== Start Dump from Saved =====\n");
+ tt = trans.start("Dump", 2);
+ try {
+ dump.extract(null,sbw,saved);
+ } finally {
+ tt.done();
+ }
+
+ sbw.append("\n==== Start XML =====\n");
+ tt = trans.start("XML", 3);
+ try {
+ xml.extract(null,sbw,saved);
+ } finally {
+ tt.done();
+ }
+
+ sbw.append("\n==== Start JSON =====\n");
+ tt = trans.start("JSON", 4);
+ try {
+ json.extract(null,sbw,saved);
+ } finally {
+ tt.done();
+ }
+ report.glean(trans,1,2,3,4);
+ } while(report.go());
+
+ report.report(sbw);
+ System.out.println(sbw.toString());
- }
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java
index 6047c03c..b0fc29a2 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java
@@ -46,78 +46,78 @@ import org.onap.aaf.misc.rosetta.ParseException;
public class JU_Stream2Obj {
- /*
- <?xml version="1.0" encoding=Config.UTF-8 standalone="yes"?>
- <root xmlns="urn:inherit">
- <base xsi:type="derivedA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <name>myDerivedA_1</name>
- <num>1432</num>
- <shortName>mda_1</shortName>
- <value>value_1</value>
- <value>value_2</value>
- </base>
- </root>
-
- {"base":[{"__extension":"derivedA","name":"myDerivedA_1","num":1432,"shortName":"mda_1","value":["value_1","value_2"]}]}
- */
-
- @Test
- public void json2Obj() throws APIException, SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException, IOException {
- DerivedA da = new DerivedA();
- da.setName("myDerivedA_1");
- da.setNum((short)1432);
- da.setShortName("mda_1");
- da.getValue().add("value_1");
- da.getValue().add("value_2");
-
- Root root = new Root();
- root.getBase().add(da);
-
- da = new DerivedA();
- da.setName("myDerivedA_2");
- da.setNum((short)1432);
- da.setShortName("mda_2");
- da.getValue().add("value_2.1");
- da.getValue().add("value_2.2");
- root.getBase().add(da);
-
- EnvJAXB env = new BasicEnv();
- DataFactory<Root> rootDF = env.newDataFactory(Root.class);
-
- String xml = rootDF.newData(env).out(Data.TYPE.XML).load(root).option(Data.PRETTY).asString();
- System.out.println(xml);
-
- InXML inXML;
- Parse<Reader,?> in = inXML = new InXML(Root.class);
- Out out = new OutRaw();
-
- StringWriter sw = new StringWriter();
- out.extract(new StringReader(xml), sw, in);
- System.out.println(sw.toString());
-
-
- out = new OutJson();
-
- sw = new StringWriter();
- out.extract(new StringReader(xml), sw, in);
- String json;
- System.out.println(json = sw.toString());
-
- in = new InJson();
- out = new OutRaw();
-
- sw = new StringWriter();
- out.extract(new StringReader(json), sw, in);
- System.out.println(sw.toString());
-
- out = new OutXML(inXML);
-
- sw = new StringWriter();
- out.extract(new StringReader(json), sw, in, true);
- System.out.println(sw.toString());
-
- System.out.flush();
-
- }
+ /*
+ <?xml version="1.0" encoding=Config.UTF-8 standalone="yes"?>
+ <root xmlns="urn:inherit">
+ <base xsi:type="derivedA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <name>myDerivedA_1</name>
+ <num>1432</num>
+ <shortName>mda_1</shortName>
+ <value>value_1</value>
+ <value>value_2</value>
+ </base>
+ </root>
+
+ {"base":[{"__extension":"derivedA","name":"myDerivedA_1","num":1432,"shortName":"mda_1","value":["value_1","value_2"]}]}
+ */
+
+ @Test
+ public void json2Obj() throws APIException, SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException, IOException {
+ DerivedA da = new DerivedA();
+ da.setName("myDerivedA_1");
+ da.setNum((short)1432);
+ da.setShortName("mda_1");
+ da.getValue().add("value_1");
+ da.getValue().add("value_2");
+
+ Root root = new Root();
+ root.getBase().add(da);
+
+ da = new DerivedA();
+ da.setName("myDerivedA_2");
+ da.setNum((short)1432);
+ da.setShortName("mda_2");
+ da.getValue().add("value_2.1");
+ da.getValue().add("value_2.2");
+ root.getBase().add(da);
+
+ EnvJAXB env = new BasicEnv();
+ DataFactory<Root> rootDF = env.newDataFactory(Root.class);
+
+ String xml = rootDF.newData(env).out(Data.TYPE.XML).load(root).option(Data.PRETTY).asString();
+ System.out.println(xml);
+
+ InXML inXML;
+ Parse<Reader,?> in = inXML = new InXML(Root.class);
+ Out out = new OutRaw();
+
+ StringWriter sw = new StringWriter();
+ out.extract(new StringReader(xml), sw, in);
+ System.out.println(sw.toString());
+
+
+ out = new OutJson();
+
+ sw = new StringWriter();
+ out.extract(new StringReader(xml), sw, in);
+ String json;
+ System.out.println(json = sw.toString());
+
+ in = new InJson();
+ out = new OutRaw();
+
+ sw = new StringWriter();
+ out.extract(new StringReader(json), sw, in);
+ System.out.println(sw.toString());
+
+ out = new OutXML(inXML);
+
+ sw = new StringWriter();
+ out.extract(new StringReader(json), sw, in, true);
+ System.out.println(sw.toString());
+
+ System.out.flush();
+
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java
index 1209e77d..7e767e5d 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java
@@ -27,47 +27,47 @@ import org.onap.aaf.misc.rosetta.JaxInfo;
import s.xsd.LargerData;
public class JU_Struct {
- public final static String XML ="<LargerData xmlns=\"urn:s:xsd\">\n" +
- "<SampleData>\n" +
- "<id>sd object 1</id>\n" +
- "<date>1346439215932</date>\n" +
- "<item>Item 1.1</item>\n" +
- "<item>Item 1.2</item>\n" +
- "</SampleData>\n" +
- "<SampleData>\n" +
- "<id>sd object 2</id>\n" +
- "<date>1346439215932</date>\n" +
- "<item>Item 2.1</item>\n" +
- "<item>Item 2.2</item>\n" +
- "</SampleData>\n" +
- "<fluff>MyFluff</fluff>\n" +
- "</LargerData>\n";
-
-// @Test
-// public void test2() throws Exception {
+ public final static String XML ="<LargerData xmlns=\"urn:s:xsd\">\n" +
+ "<SampleData>\n" +
+ "<id>sd object 1</id>\n" +
+ "<date>1346439215932</date>\n" +
+ "<item>Item 1.1</item>\n" +
+ "<item>Item 1.2</item>\n" +
+ "</SampleData>\n" +
+ "<SampleData>\n" +
+ "<id>sd object 2</id>\n" +
+ "<date>1346439215932</date>\n" +
+ "<item>Item 2.1</item>\n" +
+ "<item>Item 2.2</item>\n" +
+ "</SampleData>\n" +
+ "<fluff>MyFluff</fluff>\n" +
+ "</LargerData>\n";
+
+// @Test
+// public void test2() throws Exception {
//
-// SampleData sd = new SampleData();
-// sd.setDate(new Date().getTime());
-// sd.setId("myId");
-// sd.getItem().add("Item 1.1");
-//
-// InObj<SampleData> inObj = new InObj<SampleData>(SampleData.class);
+// SampleData sd = new SampleData();
+// sd.setDate(new Date().getTime());
+// sd.setId("myId");
+// sd.getItem().add("Item 1.1");
+//
+// InObj<SampleData> inObj = new InObj<SampleData>(SampleData.class);
//
-// JaxSet<SampleData> jaxSet = JaxSet.get(SampleData.class);
-// Setter<SampleData> setter = jaxSet.setter("id");
-// setter.set(sd, "Your ID");
-//
-// for(Entry<String, Getter<SampleData>> es : jaxSet.getters()) {
-// System.out.print(es.getKey());
-// System.out.print(' ');
-// System.out.println(es.getValue().get(sd));
-// }
-// }
-
- @Test
- public void test() throws Exception {
- JaxInfo ji = JaxInfo.build(LargerData.class);
- System.out.println(ji);
- }
+// JaxSet<SampleData> jaxSet = JaxSet.get(SampleData.class);
+// Setter<SampleData> setter = jaxSet.setter("id");
+// setter.set(sd, "Your ID");
+//
+// for(Entry<String, Getter<SampleData>> es : jaxSet.getters()) {
+// System.out.print(es.getKey());
+// System.out.print(' ');
+// System.out.println(es.getValue().get(sd));
+// }
+// }
+
+ @Test
+ public void test() throws Exception {
+ JaxInfo ji = JaxInfo.build(LargerData.class);
+ System.out.println(ji);
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java
index 5d76e3cb..032f9f1c 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java
@@ -51,251 +51,251 @@ import types.xsd.Multi.Single;
public class JU_Types {
- @Test
- public void single() throws Exception {
- Single single = setSData();
- SingleMarshal psingle = new SingleMarshal();
-
- OutRaw raw = new OutRaw();
- OutJson json = new OutJson();
- OutXML xml = new OutXML("Single","xmlns=urn:types:xsd");
-
-
- System.out.println("===== RAW =====");
- raw.extract(single, System.out, psingle);
+ @Test
+ public void single() throws Exception {
+ Single single = setSData();
+ SingleMarshal psingle = new SingleMarshal();
+
+ OutRaw raw = new OutRaw();
+ OutJson json = new OutJson();
+ OutXML xml = new OutXML("Single","xmlns=urn:types:xsd");
+
+
+ System.out.println("===== RAW =====");
+ raw.extract(single, System.out, psingle);
- System.out.println("\n===== JSON =====");
- json.extract(single, System.out, psingle);
-
- System.out.println("\n\n===== Pretty JSON =====");
- json.extract(single, System.out, psingle, true);
+ System.out.println("\n===== JSON =====");
+ json.extract(single, System.out, psingle);
+
+ System.out.println("\n\n===== Pretty JSON =====");
+ json.extract(single, System.out, psingle, true);
- System.out.println("\n\n===== XML =====");
- xml.extract(single, System.out, psingle,false);
+ System.out.println("\n\n===== XML =====");
+ xml.extract(single, System.out, psingle,false);
- System.out.println("\n\n===== Pretty XML =====");
- xml.extract(single, System.out, psingle, true);
+ System.out.println("\n\n===== Pretty XML =====");
+ xml.extract(single, System.out, psingle, true);
- RosettaEnv env = new RosettaEnv();
- StringWriter sw = new StringWriter();
- xml.extract(single, sw, psingle, true);
- JAXBumar jumar = new JAXBumar(single.getClass());
- JAXBmar jmar = new JAXBmar(new QName("Single","urn.types.xsd"),single.getClass());
- jmar.pretty(true);
- sw = new StringWriter();
- jmar.marshal(env.info(), single, sw);
- System.out.println(sw);
- Single news = jumar.unmarshal(env.info(), sw.toString());
-// System.out.println(news.getDatetime());
-// sw = new StringWriter();
-// news.setDatetime(Chrono.timeStamp());
-// xml.extract(single, sw, psingle, true);
- news = jumar.unmarshal(env.info(), sw.toString());
- System.out.println(sw.toString());
-
- String sample = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
- + "\n<ns2:urn.types.xsd xmlns:ns2=\"Single\" xmlns=\"urn:types:xsd\">"
- + "\n<str>MyString</str>"
- + "\n<int>2147483647</int>"
- + "\n<long>9223372036854775807</long>"
- + "\n<date>2015-05-27-05:00</date>"
- + "\n<datetime>2015-05-27T07:05:04.234-05:00</datetime>"
- + "\n<binary>FF00FF0E082507807F</binary>"
- + "\n<array>String 1</array>"
- + "\n<array>String 2</array>"
- + "\n</ns2:urn.types.xsd>";
- System.out.println(sample);
- news = jumar.unmarshal(env.info(), sample);
+ RosettaEnv env = new RosettaEnv();
+ StringWriter sw = new StringWriter();
+ xml.extract(single, sw, psingle, true);
+ JAXBumar jumar = new JAXBumar(single.getClass());
+ JAXBmar jmar = new JAXBmar(new QName("Single","urn.types.xsd"),single.getClass());
+ jmar.pretty(true);
+ sw = new StringWriter();
+ jmar.marshal(env.info(), single, sw);
+ System.out.println(sw);
+ Single news = jumar.unmarshal(env.info(), sw.toString());
+// System.out.println(news.getDatetime());
+// sw = new StringWriter();
+// news.setDatetime(Chrono.timeStamp());
+// xml.extract(single, sw, psingle, true);
+ news = jumar.unmarshal(env.info(), sw.toString());
+ System.out.println(sw.toString());
+
+ String sample = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ + "\n<ns2:urn.types.xsd xmlns:ns2=\"Single\" xmlns=\"urn:types:xsd\">"
+ + "\n<str>MyString</str>"
+ + "\n<int>2147483647</int>"
+ + "\n<long>9223372036854775807</long>"
+ + "\n<date>2015-05-27-05:00</date>"
+ + "\n<datetime>2015-05-27T07:05:04.234-05:00</datetime>"
+ + "\n<binary>FF00FF0E082507807F</binary>"
+ + "\n<array>String 1</array>"
+ + "\n<array>String 2</array>"
+ + "\n</ns2:urn.types.xsd>";
+ System.out.println(sample);
+ news = jumar.unmarshal(env.info(), sample);
- System.out.println(news.getDatetime());
+ System.out.println(news.getDatetime());
- }
-
- @Test
- public void multi() throws Exception {
- OutRaw raw = new OutRaw();
- OutJson json = new OutJson();
- OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd");
+ }
+
+ @Test
+ public void multi() throws Exception {
+ OutRaw raw = new OutRaw();
+ OutJson json = new OutJson();
+ OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd");
- Multi multi = new Multi();
- MultiMarshal pmulti = new MultiMarshal();
-
- for(int i=0;i<10;++i) {
- System.out.println("===== Multi Iteration " + i + " =====");
- if(i>0) {
- multi.getSingle().add(setSData());
- }
- System.out.println(" ===== RAW =====");
- raw.extract(multi, System.out, pmulti);
-
- System.out.println("\n ===== JSON =====");
- json.extract(multi, System.out, pmulti);
-
- System.out.println("\n\n ===== Pretty JSON =====");
- json.extract(multi, System.out, pmulti, true);
-
- System.out.println("\n\n ===== XML =====");
- xml.extract(multi, System.out, pmulti,false);
-
- System.out.println("\n\n ===== Pretty XML =====");
- xml.extract(multi, System.out, pmulti, true);
- }
- }
+ Multi multi = new Multi();
+ MultiMarshal pmulti = new MultiMarshal();
+
+ for(int i=0;i<10;++i) {
+ System.out.println("===== Multi Iteration " + i + " =====");
+ if(i>0) {
+ multi.getSingle().add(setSData());
+ }
+ System.out.println(" ===== RAW =====");
+ raw.extract(multi, System.out, pmulti);
+
+ System.out.println("\n ===== JSON =====");
+ json.extract(multi, System.out, pmulti);
+
+ System.out.println("\n\n ===== Pretty JSON =====");
+ json.extract(multi, System.out, pmulti, true);
+
+ System.out.println("\n\n ===== XML =====");
+ xml.extract(multi, System.out, pmulti,false);
+
+ System.out.println("\n\n ===== Pretty XML =====");
+ xml.extract(multi, System.out, pmulti, true);
+ }
+ }
- @Test
- public void doc() throws Exception {
- OutRaw raw = new OutRaw();
- OutJson json = new OutJson();
- OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd");
+ @Test
+ public void doc() throws Exception {
+ OutRaw raw = new OutRaw();
+ OutJson json = new OutJson();
+ OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd");
- Multi multi = new Multi();
- DocMarshal<Multi> doc = DocMarshal.root(new MultiMarshal());
-
- for(int i=0;i<3;++i) {
- System.out.println("===== Multi Iteration " + i + " =====");
- if(i>0) {
- multi.getSingle().add(setSData());
- }
- System.out.println(" ===== RAW =====");
- raw.extract(multi, System.out, doc);
-
- System.out.println("\n ===== JSON =====");
- json.extract(multi, System.out, doc);
-
- System.out.println("\n\n ===== Pretty JSON =====");
- json.extract(multi, System.out, doc, true);
-
- System.out.println("\n\n ===== XML =====");
- xml.extract(multi, System.out, doc,false);
-
- System.out.println("\n\n ===== Pretty XML =====");
- xml.extract(multi, System.out, doc, true);
- }
- }
+ Multi multi = new Multi();
+ DocMarshal<Multi> doc = DocMarshal.root(new MultiMarshal());
+
+ for(int i=0;i<3;++i) {
+ System.out.println("===== Multi Iteration " + i + " =====");
+ if(i>0) {
+ multi.getSingle().add(setSData());
+ }
+ System.out.println(" ===== RAW =====");
+ raw.extract(multi, System.out, doc);
+
+ System.out.println("\n ===== JSON =====");
+ json.extract(multi, System.out, doc);
+
+ System.out.println("\n\n ===== Pretty JSON =====");
+ json.extract(multi, System.out, doc, true);
+
+ System.out.println("\n\n ===== XML =====");
+ xml.extract(multi, System.out, doc,false);
+
+ System.out.println("\n\n ===== Pretty XML =====");
+ xml.extract(multi, System.out, doc, true);
+ }
+ }
-// @Test
-// public void saved() throws Exception {
-// Saved saved = new Saved();
-// saved.extract(in, ignore, parser, options);
-// }
-
- @Test
- public void df() throws Exception {
- RosettaEnv env = new RosettaEnv();
- RosettaDF<Multi> df = env.newDataFactory(Multi.class);
- df.out(TYPE.JSON).option(Data.PRETTY);
-
- Multi multi = new Multi();
- multi.getSingle().add(setSData());
-
+// @Test
+// public void saved() throws Exception {
+// Saved saved = new Saved();
+// saved.extract(in, ignore, parser, options);
+// }
+
+ @Test
+ public void df() throws Exception {
+ RosettaEnv env = new RosettaEnv();
+ RosettaDF<Multi> df = env.newDataFactory(Multi.class);
+ df.out(TYPE.JSON).option(Data.PRETTY);
+
+ Multi multi = new Multi();
+ multi.getSingle().add(setSData());
+
- System.out.println("========== Original loading");
- Trans trans = env.newTrans();
- RosettaData<Multi> data = df.newData(trans);
- // Prime pump
- for(int i=0;i<100;++i) {
- data.load(multi);
- }
- trans = env.newTrans();
- data = df.newData(trans);
-
- int iters = 10000;
- for(int i=0;i<iters;++i) {
- data.load(multi);
- }
- Metric metrics = trans.auditTrail(0, null,Env.JSON,Env.XML);
- System.out.println(data.asString());
- System.out.println(metrics.total/iters + "ms avg");
+ System.out.println("========== Original loading");
+ Trans trans = env.newTrans();
+ RosettaData<Multi> data = df.newData(trans);
+ // Prime pump
+ for(int i=0;i<100;++i) {
+ data.load(multi);
+ }
+ trans = env.newTrans();
+ data = df.newData(trans);
+
+ int iters = 10000;
+ for(int i=0;i<iters;++i) {
+ data.load(multi);
+ }
+ Metric metrics = trans.auditTrail(0, null,Env.JSON,Env.XML);
+ System.out.println(data.asString());
+ System.out.println(metrics.total/iters + "ms avg");
- System.out.println("========== New loading");
- // With new
- df.rootMarshal(DocMarshal.root(new MultiMarshal()));
- trans = env.newTrans();
- data = df.newData(trans);
+ System.out.println("========== New loading");
+ // With new
+ df.rootMarshal(DocMarshal.root(new MultiMarshal()));
+ trans = env.newTrans();
+ data = df.newData(trans);
- // Prime pump
- for(int i=0;i<100;++i) {
- data.load(multi);
- }
- trans = env.newTrans();
- data = df.newData(trans);
-
- for(int i=0;i<iters;++i) {
- data.load(multi);
- }
- metrics = trans.auditTrail(0, null,Env.JSON,Env.XML);
- System.out.println(data.asString());
- System.out.println(metrics.total/iters + "ms avg");
-
- // Assert.assertEquals(first, second);
+ // Prime pump
+ for(int i=0;i<100;++i) {
+ data.load(multi);
+ }
+ trans = env.newTrans();
+ data = df.newData(trans);
+
+ for(int i=0;i<iters;++i) {
+ data.load(multi);
+ }
+ metrics = trans.auditTrail(0, null,Env.JSON,Env.XML);
+ System.out.println(data.asString());
+ System.out.println(metrics.total/iters + "ms avg");
+
+ // Assert.assertEquals(first, second);
- System.out.println("========== Direct Object to JSON String");
- trans = env.newTrans();
- data = df.newData(trans);
- StringBuilderWriter sbw = new StringBuilderWriter(256);
- // Prime pump
- for(int i=0;i<100;++i) {
- sbw.reset();
- data.direct(multi, sbw, true);
- }
- trans = env.newTrans();
- data = df.newData(trans);
+ System.out.println("========== Direct Object to JSON String");
+ trans = env.newTrans();
+ data = df.newData(trans);
+ StringBuilderWriter sbw = new StringBuilderWriter(256);
+ // Prime pump
+ for(int i=0;i<100;++i) {
+ sbw.reset();
+ data.direct(multi, sbw, true);
+ }
+ trans = env.newTrans();
+ data = df.newData(trans);
- for(int i=0;i<iters;++i) {
- sbw.reset();
- data.direct(multi, sbw, true);
- }
-
- metrics = trans.auditTrail(0, null,Env.JSON,Env.XML);
- System.out.println(sbw.toString());
- System.out.println(metrics.total/iters + "ms avg");
-
- }
-
- private Single setSData() {
- Single s = new Single();
- s.setStr("MyString");
- s.setInt(Integer.MAX_VALUE);
- s.setLong(Long.MAX_VALUE);
- XMLGregorianCalendar ts = Chrono.timeStamp();
- s.setDate(ts);
- s.setDatetime(ts);
- byte[] bytes= new byte[] {-1,0,(byte)0XFF,0xE,0x8,0x25,0x7,Byte.MIN_VALUE,Byte.MAX_VALUE};
- s.setBinary(bytes);
- s.getArray().add("String 1");
- s.getArray().add("String 2");
- return s;
- }
+ for(int i=0;i<iters;++i) {
+ sbw.reset();
+ data.direct(multi, sbw, true);
+ }
+
+ metrics = trans.auditTrail(0, null,Env.JSON,Env.XML);
+ System.out.println(sbw.toString());
+ System.out.println(metrics.total/iters + "ms avg");
+
+ }
+
+ private Single setSData() {
+ Single s = new Single();
+ s.setStr("MyString");
+ s.setInt(Integer.MAX_VALUE);
+ s.setLong(Long.MAX_VALUE);
+ XMLGregorianCalendar ts = Chrono.timeStamp();
+ s.setDate(ts);
+ s.setDatetime(ts);
+ byte[] bytes= new byte[] {-1,0,(byte)0XFF,0xE,0x8,0x25,0x7,Byte.MIN_VALUE,Byte.MAX_VALUE};
+ s.setBinary(bytes);
+ s.getArray().add("String 1");
+ s.getArray().add("String 2");
+ return s;
+ }
-// @Test
-// public void jsonInOut() throws IOException, ParseException {
-// Parse<?> jin = new InJson();
-// Out jout = new OutJson();
+// @Test
+// public void jsonInOut() throws IOException, ParseException {
+// Parse<?> jin = new InJson();
+// Out jout = new OutJson();
//
-//// go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}");
-//
-// }
-
-
- /*
- private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException {
-
- System.out.println(str);
- StringWriter sw = new StringWriter(1024);
- out.extract(new StringReader(str), sw, in);
- System.out.println(sw);
- String result = sw.toString();
-
- if(!result.equals(str)) {
- sw.getBuffer().setLength(0);
- new OutRaw().extract(new StringReader(str), sw, in);
- System.out.println(sw);
- }
+//// go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}");
+//
+// }
+
+
+ /*
+ private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException {
+
+ System.out.println(str);
+ StringWriter sw = new StringWriter(1024);
+ out.extract(new StringReader(str), sw, in);
+ System.out.println(sw);
+ String result = sw.toString();
+
+ if(!result.equals(str)) {
+ sw.getBuffer().setLength(0);
+ new OutRaw().extract(new StringReader(str), sw, in);
+ System.out.println(sw);
+ }
- Assert.assertEquals(str,result);
- System.out.println();
+ Assert.assertEquals(str,result);
+ System.out.println();
- }
- */
+ }
+ */
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java
index ab0c921a..6ebd07a3 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java
@@ -32,60 +32,60 @@ import org.onap.aaf.misc.rosetta.Parsed;
public class OutDump extends Out{
- @Override
- public<IN, S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException {
- IndentPrintWriter ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer);
+ @Override
+ public<IN, S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException {
+ IndentPrintWriter ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer);
- Parsed<S> p = prs.newParsed();
-
- while((p = prs.parse(in,p.reuse())).valid()) {
- switch(p.event) {
- case Parse.START_OBJ:
- ipw.append("Start Object ");
- ipw.append(p.name);
- ipw.inc();
- break;
- case Parse.END_OBJ:
- printData(ipw,p);
- ipw.dec();
- ipw.append("End Object ");
- ipw.append(p.name);
- break;
- case Parse.START_ARRAY:
- ipw.inc();
- ipw.append("Start Array ");
- ipw.append(p.name);
- ipw.append('\n');
- break;
- case Parse.END_ARRAY:
- printData(ipw,p);
- ipw.dec();
- ipw.append("End Array ");
- ipw.append('\n');
- break;
- case Parse.NEXT:
- printData(ipw,p);
- break;
- }
- }
- }
-
- private void printData(IndentPrintWriter ipw, Parsed<?> parsed) {
- if(parsed.hasData()) {
- ipw.append("Data:[");
- if(parsed.hasName()) {
- ipw.append(parsed.name);
- ipw.append(" : ");
- }
- ipw.append(parsed.sb);
- ipw.append("]");
- ipw.append('\n');
- }
- }
+ Parsed<S> p = prs.newParsed();
+
+ while((p = prs.parse(in,p.reuse())).valid()) {
+ switch(p.event) {
+ case Parse.START_OBJ:
+ ipw.append("Start Object ");
+ ipw.append(p.name);
+ ipw.inc();
+ break;
+ case Parse.END_OBJ:
+ printData(ipw,p);
+ ipw.dec();
+ ipw.append("End Object ");
+ ipw.append(p.name);
+ break;
+ case Parse.START_ARRAY:
+ ipw.inc();
+ ipw.append("Start Array ");
+ ipw.append(p.name);
+ ipw.append('\n');
+ break;
+ case Parse.END_ARRAY:
+ printData(ipw,p);
+ ipw.dec();
+ ipw.append("End Array ");
+ ipw.append('\n');
+ break;
+ case Parse.NEXT:
+ printData(ipw,p);
+ break;
+ }
+ }
+ }
+
+ private void printData(IndentPrintWriter ipw, Parsed<?> parsed) {
+ if(parsed.hasData()) {
+ ipw.append("Data:[");
+ if(parsed.hasName()) {
+ ipw.append(parsed.name);
+ ipw.append(" : ");
+ }
+ ipw.append(parsed.sb);
+ ipw.append("]");
+ ipw.append('\n');
+ }
+ }
- @Override
- public String logName() {
- return "Rosetta OutDump";
- }
+ @Override
+ public String logName() {
+ return "Rosetta OutDump";
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java
index 5c709adc..df4fec07 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java
@@ -28,40 +28,40 @@ import org.onap.aaf.misc.env.Trans;
import org.onap.aaf.misc.env.Trans.Metric;
public class Report {
- float total;
- float buckets[];
- String[] names;
- private int iterations;
- private int count;
-
- public Report(int iters, String ... names) {
- iterations = iters;
- buckets = new float[names.length];
- this.names = names;
- total=0;
- count = 0;
- }
-
- public void glean(Trans trans, int ... type) {
- Metric m = trans.auditTrail(0, null, type);
- total+=m.total;
- int min = Math.min(buckets.length, m.buckets.length);
- for(int b=0;b<min;++b) {
- buckets[b]+=m.buckets[b];
- }
- }
-
- public boolean go() {
- return ++count<iterations;
- }
-
-
- public void report(Writer sbw) throws IOException {
- sbw.append("\n"+count + " entries, Total Time: " + total + "ms, Avg Time: " + total/count + "ms\n");
- int min = Math.min(buckets.length, names.length);
- for(int i=0;i<min;++i) {
- sbw.append(" Time: " + names[i] + ' ' + buckets[i] + "ms, Avg Time: " + buckets[i]/count + "ms\n");
- }
+ float total;
+ float buckets[];
+ String[] names;
+ private int iterations;
+ private int count;
+
+ public Report(int iters, String ... names) {
+ iterations = iters;
+ buckets = new float[names.length];
+ this.names = names;
+ total=0;
+ count = 0;
+ }
+
+ public void glean(Trans trans, int ... type) {
+ Metric m = trans.auditTrail(0, null, type);
+ total+=m.total;
+ int min = Math.min(buckets.length, m.buckets.length);
+ for(int b=0;b<min;++b) {
+ buckets[b]+=m.buckets[b];
+ }
+ }
+
+ public boolean go() {
+ return ++count<iterations;
+ }
+
+
+ public void report(Writer sbw) throws IOException {
+ sbw.append("\n"+count + " entries, Total Time: " + total + "ms, Avg Time: " + total/count + "ms\n");
+ int min = Math.min(buckets.length, names.length);
+ for(int i=0;i<min;++i) {
+ sbw.append(" Time: " + names[i] + ' ' + buckets[i] + "ms, Avg Time: " + buckets[i]/count + "ms\n");
+ }
- }
+ }
}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java
index 5e96a379..b28ca766 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java
@@ -30,12 +30,12 @@ import types.xsd.Multi;
import types.xsd.Multi.Single;
public class MultiMarshal extends ObjMarshal<Multi> {
- public MultiMarshal() {
- add(new ObjArray<Multi,Single>("single",new SingleMarshal()) {
- @Override
- protected List<Single> data(Multi t) {
- return t.getSingle();
- }
- });
- }
+ public MultiMarshal() {
+ add(new ObjArray<Multi,Single>("single",new SingleMarshal()) {
+ @Override
+ protected List<Single> data(Multi t) {
+ return t.getSingle();
+ }
+ });
+ }
} \ No newline at end of file
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java
index 932277de..bde91c9e 100644
--- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java
@@ -37,55 +37,55 @@ import org.onap.aaf.misc.rosetta.marshal.ObjMarshal;
import types.xsd.Multi.Single;
public class SingleMarshal extends ObjMarshal<Single> {
- public SingleMarshal() {
- add(new FieldString<Single>("str") {
- @Override
- protected String data(Single t) {
- return t.getStr();
- }
- });
-
- add(new FieldNumeric<Integer, Single>("int") {
- @Override
- protected Integer data(Single t) {
- return t.getInt();
- }
- });
-
- add(new FieldNumeric<Long,Single>("long") {
- @Override
- protected Long data(Single t) {
- return t.getLong();
- }
- });
+ public SingleMarshal() {
+ add(new FieldString<Single>("str") {
+ @Override
+ protected String data(Single t) {
+ return t.getStr();
+ }
+ });
+
+ add(new FieldNumeric<Integer, Single>("int") {
+ @Override
+ protected Integer data(Single t) {
+ return t.getInt();
+ }
+ });
+
+ add(new FieldNumeric<Long,Single>("long") {
+ @Override
+ protected Long data(Single t) {
+ return t.getLong();
+ }
+ });
- add(new FieldDate<Single>("date") {
- @Override
- protected XMLGregorianCalendar data(Single t) {
- return t.getDate();
- }
- });
+ add(new FieldDate<Single>("date") {
+ @Override
+ protected XMLGregorianCalendar data(Single t) {
+ return t.getDate();
+ }
+ });
- add(new FieldDateTime<Single>("datetime") {
- @Override
- protected XMLGregorianCalendar data(Single t) {
- return t.getDate();
- }
- });
-
- add(new FieldHexBinary<Single>("binary") {
- @Override
- protected byte[] data(Single t) {
- return t.getBinary();
- }
- });
-
- add(new FieldArray<Single,String>("array", DataWriter.STRING) {
- @Override
- protected List<String> data(Single t) {
- return t.getArray();
- }
- });
+ add(new FieldDateTime<Single>("datetime") {
+ @Override
+ protected XMLGregorianCalendar data(Single t) {
+ return t.getDate();
+ }
+ });
+
+ add(new FieldHexBinary<Single>("binary") {
+ @Override
+ protected byte[] data(Single t) {
+ return t.getBinary();
+ }
+ });
+
+ add(new FieldArray<Single,String>("array", DataWriter.STRING) {
+ @Override
+ protected List<String> data(Single t) {
+ return t.getArray();
+ }
+ });
- }
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java
index 342e3ace..5bd24b02 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java
@@ -22,13 +22,13 @@
package org.onap.aaf.misc.xgen;
public class Back {
- public String str;
- public boolean dec;
- public boolean cr;
-
- public Back(String string, boolean decrement, boolean newline) {
- str = string;
- dec = decrement;
- cr = newline;
- }
+ public String str;
+ public boolean dec;
+ public boolean cr;
+
+ public Back(String string, boolean decrement, boolean newline) {
+ str = string;
+ dec = decrement;
+ cr = newline;
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java
index ce90bd13..0f6b0d9c 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java
@@ -23,15 +23,15 @@ package org.onap.aaf.misc.xgen;
public interface Cache<G extends XGen<G>> {
- public void dynamic(G hgen, Code<G> code);
-
- public static class Null<N extends XGen<N>> implements Cache<N> {
- @Override
- public void dynamic(N hgen, Code<N> code) {} // NO_OP, no matter what type
+ public void dynamic(G hgen, Code<G> code);
+
+ public static class Null<N extends XGen<N>> implements Cache<N> {
+ @Override
+ public void dynamic(N hgen, Code<N> code) {} // NO_OP, no matter what type
- @SuppressWarnings("rawtypes")
- private static Null<?> singleton = new Null();
- public static Null<?> singleton() { return singleton;}
- }
+ @SuppressWarnings("rawtypes")
+ private static Null<?> singleton = new Null();
+ public static Null<?> singleton() { return singleton;}
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java
index 417f80b7..3edf8b60 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java
@@ -35,97 +35,97 @@ import org.onap.aaf.misc.xgen.html.Thematic;
public abstract class CacheGen<G extends XGen<G>> {
- public static final int NO_FLAGS = 0x0;
- public final static int PRETTY = 0x1;
- public final static int XML = 0x2;
- public final static int HTML4 = 0x4;
- public final static int HTML5 = 0x8;
+ public static final int NO_FLAGS = 0x0;
+ public final static int PRETTY = 0x1;
+ public final static int XML = 0x2;
+ public final static int HTML4 = 0x4;
+ public final static int HTML5 = 0x8;
-
- private ArrayList<Section<G>> sections = new ArrayList<>();
- private int flags;
- private final Thematic thematic;
+
+ private ArrayList<Section<G>> sections = new ArrayList<>();
+ private int flags;
+ private final Thematic thematic;
- public CacheGen(int flags, Code<G> code) throws APIException, IOException {
- this.flags = flags;
- final XGenBuff<G> buff = new XGenBuff<G>(flags,this);
- // Run to gather Strings and Code Class Segments
- buff.run(new Cache<G>() {
- @Override
- public void dynamic(G hgen, Code<G> code) {
- sections.add(buff.newSection());
- sections.add(new Dynamic(hgen.getIndent(),code));
- }
- },code);
- sections.add(buff.newSection());
-
- // If Code implements thematic, set for later
- thematic = code instanceof Thematic?(Thematic)code:null;
+ public CacheGen(int flags, Code<G> code) throws APIException, IOException {
+ this.flags = flags;
+ final XGenBuff<G> buff = new XGenBuff<G>(flags,this);
+ // Run to gather Strings and Code Class Segments
+ buff.run(new Cache<G>() {
+ @Override
+ public void dynamic(G hgen, Code<G> code) {
+ sections.add(buff.newSection());
+ sections.add(new Dynamic(hgen.getIndent(),code));
+ }
+ },code);
+ sections.add(buff.newSection());
+
+ // If Code implements thematic, set for later
+ thematic = code instanceof Thematic?(Thematic)code:null;
- }
-
- public abstract G create(int htmlStyle, Writer w);
+ }
+
+ public abstract G create(int htmlStyle, Writer w);
- public void replay(State<Env> state, Trans trans, OutputStream os, String theme) throws IOException, APIException {
- replay(state, trans, new OutputStreamWriter(os), theme);
- }
-
- public void replay(State<Env> state, Trans trans,Writer w, String theme) throws IOException, APIException {
- if(thematic!=null) {
- theme = thematic.themeResolve(theme);
- }
- /* Theme
- trans.setTheme(theme);
- int htmlStyle = state.htmlVer(theme);
- */
-
- XGenBuff<G> buff = new XGenBuff<G>(flags,this);
-
- // forward
- int indent = 0;
- Section<G> s;
- int i=0;
- @SuppressWarnings("unchecked")
- Section<G>[] reverse = new Section[sections.size()];
- for(Section<G> section : sections) {
- s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread
- int tempIndent = s.getIndent();
- s.setIndent(indent);
- s.forward(w);
- s.setIndent(tempIndent);
- indent = tempIndent;
- reverse[i++]=s;
- }
+ public void replay(State<Env> state, Trans trans, OutputStream os, String theme) throws IOException, APIException {
+ replay(state, trans, new OutputStreamWriter(os), theme);
+ }
+
+ public void replay(State<Env> state, Trans trans,Writer w, String theme) throws IOException, APIException {
+ if(thematic!=null) {
+ theme = thematic.themeResolve(theme);
+ }
+ /* Theme
+ trans.setTheme(theme);
+ int htmlStyle = state.htmlVer(theme);
+ */
+
+ XGenBuff<G> buff = new XGenBuff<G>(flags,this);
+
+ // forward
+ int indent = 0;
+ Section<G> s;
+ int i=0;
+ @SuppressWarnings("unchecked")
+ Section<G>[] reverse = new Section[sections.size()];
+ for(Section<G> section : sections) {
+ s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread
+ int tempIndent = s.getIndent();
+ s.setIndent(indent);
+ s.forward(w);
+ s.setIndent(tempIndent);
+ indent = tempIndent;
+ reverse[i++]=s;
+ }
- for(--i;i>=0;--i) {
- reverse[i].back(w);
- }
- w.flush();
- }
-
- private class Dynamic extends Section<G> {
- private Code<G> code;
-
- public Dynamic(int indent, Code<G> code) {
- this.code = code;
- this.indent = indent;
- }
+ for(--i;i>=0;--i) {
+ reverse[i].back(w);
+ }
+ w.flush();
+ }
+
+ private class Dynamic extends Section<G> {
+ private Code<G> code;
+
+ public Dynamic(int indent, Code<G> code) {
+ this.code = code;
+ this.indent = indent;
+ }
- @SuppressWarnings("unchecked")
- public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
- // Clone Dynamic to make Thread Safe
- Dynamic d = new Dynamic(indent,code);
- buff.setIndent(indent);
- if(code instanceof DynamicCode) {
- buff.run(state,trans,Cache.Null.singleton(), (DynamicCode<G,?,? extends Trans>)code);
- } else {
- buff.run((Cache<G>)Cache.Null.singleton(), code);
- }
- Section<G> s = buff.newSection();
- d.indent = s.indent;
- d.forward = s.forward;
- d.backward = s.backward;
- return d;
- }
- }
+ @SuppressWarnings("unchecked")
+ public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
+ // Clone Dynamic to make Thread Safe
+ Dynamic d = new Dynamic(indent,code);
+ buff.setIndent(indent);
+ if(code instanceof DynamicCode) {
+ buff.run(state,trans,Cache.Null.singleton(), (DynamicCode<G,?,? extends Trans>)code);
+ } else {
+ buff.run((Cache<G>)Cache.Null.singleton(), code);
+ }
+ Section<G> s = buff.newSection();
+ d.indent = s.indent;
+ d.forward = s.forward;
+ d.backward = s.backward;
+ return d;
+ }
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java
index 68048431..971a56e4 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java
@@ -26,5 +26,5 @@ import java.io.IOException;
import org.onap.aaf.misc.env.APIException;
public interface Code<G extends XGen<G>> {
- public void code(Cache<G> cache, G xgen) throws APIException, IOException;
+ public void code(Cache<G> cache, G xgen) throws APIException, IOException;
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java
index a4194b97..8d4f4eec 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java
@@ -35,10 +35,10 @@ import org.onap.aaf.misc.xgen.html.State;
*
*/
public abstract class DynamicCode<G extends XGen<G>, AS extends State<Env>, TRANS extends Trans> implements Code<G> {
- public abstract void code(final AS state, final TRANS trans, final Cache<G> cache, final G xgen) throws APIException, IOException;
-
- // We expect not to have this section of the code engaged at any time
- public void code(final Cache<G> cache, final G xgen) throws APIException, IOException {
- code(null, null,cache,xgen);
- }
+ public abstract void code(final AS state, final TRANS trans, final Cache<G> cache, final G xgen) throws APIException, IOException;
+
+ // We expect not to have this section of the code engaged at any time
+ public void code(final Cache<G> cache, final G xgen) throws APIException, IOException {
+ code(null, null,cache,xgen);
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java
index 80b0680d..f9c06c40 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java
@@ -22,19 +22,19 @@
package org.onap.aaf.misc.xgen;
public class Mark {
- // package on purpose
- int spot = 0;
- public String comment;
-
- public Mark() {
- comment = null;
- }
-
- public Mark(String string) {
- comment = string;
- }
+ // package on purpose
+ int spot = 0;
+ public String comment;
+
+ public Mark() {
+ comment = null;
+ }
+
+ public Mark(String string) {
+ comment = string;
+ }
- public void spot(int spot) {
- this.spot = spot;
- }
+ public void spot(int spot) {
+ this.spot = spot;
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java
index e73512c3..9f1f2a38 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java
@@ -30,32 +30,32 @@ import org.onap.aaf.misc.env.Trans;
import org.onap.aaf.misc.xgen.html.State;
public class Section<G extends XGen<G>> {
- protected int indent;
- protected String forward;
- protected String backward;
-
- // Default is to use the set Strings (static)
- public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
- return this;
- }
-
- public int getIndent() {
- return indent;
- }
+ protected int indent;
+ protected String forward;
+ protected String backward;
+
+ // Default is to use the set Strings (static)
+ public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
+ return this;
+ }
+
+ public int getIndent() {
+ return indent;
+ }
- public void setIndent(int indent) {
- this.indent = indent;
- }
+ public void setIndent(int indent) {
+ this.indent = indent;
+ }
- public void forward(Writer w) throws IOException {
- w.write(forward);
- }
-
- public void back(Writer w) throws IOException {
- w.write(backward);
- }
-
- public String toString() {
- return forward;
- }
+ public void forward(Writer w) throws IOException {
+ w.write(forward);
+ }
+
+ public void back(Writer w) throws IOException {
+ w.write(backward);
+ }
+
+ public String toString() {
+ return forward;
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java
index 4bb6ee28..7b0a4263 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java
@@ -30,267 +30,267 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter;
public class XGen<RT extends XGen<RT>> {
- private static final int COMMENT_COLUMN = 40;
- private StringBuilder backSB = new StringBuilder();
- private Stack<Back> backStack = new Stack<Back>();
-
- protected XGen(Writer w) {
- forward = new IndentPrintWriter(w);
- }
-
- public int pushBack(Back b) {
- int rv = backStack.size();
- backStack.push(b);
- return rv;
- }
-
- public boolean pretty = false;
- protected IndentPrintWriter forward;
-
- public IndentPrintWriter getWriter() {
- return forward;
- }
-
- protected PrintWriter back = new PrintWriter(
- new StringBuilderWriter(backSB));
-
- @SuppressWarnings("unchecked")
- public RT pretty() {
- pretty = true;
- return (RT) this;
- }
-
- protected void prettyln(PrintWriter pw) {
- if(pretty)pw.println();
- }
-
- public RT leaf(Mark mark, String tag, String ... args) {
- mark.spot = backStack.size();
- return leaf(tag, args);
- }
-
- @SuppressWarnings("unchecked")
- public RT leaf(String tag, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append('>');
- back.append("</");
- back.append(tag);
- back.append('>');
- backStack.push(new Back(backSB.toString(), false, true));
- backSB.setLength(0);
- return (RT)this;
- }
-
- public RT incr(String tag, String ... args) {
- return incr(null, tag, false, args);
- }
-
- public RT incr(String tag, boolean oneLine, String ... args) {
- return incr(null, tag, oneLine, args);
- }
-
- public RT incr(Mark mark) {
- return incr(mark,mark.comment, false, new String[0]);
- }
-
- public RT incr(Mark mark, String tag, String ... attrs) {
- return incr(mark, tag, false, attrs);
- }
-
- @SuppressWarnings("unchecked")
- public RT incr(Mark mark, String tag, boolean oneLine, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append('>');
-
- back.append("</");
- back.append(tag);
- back.append('>');
-
- if(pretty) {
- if(mark!=null && mark.comment!=null) {
- int fi = forward.getIndent()*IndentPrintWriter.INDENT_MULTIPLIER;
- for(int i = fi+backSB.length();i<=COMMENT_COLUMN;++i) {
- back.append(' ');
- }
- back.append("<!-- end ");
- back.append(mark.comment);
- back.append(" -->");
-
- forward.toCol(COMMENT_COLUMN);
- forward.append("<!-- begin ");
- forward.append(mark.comment);
- forward.append(" -->");
- }
- forward.inc();
- if(!oneLine) {
- forward.println();
- }
- back.println();
- }
- if(mark!=null)mark.spot = backStack.size();
- backStack.push(new Back(backSB.toString(),true, false));
- backSB.setLength(0);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT tagOnly(String tag, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append(" />");
- if(pretty) {
- forward.println();
- }
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT text(String txt) {
- forward.append(txt);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT xml(String txt) {
- for(int i=0; i<txt.length();++i) {
- char c = txt.charAt(i);
- switch(c) {
- case '<':
- forward.append("&lt;");
- break;
- case '>':
- forward.append("&gt;");
- break;
- case '&':
- forward.append("&amp;");
- break;
- default:
- forward.append(c);
- }
- }
- return (RT)this;
- }
-
-
- @SuppressWarnings("unchecked")
- public RT textCR(int tabs, String txt) {
- for(int i=0;i<tabs;++i) {
- forward.append(" ");
- }
- forward.append(txt);
- if(pretty)forward.println();
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT value() {
- Mark mark = new Mark();
- mark.spot = backStack.size()-1;
- end(mark);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT value(String txt) {
- forward.append(txt);
- Mark mark = new Mark();
- mark.spot = backStack.size()-1;
- end(mark);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT value(String txt, int levels) {
- forward.append(txt);
- Mark mark = new Mark();
- mark.spot = backStack.size()-levels;
- end(mark);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT end(Mark mark) {
- int size = backStack.size();
- Back c;
- boolean println = false;
- for(int i=mark==null?0:mark.spot;i<size;++i) {
- c = backStack.pop();
- if(c.dec)forward.dec();
- forward.append(c.str);
- println = c.cr;
- }
- if(pretty && println) {
- forward.println();
- }
- return (RT)this;
- }
-
- public RT end() {
- Mark mark = new Mark();
- mark.spot=backStack.size()-1;
- if(mark.spot<0)mark.spot=0;
- return end(mark);
- }
-
- public RT end(int i) {
- Mark mark = new Mark();
- mark.spot=backStack.size()-i;
- if(mark.spot<0)mark.spot=0;
- return end(mark);
- }
-
- public void endAll() {
- end(new Mark());
- forward.flush();
- }
-
- protected void addAttrs(String[] attrs) {
- if(attrs!=null) {
- for(String attr : attrs) {
- if(attr!=null && attr.length()>0) {
- forward.append(' ');
- String[] split = attr.split("=",2);
- switch(split.length) {
- case 0:
- break;
- case 1:
- forward.append(split[0]);
-// forward.append("=\"\"");
- break;
- default:
- forward.append(split[0]);
- forward.append("=\"");
- forward.append(split[1]);
- forward.append('"');
- break;
- }
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public RT comment(String string) {
- if(pretty) {
- forward.print("<!-- ");
- forward.print(string);
- forward.println(" -->");
- }
- return (RT)this;
- }
-
- public void setIndent(int indent) {
- forward.setIndent(indent);
- forward.toIndent();
- }
-
- public int getIndent() {
- return forward.getIndent();
- }
+ private static final int COMMENT_COLUMN = 40;
+ private StringBuilder backSB = new StringBuilder();
+ private Stack<Back> backStack = new Stack<Back>();
+
+ protected XGen(Writer w) {
+ forward = new IndentPrintWriter(w);
+ }
+
+ public int pushBack(Back b) {
+ int rv = backStack.size();
+ backStack.push(b);
+ return rv;
+ }
+
+ public boolean pretty = false;
+ protected IndentPrintWriter forward;
+
+ public IndentPrintWriter getWriter() {
+ return forward;
+ }
+
+ protected PrintWriter back = new PrintWriter(
+ new StringBuilderWriter(backSB));
+
+ @SuppressWarnings("unchecked")
+ public RT pretty() {
+ pretty = true;
+ return (RT) this;
+ }
+
+ protected void prettyln(PrintWriter pw) {
+ if(pretty)pw.println();
+ }
+
+ public RT leaf(Mark mark, String tag, String ... args) {
+ mark.spot = backStack.size();
+ return leaf(tag, args);
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT leaf(String tag, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append('>');
+ back.append("</");
+ back.append(tag);
+ back.append('>');
+ backStack.push(new Back(backSB.toString(), false, true));
+ backSB.setLength(0);
+ return (RT)this;
+ }
+
+ public RT incr(String tag, String ... args) {
+ return incr(null, tag, false, args);
+ }
+
+ public RT incr(String tag, boolean oneLine, String ... args) {
+ return incr(null, tag, oneLine, args);
+ }
+
+ public RT incr(Mark mark) {
+ return incr(mark,mark.comment, false, new String[0]);
+ }
+
+ public RT incr(Mark mark, String tag, String ... attrs) {
+ return incr(mark, tag, false, attrs);
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT incr(Mark mark, String tag, boolean oneLine, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append('>');
+
+ back.append("</");
+ back.append(tag);
+ back.append('>');
+
+ if(pretty) {
+ if(mark!=null && mark.comment!=null) {
+ int fi = forward.getIndent()*IndentPrintWriter.INDENT_MULTIPLIER;
+ for(int i = fi+backSB.length();i<=COMMENT_COLUMN;++i) {
+ back.append(' ');
+ }
+ back.append("<!-- end ");
+ back.append(mark.comment);
+ back.append(" -->");
+
+ forward.toCol(COMMENT_COLUMN);
+ forward.append("<!-- begin ");
+ forward.append(mark.comment);
+ forward.append(" -->");
+ }
+ forward.inc();
+ if(!oneLine) {
+ forward.println();
+ }
+ back.println();
+ }
+ if(mark!=null)mark.spot = backStack.size();
+ backStack.push(new Back(backSB.toString(),true, false));
+ backSB.setLength(0);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT tagOnly(String tag, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append(" />");
+ if(pretty) {
+ forward.println();
+ }
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT text(String txt) {
+ forward.append(txt);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT xml(String txt) {
+ for(int i=0; i<txt.length();++i) {
+ char c = txt.charAt(i);
+ switch(c) {
+ case '<':
+ forward.append("&lt;");
+ break;
+ case '>':
+ forward.append("&gt;");
+ break;
+ case '&':
+ forward.append("&amp;");
+ break;
+ default:
+ forward.append(c);
+ }
+ }
+ return (RT)this;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public RT textCR(int tabs, String txt) {
+ for(int i=0;i<tabs;++i) {
+ forward.append(" ");
+ }
+ forward.append(txt);
+ if(pretty)forward.println();
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT value() {
+ Mark mark = new Mark();
+ mark.spot = backStack.size()-1;
+ end(mark);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT value(String txt) {
+ forward.append(txt);
+ Mark mark = new Mark();
+ mark.spot = backStack.size()-1;
+ end(mark);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT value(String txt, int levels) {
+ forward.append(txt);
+ Mark mark = new Mark();
+ mark.spot = backStack.size()-levels;
+ end(mark);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT end(Mark mark) {
+ int size = backStack.size();
+ Back c;
+ boolean println = false;
+ for(int i=mark==null?0:mark.spot;i<size;++i) {
+ c = backStack.pop();
+ if(c.dec)forward.dec();
+ forward.append(c.str);
+ println = c.cr;
+ }
+ if(pretty && println) {
+ forward.println();
+ }
+ return (RT)this;
+ }
+
+ public RT end() {
+ Mark mark = new Mark();
+ mark.spot=backStack.size()-1;
+ if(mark.spot<0)mark.spot=0;
+ return end(mark);
+ }
+
+ public RT end(int i) {
+ Mark mark = new Mark();
+ mark.spot=backStack.size()-i;
+ if(mark.spot<0)mark.spot=0;
+ return end(mark);
+ }
+
+ public void endAll() {
+ end(new Mark());
+ forward.flush();
+ }
+
+ protected void addAttrs(String[] attrs) {
+ if(attrs!=null) {
+ for(String attr : attrs) {
+ if(attr!=null && attr.length()>0) {
+ forward.append(' ');
+ String[] split = attr.split("=",2);
+ switch(split.length) {
+ case 0:
+ break;
+ case 1:
+ forward.append(split[0]);
+// forward.append("=\"\"");
+ break;
+ default:
+ forward.append(split[0]);
+ forward.append("=\"");
+ forward.append(split[1]);
+ forward.append('"');
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT comment(String string) {
+ if(pretty) {
+ forward.print("<!-- ");
+ forward.print(string);
+ forward.println(" -->");
+ }
+ return (RT)this;
+ }
+
+ public void setIndent(int indent) {
+ forward.setIndent(indent);
+ forward.toIndent();
+ }
+
+ public int getIndent() {
+ return forward.getIndent();
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java
index d2578a34..5f11e4db 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java
@@ -30,57 +30,57 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter;
import org.onap.aaf.misc.xgen.html.State;
public class XGenBuff<G extends XGen<G>> {
- private G xgen;
- private StringBuilder sb;
- // private String forward, backward;
-
- public XGenBuff(int flags, CacheGen<G> cg) {
- sb = new StringBuilder();
- xgen = cg.create(flags, new StringBuilderWriter(sb));
- }
+ private G xgen;
+ private StringBuilder sb;
+ // private String forward, backward;
+
+ public XGenBuff(int flags, CacheGen<G> cg) {
+ sb = new StringBuilder();
+ xgen = cg.create(flags, new StringBuilderWriter(sb));
+ }
- /**
- * Normal case of building up Cached HTML without transaction info
- *
- * @param cache
- * @param code
- * @throws APIException
- * @throws IOException
- */
- public void run(Cache<G> cache, Code<G> code) throws APIException, IOException {
- code.code(cache, xgen);
- }
+ /**
+ * Normal case of building up Cached HTML without transaction info
+ *
+ * @param cache
+ * @param code
+ * @throws APIException
+ * @throws IOException
+ */
+ public void run(Cache<G> cache, Code<G> code) throws APIException, IOException {
+ code.code(cache, xgen);
+ }
- /**
- * Special Case where code is dynamic, so give access to State and Trans info
- *
- * @param state
- * @param trans
- * @param cache
- * @param code
- * @throws APIException
- * @throws IOException
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void run(State<Env> state, Trans trans, Cache cache, DynamicCode code) throws APIException, IOException {
- code.code(state, trans, cache, xgen);
- }
-
- public int getIndent() {
- return xgen.getIndent();
- }
+ /**
+ * Special Case where code is dynamic, so give access to State and Trans info
+ *
+ * @param state
+ * @param trans
+ * @param cache
+ * @param code
+ * @throws APIException
+ * @throws IOException
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void run(State<Env> state, Trans trans, Cache cache, DynamicCode code) throws APIException, IOException {
+ code.code(state, trans, cache, xgen);
+ }
+
+ public int getIndent() {
+ return xgen.getIndent();
+ }
- public void setIndent(int indent) {
- xgen.setIndent(indent);
- }
+ public void setIndent(int indent) {
+ xgen.setIndent(indent);
+ }
- public Section<G> newSection() {
- Section<G> s = new Section<G>();
- s.indent = xgen.getIndent();
- s.forward = sb.toString();
- sb.setLength(0);
- s.backward = sb.toString();
- sb.setLength(0);
- return s;
- }
+ public Section<G> newSection() {
+ Section<G> s = new Section<G>();
+ s.indent = xgen.getIndent();
+ s.forward = sb.toString();
+ sb.setLength(0);
+ s.backward = sb.toString();
+ sb.setLength(0);
+ return s;
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java
index 34d798d5..16ac60ae 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java
@@ -26,118 +26,118 @@ import java.io.Writer;
import org.onap.aaf.misc.xgen.Mark;
public class HTML4Gen extends HTMLGen {
- private final static String DOCTYPE =
- /*
- "<!DOCTYPE HTML PUBLIC " +
- "\"-//W3C//DTD HTML 4.01 Transitional//EN\" " +
- "\"http://www.w3.org/TR/html3/loose.dtd\">";
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" +
- " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
- */
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" +
- " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
+ private final static String DOCTYPE =
+ /*
+ "<!DOCTYPE HTML PUBLIC " +
+ "\"-//W3C//DTD HTML 4.01 Transitional//EN\" " +
+ "\"http://www.w3.org/TR/html3/loose.dtd\">";
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" +
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
+ */
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" +
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- public HTML4Gen(Writer w) {
- super(w);
- }
+ public HTML4Gen(Writer w) {
+ super(w);
+ }
- @Override
- public HTMLGen html(String ... attrib) {
- forward.println(DOCTYPE);
- return incr("html","xmlns=http://www.w3.org/1999/xhtml","xml:lang=en","lang=en");
-
- }
+ @Override
+ public HTMLGen html(String ... attrib) {
+ forward.println(DOCTYPE);
+ return incr("html","xmlns=http://www.w3.org/1999/xhtml","xml:lang=en","lang=en");
+
+ }
- @Override
- public Mark head() {
- Mark head = new Mark("head");
- incr(head);
- return head;
- }
+ @Override
+ public Mark head() {
+ Mark head = new Mark("head");
+ incr(head);
+ return head;
+ }
- @Override
- public Mark body(String ... attrs) {
- Mark body = new Mark("body");
- incr(body,"body",attrs);
- return body;
- }
-
- @Override
- public HTML4Gen charset(String charset) {
- forward.append("<meta http-equiv=\"Content-type\" content=\"text.hml; charset=");
- forward.append(charset);
- forward.append("\">");
- prettyln(forward);
- return this;
- }
+ @Override
+ public Mark body(String ... attrs) {
+ Mark body = new Mark("body");
+ incr(body,"body",attrs);
+ return body;
+ }
+
+ @Override
+ public HTML4Gen charset(String charset) {
+ forward.append("<meta http-equiv=\"Content-type\" content=\"text.hml; charset=");
+ forward.append(charset);
+ forward.append("\">");
+ prettyln(forward);
+ return this;
+ }
- @Override
- public Mark header(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="header";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark header(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="header";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark footer(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="footer";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark footer(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="footer";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark section(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="section";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark section(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="section";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark article(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="attrib";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark article(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="attrib";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark aside(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="aside";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark aside(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="aside";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark nav(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="nav";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark nav(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="nav";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
-// @Override
-// protected void importCSS(Imports imports) {
-// if(imports.css.size()==1) {
-// cssInline(imports.css.get(0));
-// } else {
-// text("<style type=\"text/css\">");
-// prettyln(forward);
-// forward.inc();
-// for(String str : imports.css) {
-// forward.print("@import url(\"");
-// forward.print(imports.themePath(null));
-// forward.print(str);
-// forward.print("\");");
-// prettyln(forward);
-// }
-// forward.dec();
-// forward.print("</style>");
-// prettyln(forward);
-// }
-// }
-
+// @Override
+// protected void importCSS(Imports imports) {
+// if(imports.css.size()==1) {
+// cssInline(imports.css.get(0));
+// } else {
+// text("<style type=\"text/css\">");
+// prettyln(forward);
+// forward.inc();
+// for(String str : imports.css) {
+// forward.print("@import url(\"");
+// forward.print(imports.themePath(null));
+// forward.print(str);
+// forward.print("\");");
+// prettyln(forward);
+// }
+// forward.dec();
+// forward.print("</style>");
+// prettyln(forward);
+// }
+// }
+
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java
index f155a65e..5e4cee7e 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java
@@ -26,130 +26,130 @@ import java.io.Writer;
import org.onap.aaf.misc.xgen.Mark;
public class HTML5Gen extends HTMLGen {
- public HTML5Gen(Writer w) {
- super(w);
- }
-
- @Override
- public HTMLGen html(String ... attrib) {
- //forward.println("<!DOCTYPE html>");
- incr("html",attrib);
- return this;
- }
-
- @Override
- public Mark head() {
- Mark head = new Mark("head");
- incr(head).directive("meta","charset=utf-8");
- return head;
- }
-
- @Override
- public Mark body(String ... attrs) {
- Mark body = new Mark("body");
- incr(body,"body",attrs);
- //chromeFrame();
- return body;
- }
-
- @Override
- public HTML5Gen charset(String charset) {
- forward.append("<meta charset=\"");
- forward.append(charset);
- forward.append("\">");
- prettyln(forward);
- return this;
- }
-
- @Override
- public Mark header(String ... attribs) {
- Mark mark = new Mark("header");
- incr(mark, mark.comment, attribs);
- return mark;
- }
-
- @Override
- public Mark footer(String ... attribs) {
- Mark mark = new Mark("footer");
- incr(mark, mark.comment, attribs);
- return mark;
- }
-
- @Override
- public Mark section(String ... attribs) {
- Mark mark = new Mark("section");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
- @Override
- public Mark article(String ... attribs) {
- Mark mark = new Mark("article");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
- @Override
- public Mark aside(String ... attribs) {
- Mark mark = new Mark("aside");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
- @Override
- public Mark nav(String ... attribs) {
- Mark mark = new Mark("nav");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
-
-// @Override
-// protected void importCSS(Imports imports) {
-// if(imports.css.size() == 1) {
-// cssInline(imports.css.get(0));
-// } else {
-// for(String str : imports.css) {
-// forward.print("<link rel=\"stylesheet\" href=\"");
-// forward.print(imports.themePath(null));
-// forward.print(str);
-// forward.println("\">");
-// }
-// }
-// }
+ public HTML5Gen(Writer w) {
+ super(w);
+ }
+
+ @Override
+ public HTMLGen html(String ... attrib) {
+ //forward.println("<!DOCTYPE html>");
+ incr("html",attrib);
+ return this;
+ }
+
+ @Override
+ public Mark head() {
+ Mark head = new Mark("head");
+ incr(head).directive("meta","charset=utf-8");
+ return head;
+ }
+
+ @Override
+ public Mark body(String ... attrs) {
+ Mark body = new Mark("body");
+ incr(body,"body",attrs);
+ //chromeFrame();
+ return body;
+ }
+
+ @Override
+ public HTML5Gen charset(String charset) {
+ forward.append("<meta charset=\"");
+ forward.append(charset);
+ forward.append("\">");
+ prettyln(forward);
+ return this;
+ }
+
+ @Override
+ public Mark header(String ... attribs) {
+ Mark mark = new Mark("header");
+ incr(mark, mark.comment, attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark footer(String ... attribs) {
+ Mark mark = new Mark("footer");
+ incr(mark, mark.comment, attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark section(String ... attribs) {
+ Mark mark = new Mark("section");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark article(String ... attribs) {
+ Mark mark = new Mark("article");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark aside(String ... attribs) {
+ Mark mark = new Mark("aside");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark nav(String ... attribs) {
+ Mark mark = new Mark("nav");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+
+// @Override
+// protected void importCSS(Imports imports) {
+// if(imports.css.size() == 1) {
+// cssInline(imports.css.get(0));
+// } else {
+// for(String str : imports.css) {
+// forward.print("<link rel=\"stylesheet\" href=\"");
+// forward.print(imports.themePath(null));
+// forward.print(str);
+// forward.println("\">");
+// }
+// }
+// }
//
- /*
- public void chromeFrame() {
- this.textCR(0,"<!--[if IE]>");
- Mark mark = new Mark();
- this.leaf(mark, "script","type=text/javascript","src=http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js")
- .end(mark);
- this.incr(mark, "style")
- .textCR(0,".chromeFrameInstallDefaultStyle {")
- .textCR(1,"width: 100%; /* default is 800px * /")
- .textCR(1,"border: 5px solid blue;")
- .textCR(0,"}")
- .end(mark);
-
- this.incr(mark,"div","id=prompt"); // auto comment would break IE specific Script
- // "if IE without GCF, prompt goes here"
- this.text("Please load this plugin to run ClientSide Websockets")
- .end(mark);
-
- this.incr(mark, "script")
- .textCR(0, "// The conditional ensures that this code will only execute in IE,")
- .textCR(0, "// Therefore we can use the IE-specific attachEvent without worry")
- .textCR(0, "window.attachEvent('onload', function() {")
- .textCR(1,"CFInstall.check({")
- .textCR(2,"mode: 'inline', // the default")
- .textCR(2,"node: 'prompt'")
- .textCR(1, "});")
- .textCR(0, "});")
- .end(mark);
-
- this.textCR(0,"<![endif]-->");
- }
- */
+ /*
+ public void chromeFrame() {
+ this.textCR(0,"<!--[if IE]>");
+ Mark mark = new Mark();
+ this.leaf(mark, "script","type=text/javascript","src=http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js")
+ .end(mark);
+ this.incr(mark, "style")
+ .textCR(0,".chromeFrameInstallDefaultStyle {")
+ .textCR(1,"width: 100%; /* default is 800px * /")
+ .textCR(1,"border: 5px solid blue;")
+ .textCR(0,"}")
+ .end(mark);
+
+ this.incr(mark,"div","id=prompt"); // auto comment would break IE specific Script
+ // "if IE without GCF, prompt goes here"
+ this.text("Please load this plugin to run ClientSide Websockets")
+ .end(mark);
+
+ this.incr(mark, "script")
+ .textCR(0, "// The conditional ensures that this code will only execute in IE,")
+ .textCR(0, "// Therefore we can use the IE-specific attachEvent without worry")
+ .textCR(0, "window.attachEvent('onload', function() {")
+ .textCR(1,"CFInstall.check({")
+ .textCR(2,"mode: 'inline', // the default")
+ .textCR(2,"node: 'prompt'")
+ .textCR(1, "});")
+ .textCR(0, "});")
+ .end(mark);
+
+ this.textCR(0,"<![endif]-->");
+ }
+ */
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java
index 74c5a000..0c94d837 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java
@@ -29,31 +29,31 @@ import org.onap.aaf.misc.xgen.CacheGen;
import org.onap.aaf.misc.xgen.Code;
public class HTMLCacheGen extends CacheGen<HTMLGen> {
- protected int flags;
-
- public HTMLCacheGen(int flags, Code<HTMLGen> code) throws APIException,IOException {
- super(flags, code);
- this.flags = flags;
- }
-
- @Override
- public HTMLGen create(int htmlStyle, Writer w) {
- HTMLGen hg;
- switch(htmlStyle&(CacheGen.HTML4|CacheGen.HTML5)) {
- case CacheGen.HTML4:
- hg = new HTML4Gen(w);
- break;
- case CacheGen.HTML5:
- default:
- hg = new HTML5Gen(w);
- break;
-
- }
- hg.pretty = (htmlStyle&CacheGen.PRETTY)>0;
- return hg;
- }
-
- protected HTMLGen clone(Writer w) {
- return create(flags,w);
- }
+ protected int flags;
+
+ public HTMLCacheGen(int flags, Code<HTMLGen> code) throws APIException,IOException {
+ super(flags, code);
+ this.flags = flags;
+ }
+
+ @Override
+ public HTMLGen create(int htmlStyle, Writer w) {
+ HTMLGen hg;
+ switch(htmlStyle&(CacheGen.HTML4|CacheGen.HTML5)) {
+ case CacheGen.HTML4:
+ hg = new HTML4Gen(w);
+ break;
+ case CacheGen.HTML5:
+ default:
+ hg = new HTML5Gen(w);
+ break;
+
+ }
+ hg.pretty = (htmlStyle&CacheGen.PRETTY)>0;
+ return hg;
+ }
+
+ protected HTMLGen clone(Writer w) {
+ return create(flags,w);
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java
index c3359745..b2fb81d1 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java
@@ -27,214 +27,214 @@ import org.onap.aaf.misc.xgen.Mark;
import org.onap.aaf.misc.xgen.XGen;
public abstract class HTMLGen extends XGen<HTMLGen> {
- public static final String A = "a";
- public static final String P = "p";
- public static final String LI = "li";
- public static final String OL = "ol";
- public static final String UL = "ul";
-
-
- public static final String TABLE = "table";
- public static final String THEAD = "thead";
- public static final String TBODY = "tbody";
- public static final String TR = "tr";
- public static final String TH = "th";
- public static final String TD = "td";
-
- public static final String TITLE = "title";
- public static final String H1 = "h1";
- public static final String H2 = "h2";
- public static final String H3 = "h3";
- public static final String H4 = "h4";
- public static final String H5 = "h5";
-
-
-
- // --------------------------- HTML Version Specific -----------------------
- public abstract HTMLGen html(String ... attributes);
- public abstract HTMLGen charset(String charset);
- public abstract Mark head();
- public abstract Mark body(String ... attribs);
-
-
- // HTML 5 has simplified sectioning
- public abstract Mark header(String ... attribs);
- public abstract Mark footer(String ... attribs);
- public abstract Mark section(String ... attribs);
- public abstract Mark article(String ... attribs);
- public abstract Mark aside(String ... attribs);
- public abstract Mark nav(String ... attribs);
-
- // --------------------------- HTML Version Specific -----------------------
-
- public HTMLGen imports(Imports imports) {
- //this.imports=imports;
- for(String str : imports.css) {
- forward.print("<link rel=\"stylesheet\" href=\"");
- forward.print(imports.themePath(null));
- forward.print(str);
- forward.println("\">");
- }
-
- for(String str : imports.js) {
- forward.print("<script type=\"text/javascript\" src=\"");
- forward.print(imports.themePath(null));
- forward.print(str);
- forward.println("\"></script>");
- }
- return this;
- }
-
- public HTMLGen jsVars(String ... attrs) {
- forward.println("<script type=text/javascript>");
- if(attrs!=null) {
- for(int i=0; i<attrs.length;++i) {
- forward.append(' ');
- String[] split = attrs[i].split("=",2);
- switch(split.length) {
- case 2:
- forward.print(" var ");
- forward.append(split[0]);
- forward.append("='");
- forward.append(split[1]);
- forward.println("';");
- break;
- }
- }
- }
- forward.println("</script>");
- return this;
- }
-
- public HTMLGen(Writer w) {
- super(w);
- }
-
- /**
- * Use "directive" to handle non-ended HTML tags like <meta ... > and <link ...>
- * @param tag
- * @param attrs
- * @return
- */
- public HTMLGen directive(String tag, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append('>');
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public Mark divID(String ... attrs) {
- Mark div;
- if(attrs.length>0) {
- div = new Mark(attrs[0]);
- attrs[0]="id="+attrs[0];
- } else {
- div = new Mark();
- }
- incr(div, "div", attrs);
- return div;
- }
-
- public HTMLGen img(String ... attrs) {
- return tagOnly("img", attrs);
- }
-
- /**
- * Input Cheesecake... creates a Label and Field in the form of Table Rows.
- * Make sure you create a table first, ie. incr(HTMLGen.TABLE);
- *
- * Setting Required to "true" will add required Attribute to both Label and Field. In HTML5, "required" in the input will
- * validate there is data in the fields before submitting. "required" does nothing for label, but allows for
- * easy CSS coding... "label[required] { ... }", so that colors can be changed
- *
- * @param id
- * @param label
- * @param required
- * @param attrs
- * @return
- */
- public HTMLGen input(String id, String label, boolean required, String ... attrs) {
- Mark mtr = new Mark(TR);
- Mark mtd = new Mark(TD);
- incr(mtr);
- incr(mtd);
- incr("label",true, "for="+id,required?"required":null).text(label).end();
- end(mtd);
- String nattrs[] = new String[attrs.length+(required?3:2)];
- nattrs[0]="id="+id;
- nattrs[1]="name="+id;
- System.arraycopy(attrs, 0, nattrs, 2, attrs.length);
- if(required) {
- nattrs[nattrs.length-1]="required";
- }
- incr(mtd);
- tagOnly("input",nattrs);
- end(mtr);
- return this;
- }
-
- // Common tags that do not have standard endings. These are here to help people who don't know to pick directive
- public HTMLGen br() {
- forward.append("<br>");
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public HTMLGen p(String ... text) {
- forward.append("<p>");
- for(String s : text) {
- forward.append(s);
- }
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public HTMLGen hr() {
- forward.append("<hr>");
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public JSGen js(Mark mark) {
- return new JSGen(mark, this);
- }
-
- public JSGen js() {
- return js(null);
- }
+ public static final String A = "a";
+ public static final String P = "p";
+ public static final String LI = "li";
+ public static final String OL = "ol";
+ public static final String UL = "ul";
+
+
+ public static final String TABLE = "table";
+ public static final String THEAD = "thead";
+ public static final String TBODY = "tbody";
+ public static final String TR = "tr";
+ public static final String TH = "th";
+ public static final String TD = "td";
+
+ public static final String TITLE = "title";
+ public static final String H1 = "h1";
+ public static final String H2 = "h2";
+ public static final String H3 = "h3";
+ public static final String H4 = "h4";
+ public static final String H5 = "h5";
+
+
+
+ // --------------------------- HTML Version Specific -----------------------
+ public abstract HTMLGen html(String ... attributes);
+ public abstract HTMLGen charset(String charset);
+ public abstract Mark head();
+ public abstract Mark body(String ... attribs);
+
+
+ // HTML 5 has simplified sectioning
+ public abstract Mark header(String ... attribs);
+ public abstract Mark footer(String ... attribs);
+ public abstract Mark section(String ... attribs);
+ public abstract Mark article(String ... attribs);
+ public abstract Mark aside(String ... attribs);
+ public abstract Mark nav(String ... attribs);
+
+ // --------------------------- HTML Version Specific -----------------------
+
+ public HTMLGen imports(Imports imports) {
+ //this.imports=imports;
+ for(String str : imports.css) {
+ forward.print("<link rel=\"stylesheet\" href=\"");
+ forward.print(imports.themePath(null));
+ forward.print(str);
+ forward.println("\">");
+ }
+
+ for(String str : imports.js) {
+ forward.print("<script type=\"text/javascript\" src=\"");
+ forward.print(imports.themePath(null));
+ forward.print(str);
+ forward.println("\"></script>");
+ }
+ return this;
+ }
+
+ public HTMLGen jsVars(String ... attrs) {
+ forward.println("<script type=text/javascript>");
+ if(attrs!=null) {
+ for(int i=0; i<attrs.length;++i) {
+ forward.append(' ');
+ String[] split = attrs[i].split("=",2);
+ switch(split.length) {
+ case 2:
+ forward.print(" var ");
+ forward.append(split[0]);
+ forward.append("='");
+ forward.append(split[1]);
+ forward.println("';");
+ break;
+ }
+ }
+ }
+ forward.println("</script>");
+ return this;
+ }
+
+ public HTMLGen(Writer w) {
+ super(w);
+ }
+
+ /**
+ * Use "directive" to handle non-ended HTML tags like <meta ... > and <link ...>
+ * @param tag
+ * @param attrs
+ * @return
+ */
+ public HTMLGen directive(String tag, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append('>');
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public Mark divID(String ... attrs) {
+ Mark div;
+ if(attrs.length>0) {
+ div = new Mark(attrs[0]);
+ attrs[0]="id="+attrs[0];
+ } else {
+ div = new Mark();
+ }
+ incr(div, "div", attrs);
+ return div;
+ }
+
+ public HTMLGen img(String ... attrs) {
+ return tagOnly("img", attrs);
+ }
+
+ /**
+ * Input Cheesecake... creates a Label and Field in the form of Table Rows.
+ * Make sure you create a table first, ie. incr(HTMLGen.TABLE);
+ *
+ * Setting Required to "true" will add required Attribute to both Label and Field. In HTML5, "required" in the input will
+ * validate there is data in the fields before submitting. "required" does nothing for label, but allows for
+ * easy CSS coding... "label[required] { ... }", so that colors can be changed
+ *
+ * @param id
+ * @param label
+ * @param required
+ * @param attrs
+ * @return
+ */
+ public HTMLGen input(String id, String label, boolean required, String ... attrs) {
+ Mark mtr = new Mark(TR);
+ Mark mtd = new Mark(TD);
+ incr(mtr);
+ incr(mtd);
+ incr("label",true, "for="+id,required?"required":null).text(label).end();
+ end(mtd);
+ String nattrs[] = new String[attrs.length+(required?3:2)];
+ nattrs[0]="id="+id;
+ nattrs[1]="name="+id;
+ System.arraycopy(attrs, 0, nattrs, 2, attrs.length);
+ if(required) {
+ nattrs[nattrs.length-1]="required";
+ }
+ incr(mtd);
+ tagOnly("input",nattrs);
+ end(mtr);
+ return this;
+ }
+
+ // Common tags that do not have standard endings. These are here to help people who don't know to pick directive
+ public HTMLGen br() {
+ forward.append("<br>");
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public HTMLGen p(String ... text) {
+ forward.append("<p>");
+ for(String s : text) {
+ forward.append(s);
+ }
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public HTMLGen hr() {
+ forward.append("<hr>");
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public JSGen js(Mark mark) {
+ return new JSGen(mark, this);
+ }
+
+ public JSGen js() {
+ return js(null);
+ }
//
-// protected void cssInline(String filename) {
-// File file = new File(imports.webDir,filename);
-// try {
-// String line;
-// BufferedReader br = new BufferedReader(new FileReader(file));
-// try {
-// forward.print("<style>");
-// prettyln(forward);
-// while((line=br.readLine())!=null) {
-// forward.print((pretty?line:line.trim()));
-// prettyln(forward);
-// }
-// }finally {
-// forward.print("</style>");
-// prettyln(forward);
-// br.close();
-// }
-// } catch (IOException e) {
-// e.printStackTrace();
-// // Can't read, suffice to import normally?
-// // for now, just skip
-// }
-// }
-
+// protected void cssInline(String filename) {
+// File file = new File(imports.webDir,filename);
+// try {
+// String line;
+// BufferedReader br = new BufferedReader(new FileReader(file));
+// try {
+// forward.print("<style>");
+// prettyln(forward);
+// while((line=br.readLine())!=null) {
+// forward.print((pretty?line:line.trim()));
+// prettyln(forward);
+// }
+// }finally {
+// forward.print("</style>");
+// prettyln(forward);
+// br.close();
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// // Can't read, suffice to import normally?
+// // for now, just skip
+// }
+// }
+
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java
index 17678b3f..00e7f30f 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java
@@ -25,73 +25,73 @@ import java.util.ArrayList;
import java.util.List;
public class Imports implements Thematic{
- List<String> css;
- List<String> js;
- public final int backdots;
- private String theme;
-
- public Imports(int backdots) {
-
- css = new ArrayList<>();
- js = new ArrayList<>();
- this.backdots = backdots;
- theme = "";
- }
-
- public Imports css(String str) {
- css.add(str);
- return this;
- }
-
- public Imports js(String str) {
- js.add(str);
- return this;
- }
+ List<String> css;
+ List<String> js;
+ public final int backdots;
+ private String theme;
+
+ public Imports(int backdots) {
+
+ css = new ArrayList<>();
+ js = new ArrayList<>();
+ this.backdots = backdots;
+ theme = "";
+ }
+
+ public Imports css(String str) {
+ css.add(str);
+ return this;
+ }
+
+ public Imports js(String str) {
+ js.add(str);
+ return this;
+ }
- public Imports theme(String str) {
- theme = str==null?"":str;
- return this;
- }
+ public Imports theme(String str) {
+ theme = str==null?"":str;
+ return this;
+ }
- /**
- * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
- *
- * @param theTheme
- * @return
- */
- @Override
- public String themePath(String theTheme) {
- StringBuilder src = dots(new StringBuilder());
- if(theTheme==null||theTheme.length()==0) {
- src.append(theme);
- if(theme.length()>0)src.append('/');
- } else {
- src.append(theTheme);
- src.append('/');
- }
+ /**
+ * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
+ *
+ * @param theTheme
+ * @return
+ */
+ @Override
+ public String themePath(String theTheme) {
+ StringBuilder src = dots(new StringBuilder());
+ if(theTheme==null||theTheme.length()==0) {
+ src.append(theme);
+ if(theme.length()>0)src.append('/');
+ } else {
+ src.append(theTheme);
+ src.append('/');
+ }
- return src.toString();
- }
-
- /**
- * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
- *
- * @param theTheme
- * @return
- */
- @Override
- public String themeResolve(String theTheme) {
- return (theTheme==null||theTheme.length()==0)
- ?theme
- :theTheme;
- }
+ return src.toString();
+ }
+
+ /**
+ * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
+ *
+ * @param theTheme
+ * @return
+ */
+ @Override
+ public String themeResolve(String theTheme) {
+ return (theTheme==null||theTheme.length()==0)
+ ?theme
+ :theTheme;
+ }
- public StringBuilder dots(StringBuilder src) {
- for(int i=0;i<backdots;++i) {
- src.append("../");
- }
- return src;
- }
-
+ public StringBuilder dots(StringBuilder src) {
+ for(int i=0;i<backdots;++i) {
+ src.append("../");
+ }
+ return src;
+ }
+
};
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java
index 537e9fc5..5d9a507d 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java
@@ -31,174 +31,174 @@ import org.onap.aaf.misc.xgen.Mark;
public class JSGen {
- private HTMLGen htmlGen;
- private IndentPrintWriter ipw;
- private Mark mark;
+ private HTMLGen htmlGen;
+ private IndentPrintWriter ipw;
+ private Mark mark;
- public JSGen(Mark mark, HTMLGen hg) {
- this.mark = mark==null?new Mark():mark;
- hg.incr(this.mark, "script", "language=javascript", "type=text/javascript");
- htmlGen = hg;
- ipw = hg.getWriter();
- }
+ public JSGen(Mark mark, HTMLGen hg) {
+ this.mark = mark==null?new Mark():mark;
+ hg.incr(this.mark, "script", "language=javascript", "type=text/javascript");
+ htmlGen = hg;
+ ipw = hg.getWriter();
+ }
- public JSGen inline(String filename, int tabstop) throws IOException {
- BufferedReader br = new BufferedReader(new FileReader(filename));
- int indent = htmlGen.getIndent();
- try {
- boolean pretty = htmlGen.pretty;
- String line, el;
- int l, end;
- while((line=br.readLine())!=null) {
- if(pretty) {
- String[] elements = line.split("\t");
-
- for(int i=0; i<elements.length;++i) {
- el = elements[i];
- l = el.length();
- if(l==0) {// was a Tab
- ipw.print(" ");
- } else {
- el = el.trim();
- l = l-el.length();
- end = l/tabstop;
- for(int j=0;j<end;++j) {
- ipw.print(" ");
- }
- end = l%tabstop;
- for(int j=0;j<end;++j) {
- ipw.print(' ');
- }
- if(i>0) ipw.print(' ');
- ipw.print(el);
- }
- }
- ipw.println();
- } else {
- ipw.print(line.trim());
- }
- }
- } finally {
- htmlGen.setIndent(indent);
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return this;
- }
-
- public JSGen pst(String ... lines) {
- return pst(null, lines);
- }
-
- public JSGen pst(Mark jm, String ... lines) {
- if(lines.length>0) ipw.append(lines[0]);
- ipw.append('(');
- for(int i=1;i<lines.length;++i) {
- ipw.print(lines[i]);
- ipw.print(", ");
- }
- Back back;
+ public JSGen inline(String filename, int tabstop) throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ int indent = htmlGen.getIndent();
+ try {
+ boolean pretty = htmlGen.pretty;
+ String line, el;
+ int l, end;
+ while((line=br.readLine())!=null) {
+ if(pretty) {
+ String[] elements = line.split("\t");
+
+ for(int i=0; i<elements.length;++i) {
+ el = elements[i];
+ l = el.length();
+ if(l==0) {// was a Tab
+ ipw.print(" ");
+ } else {
+ el = el.trim();
+ l = l-el.length();
+ end = l/tabstop;
+ for(int j=0;j<end;++j) {
+ ipw.print(" ");
+ }
+ end = l%tabstop;
+ for(int j=0;j<end;++j) {
+ ipw.print(' ');
+ }
+ if(i>0) ipw.print(' ');
+ ipw.print(el);
+ }
+ }
+ ipw.println();
+ } else {
+ ipw.print(line.trim());
+ }
+ }
+ } finally {
+ htmlGen.setIndent(indent);
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return this;
+ }
+
+ public JSGen pst(String ... lines) {
+ return pst(null, lines);
+ }
+
+ public JSGen pst(Mark jm, String ... lines) {
+ if(lines.length>0) ipw.append(lines[0]);
+ ipw.append('(');
+ for(int i=1;i<lines.length;++i) {
+ ipw.print(lines[i]);
+ ipw.print(", ");
+ }
+ Back back;
- if(htmlGen.pretty) {
- back = new Back(");\n",false,false);
- } else {
- back = new Back(");",false,false);
- }
- int spot = htmlGen.pushBack(back);
- if(jm!=null)jm.spot(spot);
- return this;
- }
-
- public JSGen li(String ... lines) {
- int current = ipw.getIndent();
- for(int i=0;i<lines.length;++i) {
- if(i==1)ipw.inc();
- if(i>0)ipw.println();
- ipw.print(lines[i]);
- }
- ipw.setIndent(current);
- ipw.append(';');
- if(htmlGen.pretty)ipw.println();
- return this;
- }
-
- public JSGen text(String text) {
- ipw.append(text);
- if(htmlGen.pretty)ipw.println();
- return this;
- }
+ if(htmlGen.pretty) {
+ back = new Back(");\n",false,false);
+ } else {
+ back = new Back(");",false,false);
+ }
+ int spot = htmlGen.pushBack(back);
+ if(jm!=null)jm.spot(spot);
+ return this;
+ }
+
+ public JSGen li(String ... lines) {
+ int current = ipw.getIndent();
+ for(int i=0;i<lines.length;++i) {
+ if(i==1)ipw.inc();
+ if(i>0)ipw.println();
+ ipw.print(lines[i]);
+ }
+ ipw.setIndent(current);
+ ipw.append(';');
+ if(htmlGen.pretty)ipw.println();
+ return this;
+ }
+
+ public JSGen text(String text) {
+ ipw.append(text);
+ if(htmlGen.pretty)ipw.println();
+ return this;
+ }
- public JSGen function(String name, String ... params) {
- return function(null, name, params);
- }
-
- public JSGen jqfunc(Mark mark, String name, String ... params) {
- pst(mark,"$").function(name, params);
- return this;
- }
-
- public JSGen function(Mark jm, String name, String ... params) {
- ipw.print("function ");
- ipw.print(name);
- ipw.print('(');
- for(int i=0;i<params.length;++i) {
- if(i!=0)ipw.print(", ");
- ipw.print(params[i]);
- }
- ipw.print(") {");
- if(htmlGen.pretty) {
- ipw.println();
- ipw.inc();
- }
- int spot = htmlGen.pushBack(new Back("}",true,true));
- if(jm!=null)jm.spot(spot);
- return this;
- }
-
- public JSGen cb(String ... lines) {
- return cb(null,lines);
- }
+ public JSGen function(String name, String ... params) {
+ return function(null, name, params);
+ }
+
+ public JSGen jqfunc(Mark mark, String name, String ... params) {
+ pst(mark,"$").function(name, params);
+ return this;
+ }
+
+ public JSGen function(Mark jm, String name, String ... params) {
+ ipw.print("function ");
+ ipw.print(name);
+ ipw.print('(');
+ for(int i=0;i<params.length;++i) {
+ if(i!=0)ipw.print(", ");
+ ipw.print(params[i]);
+ }
+ ipw.print(") {");
+ if(htmlGen.pretty) {
+ ipw.println();
+ ipw.inc();
+ }
+ int spot = htmlGen.pushBack(new Back("}",true,true));
+ if(jm!=null)jm.spot(spot);
+ return this;
+ }
+
+ public JSGen cb(String ... lines) {
+ return cb(null,lines);
+ }
- public JSGen cb(Mark jm, String ... lines) {
- int current = ipw.getIndent();
- for(int i=0;i<lines.length;++i) {
- if(i==1)ipw.inc();
- if(i>0)ipw.println();
- ipw.print(lines[i]);
- }
- ipw.setIndent(current);
- ipw.print('{');
- if(htmlGen.pretty) {
- ipw.println();
- ipw.inc();
- }
- int spot = htmlGen.pushBack(new Back("}",true,true));
- if(jm!=null)jm.spot(spot);
- return this;
+ public JSGen cb(Mark jm, String ... lines) {
+ int current = ipw.getIndent();
+ for(int i=0;i<lines.length;++i) {
+ if(i==1)ipw.inc();
+ if(i>0)ipw.println();
+ ipw.print(lines[i]);
+ }
+ ipw.setIndent(current);
+ ipw.print('{');
+ if(htmlGen.pretty) {
+ ipw.println();
+ ipw.inc();
+ }
+ int spot = htmlGen.pushBack(new Back("}",true,true));
+ if(jm!=null)jm.spot(spot);
+ return this;
- }
+ }
-
- public JSGen comment(String ... lines) {
- if(htmlGen.pretty) {
- for(int i=0;i<lines.length;++i) {
- ipw.print("// ");
- ipw.println(lines[i]);
- }
- }
- return this;
- }
-
- public JSGen end(Mark mark) {
- htmlGen.end(mark);
- return this;
- }
-
- public HTMLGen done() {
- return htmlGen.end(mark);
- }
-
+
+ public JSGen comment(String ... lines) {
+ if(htmlGen.pretty) {
+ for(int i=0;i<lines.length;++i) {
+ ipw.print("// ");
+ ipw.println(lines[i]);
+ }
+ }
+ return this;
+ }
+
+ public JSGen end(Mark mark) {
+ htmlGen.end(mark);
+ return this;
+ }
+
+ public HTMLGen done() {
+ return htmlGen.end(mark);
+ }
+
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java
index 5b08efb4..dd8bc56f 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java
@@ -22,6 +22,6 @@
package org.onap.aaf.misc.xgen.html;
public interface Thematic {
- String themePath(String theTheme);
- String themeResolve(String theTheme);
+ String themePath(String theTheme);
+ String themeResolve(String theTheme);
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java
index b274fef9..b1110e0d 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java
@@ -30,16 +30,16 @@ import org.onap.aaf.misc.xgen.Code;
public class XMLCacheGen extends CacheGen<XMLGen> {
- public XMLCacheGen(int flags, Code<XMLGen> code) throws APIException,
- IOException {
- super(flags, code);
- }
+ public XMLCacheGen(int flags, Code<XMLGen> code) throws APIException,
+ IOException {
+ super(flags, code);
+ }
- @Override
- public XMLGen create(int style, Writer w) {
- XMLGen xg = new XMLGen(w);
- xg.pretty = (style & PRETTY)==PRETTY;
- return xg;
- }
+ @Override
+ public XMLGen create(int style, Writer w) {
+ XMLGen xg = new XMLGen(w);
+ xg.pretty = (style & PRETTY)==PRETTY;
+ return xg;
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java
index 6683c627..a5d75453 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java
@@ -26,19 +26,19 @@ import java.io.Writer;
import org.onap.aaf.misc.xgen.XGen;;
public class XMLGen extends XGen<XMLGen> {
- private final String XML_TAG;
-
- public XMLGen(Writer w) {
- this(w,"UTF-8");
- }
-
- public XMLGen(Writer w, String encoding) {
- super(w);
- XML_TAG="<?xml version=\"1.0\" encoding=\"" + encoding + "\" standalone=\"yes\"?>";
- }
+ private final String XML_TAG;
+
+ public XMLGen(Writer w) {
+ this(w,"UTF-8");
+ }
+
+ public XMLGen(Writer w, String encoding) {
+ super(w);
+ XML_TAG="<?xml version=\"1.0\" encoding=\"" + encoding + "\" standalone=\"yes\"?>";
+ }
- public XMLGen xml() {
- forward.println(XML_TAG);
- return this;
- }
+ public XMLGen xml() {
+ forward.println(XML_TAG);
+ return this;
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java
index 6a3eb15e..aa877966 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java
@@ -26,12 +26,12 @@ import org.junit.Test;
public class JU_BackTest {
- @Test
- public void testBackConstructor() {
- Back back = new Back("String", true, false);
+ @Test
+ public void testBackConstructor() {
+ Back back = new Back("String", true, false);
- assertEquals(back.str, "String");
- assertEquals(back.dec, true);
- assertEquals(back.cr, false);
- }
+ assertEquals(back.str, "String");
+ assertEquals(back.dec, true);
+ assertEquals(back.cr, false);
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java
index 5aead073..2a66f851 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java
@@ -37,29 +37,29 @@ import org.onap.aaf.misc.xgen.html.State;
public class JU_DynamicCodeTest {
- @Test
- public void test() throws APIException, IOException {
- final Cache<HTMLGen> cache1 = new Cache<HTMLGen>() {
+ @Test
+ public void test() throws APIException, IOException {
+ final Cache<HTMLGen> cache1 = new Cache<HTMLGen>() {
- @Override
- public void dynamic(HTMLGen hgen, Code<HTMLGen> code) {
- }
- };
+ @Override
+ public void dynamic(HTMLGen hgen, Code<HTMLGen> code) {
+ }
+ };
- final HTMLGen xgen1 = new HTML4Gen(new PrintWriter(System.out));
- DynamicCode<HTMLGen, State<Env>, Trans> g = new DynamicCode<HTMLGen, State<Env>, Trans>() {
+ final HTMLGen xgen1 = new HTML4Gen(new PrintWriter(System.out));
+ DynamicCode<HTMLGen, State<Env>, Trans> g = new DynamicCode<HTMLGen, State<Env>, Trans>() {
- @Override
- public void code(State<Env> state, Trans trans, Cache<HTMLGen> cache, HTMLGen xgen)
- throws APIException, IOException {
- assertNull(state);
- assertNull(trans);
- assertEquals(cache, cache1);
- assertEquals(xgen, xgen1);
- }
- };
+ @Override
+ public void code(State<Env> state, Trans trans, Cache<HTMLGen> cache, HTMLGen xgen)
+ throws APIException, IOException {
+ assertNull(state);
+ assertNull(trans);
+ assertEquals(cache, cache1);
+ assertEquals(xgen, xgen1);
+ }
+ };
- g.code(cache1, xgen1);
- }
+ g.code(cache1, xgen1);
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java
index 200bde6e..9a5378a7 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java
@@ -26,16 +26,16 @@ import org.junit.Test;
public class JU_MarkTest {
- @Test
- public void testMark() {
- Mark mark = new Mark();
- assertEquals(mark.spot, 0);
- assertEquals(mark.comment, null);
+ @Test
+ public void testMark() {
+ Mark mark = new Mark();
+ assertEquals(mark.spot, 0);
+ assertEquals(mark.comment, null);
- mark = new Mark("New Comment");
- mark.spot(10);
- assertEquals(mark.spot, 10);
- assertEquals(mark.comment, "New Comment");
+ mark = new Mark("New Comment");
+ mark.spot(10);
+ assertEquals(mark.spot, 10);
+ assertEquals(mark.comment, "New Comment");
- }
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java
index 5b5f816a..0f996d5c 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java
@@ -27,9 +27,9 @@ import org.onap.aaf.misc.xgen.Cache.Null;
public class JU_NullCacheTest {
- @Test
- public void testNullIsSingleton() {
- Null<?> singleton = Cache.Null.singleton();
- assertEquals(singleton, Cache.Null.singleton());
- }
+ @Test
+ public void testNullIsSingleton() {
+ Null<?> singleton = Cache.Null.singleton();
+ assertEquals(singleton, Cache.Null.singleton());
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
index a45ea158..44ca3a14 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
@@ -34,31 +34,31 @@ import org.onap.aaf.misc.env.APIException;
public class JU_SectionTest {
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- @Before
- public void setup() {
- writer = mock(Writer.class);
- }
+ @Before
+ public void setup() {
+ writer = mock(Writer.class);
+ }
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void test() throws APIException, IOException {
- Section section = new Section();
- section.forward = "Forward";
- section.backward = "Backward";
+ @Test
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void test() throws APIException, IOException {
+ Section section = new Section();
+ section.forward = "Forward";
+ section.backward = "Backward";
- section.setIndent(10);
- section.forward(writer);
- section.back(writer);
+ section.setIndent(10);
+ section.forward(writer);
+ section.back(writer);
- assertEquals(section.use(null, null, null), section);
- assertEquals(section.getIndent(), 10);
- assertEquals(section.toString(), "Forward");
+ assertEquals(section.use(null, null, null), section);
+ assertEquals(section.getIndent(), 10);
+ assertEquals(section.toString(), "Forward");
- verify(writer).write("Forward");
- verify(writer).write("Backward");
- }
+ verify(writer).write("Forward");
+ verify(writer).write("Backward");
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java
index 9160095d..6fa2afb8 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java
@@ -36,280 +36,280 @@ import org.mockito.Mock;
public class JU_HTML4GenTest {
- private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
- + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
+ private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
+ + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- private String charset = "utf-8";
+ private String charset = "utf-8";
- private final String CHARSET_LINE = "<meta http-equiv=\"Content-type\" content=\"text.hml; charset=" + charset
- + "\">";
+ private final String CHARSET_LINE = "<meta http-equiv=\"Content-type\" content=\"text.hml; charset=" + charset
+ + "\">";
- @Mock
- Writer w;
+ @Mock
+ Writer w;
- @Before
- public void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
- w = mock(Writer.class);
- }
+ w = mock(Writer.class);
+ }
- @Test
- public void testHTML() throws IOException {
+ @Test
+ public void testHTML() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.html("attributes");
+ gen.html("attributes");
- Map<Character, Integer> map = new TreeMap<>();
- for (char ch : DOCTYPE.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ Map<Character, Integer> map = new TreeMap<>();
+ for (char ch : DOCTYPE.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "html".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "html".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- verify(w, atLeast(1)).write(anyInt());
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ verify(w, atLeast(1)).write(anyInt());
+ }
- @Test
- public void testHead() throws IOException {
+ @Test
+ public void testHead() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.head();
+ gen.head();
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "head".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "head".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testBody() throws IOException {
+ @Test
+ public void testBody() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.body("attributes");
+ gen.body("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "body".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "body".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testCharSet() throws IOException {
+ @Test
+ public void testCharSet() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.charset(charset);
+ gen.charset(charset);
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : CHARSET_LINE.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : CHARSET_LINE.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testHeader() throws IOException {
+ @Test
+ public void testHeader() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.header("attributes");
+ gen.header("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "header".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "header".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testFooter() throws IOException {
+ @Test
+ public void testFooter() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.footer("attributes");
+ gen.footer("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "footer".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "footer".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testSection() throws IOException {
+ @Test
+ public void testSection() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.section("attributes");
+ gen.section("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "section".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "section".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testArticle() throws IOException {
+ @Test
+ public void testArticle() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.article("attributes");
+ gen.article("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "attrib".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attrib".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testAside() throws IOException {
+ @Test
+ public void testAside() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.aside("attributes");
+ gen.aside("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "aside".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "aside".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testNav() throws IOException {
+ @Test
+ public void testNav() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.nav("attributes");
+ gen.nav("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "nav".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "nav".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java
index 69ebf89b..6426fae5 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java
@@ -36,100 +36,100 @@ import org.mockito.Mock;
public class JU_HTML5GenTest {
-// private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
-// + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
+// private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
+// + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- private String charset = "utf-8";
+ private String charset = "utf-8";
- private final String CHARSET_LINE = "<meta charset=\"" + charset + "\">";
+ private final String CHARSET_LINE = "<meta charset=\"" + charset + "\">";
- @Mock
- Writer w;
+ @Mock
+ Writer w;
- @Before
- public void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
- w = mock(Writer.class);
- }
+ w = mock(Writer.class);
+ }
- @Test
- public void testHTML() throws IOException {
+ @Test
+ public void testHTML() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.html("attributes");
+ gen.html("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "html".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "html".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- verify(w, atLeast(1)).write(anyInt());
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ verify(w, atLeast(1)).write(anyInt());
+ }
- @Test
- public void testHead() throws IOException {
+ @Test
+ public void testHead() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.head();
+ gen.head();
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "head".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "head".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testBody() throws IOException {
+ @Test
+ public void testBody() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.body("attributes");
+ gen.body("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "body".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "body".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testCharSet() throws IOException {
+ @Test
+ public void testCharSet() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.charset(charset);
+ gen.charset(charset);
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : CHARSET_LINE.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : CHARSET_LINE.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java
index 4a6ce6b8..c9de2d14 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java
@@ -27,28 +27,28 @@ import org.junit.Test;
public class JU_ImportsTest {
- @Before
- public void setUp() throws Exception {
- }
-
- @Test
- public void test() {
- Imports imports = new Imports(2);
- imports.css("styles.css");
- imports.js("main.js");
- imports.theme("New Theme");
-
- assertEquals("New Theme", imports.themeResolve(null));
- assertEquals("New Theme", imports.themeResolve(""));
- assertEquals("The Theme", imports.themeResolve("The Theme"));
-
- assertEquals("build/../../", imports.dots(new StringBuilder("build/")).toString());
- assertEquals("../../Theme/", imports.themePath("Theme"));
- assertEquals("../../New Theme/", imports.themePath(""));
- assertEquals("../../New Theme/", imports.themePath(null));
-
- imports.theme(null);
- assertEquals("../../", imports.themePath(null));
- }
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() {
+ Imports imports = new Imports(2);
+ imports.css("styles.css");
+ imports.js("main.js");
+ imports.theme("New Theme");
+
+ assertEquals("New Theme", imports.themeResolve(null));
+ assertEquals("New Theme", imports.themeResolve(""));
+ assertEquals("The Theme", imports.themeResolve("The Theme"));
+
+ assertEquals("build/../../", imports.dots(new StringBuilder("build/")).toString());
+ assertEquals("../../Theme/", imports.themePath("Theme"));
+ assertEquals("../../New Theme/", imports.themePath(""));
+ assertEquals("../../New Theme/", imports.themePath(null));
+
+ imports.theme(null);
+ assertEquals("../../", imports.themePath(null));
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java
index 8bf811be..a52dae3d 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java
@@ -39,176 +39,176 @@ import org.onap.aaf.misc.xgen.Mark;
public class JU_JSGenTest {
- @Mock
- private HTMLGen hg;
- @Mock
- private Mark mark;
- @Mock
- private IndentPrintWriter writer;
- @Mock
- private Mark jm;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testFileNotFoundException() {
- JSGen gen = new JSGen(mark, hg);
-
- try {
- gen.inline("JSScript", 2);
- fail("This file should not be found.");
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void testJSRead() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- JSGen gen = new JSGen(mark, hg);
-
- gen.inline("./sampletest.js", 2);
-
- verify(writer).print("function myFunction() {");
- verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
- verify(writer).print("}");
- verify(writer, times(0)).println();
- }
-
- @Test
- public void testJSReadPrettyPrint() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.inline("./sampletest.js", 2);
-
- verify(writer).print("function myFunction() {");
- verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
- verify(writer).print("}");
- verify(writer, times(3)).println();
- verify(hg).setIndent(0);
- }
-
- @Test
- public void testPst() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.pst("line 1", "line 2");
-
- verify(writer).append('(');
- verify(writer).append("line 1");
- verify(writer).print("line 2");
- verify(writer, times(1)).print(", ");
- }
-
- @Test
- public void testPstWithMark() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- JSGen gen = new JSGen(mark, hg);
-
- gen.pst(jm, "line 1", "line 2");
-
- verify(writer).append('(');
- verify(writer).append("line 1");
- verify(writer).print("line 2");
- verify(writer, times(1)).print(", ");
- }
-
- @Test
- public void testPstWithNoLines() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- JSGen gen = new JSGen(mark, hg);
-
- gen.pst(jm);
-
- verify(writer).append('(');
- }
-
- @Test
- public void testLi() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(writer.getIndent()).thenReturn(3);
-
- JSGen gen = new JSGen(mark, hg);
-
- gen.li("line 1", "line 2");
-
- verify(writer).setIndent(3);
- verify(writer).inc();
- verify(writer).println();
- verify(writer).print("line 1");
- verify(writer).print("line 2");
-
- hg.pretty = true;
- gen.li("line 1", "line 2");
- verify(writer, times(3)).println();
- }
-
- @Test
- public void testText() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.text("line 1");
-
- verify(writer).append("line 1");
- verify(writer).println();
-
- hg.pretty = false;
- gen.text("line 1");
-
- verify(writer, times(2)).append("line 1");
- }
-
- @Test
- public void testFunction() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.function("line 1", "line 2", "line 3");
-
- verify(writer).print("function ");
- verify(writer).print("line 1");
- verify(writer).print('(');
-
- verify(writer).print("line 2");
- verify(writer).print("line 3");
- verify(writer, times(1)).print(", ");
- verify(writer).print(") {");
- verify(writer).inc();
- verify(writer).println();
- }
-
- @Test
- public void testFunctionWithMark() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- JSGen gen = new JSGen(mark, hg);
-
- gen.function(jm, "line 1", "line 2", "line 3");
-
- verify(writer).print("function ");
- verify(writer).print("line 1");
- verify(writer).print('(');
-
- verify(writer).print("line 2");
- verify(writer).print("line 3");
- verify(writer, times(1)).print(", ");
- verify(writer).print(") {");
- verify(writer, times(0)).inc();
- verify(writer, times(0)).println();
- }
+ @Mock
+ private HTMLGen hg;
+ @Mock
+ private Mark mark;
+ @Mock
+ private IndentPrintWriter writer;
+ @Mock
+ private Mark jm;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testFileNotFoundException() {
+ JSGen gen = new JSGen(mark, hg);
+
+ try {
+ gen.inline("JSScript", 2);
+ fail("This file should not be found.");
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testJSRead() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.inline("./sampletest.js", 2);
+
+ verify(writer).print("function myFunction() {");
+ verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
+ verify(writer).print("}");
+ verify(writer, times(0)).println();
+ }
+
+ @Test
+ public void testJSReadPrettyPrint() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.inline("./sampletest.js", 2);
+
+ verify(writer).print("function myFunction() {");
+ verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
+ verify(writer).print("}");
+ verify(writer, times(3)).println();
+ verify(hg).setIndent(0);
+ }
+
+ @Test
+ public void testPst() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.pst("line 1", "line 2");
+
+ verify(writer).append('(');
+ verify(writer).append("line 1");
+ verify(writer).print("line 2");
+ verify(writer, times(1)).print(", ");
+ }
+
+ @Test
+ public void testPstWithMark() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.pst(jm, "line 1", "line 2");
+
+ verify(writer).append('(');
+ verify(writer).append("line 1");
+ verify(writer).print("line 2");
+ verify(writer, times(1)).print(", ");
+ }
+
+ @Test
+ public void testPstWithNoLines() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.pst(jm);
+
+ verify(writer).append('(');
+ }
+
+ @Test
+ public void testLi() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(writer.getIndent()).thenReturn(3);
+
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.li("line 1", "line 2");
+
+ verify(writer).setIndent(3);
+ verify(writer).inc();
+ verify(writer).println();
+ verify(writer).print("line 1");
+ verify(writer).print("line 2");
+
+ hg.pretty = true;
+ gen.li("line 1", "line 2");
+ verify(writer, times(3)).println();
+ }
+
+ @Test
+ public void testText() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.text("line 1");
+
+ verify(writer).append("line 1");
+ verify(writer).println();
+
+ hg.pretty = false;
+ gen.text("line 1");
+
+ verify(writer, times(2)).append("line 1");
+ }
+
+ @Test
+ public void testFunction() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.function("line 1", "line 2", "line 3");
+
+ verify(writer).print("function ");
+ verify(writer).print("line 1");
+ verify(writer).print('(');
+
+ verify(writer).print("line 2");
+ verify(writer).print("line 3");
+ verify(writer, times(1)).print(", ");
+ verify(writer).print(") {");
+ verify(writer).inc();
+ verify(writer).println();
+ }
+
+ @Test
+ public void testFunctionWithMark() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.function(jm, "line 1", "line 2", "line 3");
+
+ verify(writer).print("function ");
+ verify(writer).print("line 1");
+ verify(writer).print('(');
+
+ verify(writer).print("line 2");
+ verify(writer).print("line 3");
+ verify(writer, times(1)).print(", ");
+ verify(writer).print(") {");
+ verify(writer, times(0)).inc();
+ verify(writer, times(0)).println();
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java
index c8014dda..5e15fa67 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java
@@ -34,30 +34,30 @@ import org.onap.aaf.misc.xgen.Code;
public class JU_XMLCacheGenTest {
- @Mock
- Writer writer;
+ @Mock
+ Writer writer;
- @Mock
- Code code;
+ @Mock
+ Code code;
- @Before
- public void setup() {
+ @Before
+ public void setup() {
- code = mock(Code.class);
- writer = mock(Writer.class);
- }
+ code = mock(Code.class);
+ writer = mock(Writer.class);
+ }
- @Test
- public void test() throws APIException, IOException {
- XMLCacheGen cacheGen = new XMLCacheGen(0, code);
- assertEquals(cacheGen.PRETTY, 1);
+ @Test
+ public void test() throws APIException, IOException {
+ XMLCacheGen cacheGen = new XMLCacheGen(0, code);
+ assertEquals(cacheGen.PRETTY, 1);
- XMLGen xgen = cacheGen.create(1, writer);
- assertEquals(0, xgen.getIndent());
+ XMLGen xgen = cacheGen.create(1, writer);
+ assertEquals(0, xgen.getIndent());
- xgen.setIndent(10);
- assertEquals(10, xgen.getIndent());
- xgen.comment("Comment");
- }
+ xgen.setIndent(10);
+ assertEquals(10, xgen.getIndent());
+ xgen.comment("Comment");
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
index 1c00b452..18b82393 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
@@ -36,31 +36,31 @@ import org.mockito.Mock;
public class JU_XMLGenTest {
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- String XML_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
+ String XML_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- @Before
- public void setUp() throws Exception {
- writer = mock(Writer.class);
- }
+ @Before
+ public void setUp() throws Exception {
+ writer = mock(Writer.class);
+ }
- @Test
- public void testXMLGenWriter() throws IOException {
- XMLGen xmlGen = new XMLGen(writer);
+ @Test
+ public void testXMLGenWriter() throws IOException {
+ XMLGen xmlGen = new XMLGen(writer);
- xmlGen.xml();
+ xmlGen.xml();
- for (char ch : XML_TAG.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : XML_TAG.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(writer, times(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(writer, times(map.get(ch))).write(ch);
+ }
+ }
} \ No newline at end of file