summaryrefslogtreecommitdiffstats
path: root/rosetta/src/main/java/org/onap/aaf/rosetta/marshal
diff options
context:
space:
mode:
Diffstat (limited to 'rosetta/src/main/java/org/onap/aaf/rosetta/marshal')
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DataWriter.java139
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DocMarshal.java83
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldArray.java93
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldBlob.java39
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDate.java38
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDateTime.java38
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldHexBinary.java36
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldMarshal.java60
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldNumeric.java37
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldString.java37
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ListIterator.java59
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjArray.java91
-rw-r--r--rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjMarshal.java128
13 files changed, 0 insertions, 878 deletions
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DataWriter.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DataWriter.java
deleted file mode 100644
index 14a1e24..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DataWriter.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import javax.xml.datatype.XMLGregorianCalendar;
-
-import org.onap.aaf.inno.env.util.Chrono;
-
-/**
- * We make these objects instead of static functions so they can be passed into
- * FieldArray.
- *
- *
- * @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 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<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<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;
- }
- };
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DocMarshal.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DocMarshal.java
deleted file mode 100644
index 47ee596..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/DocMarshal.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import java.util.Iterator;
-
-import org.onap.aaf.rosetta.Ladder;
-import org.onap.aaf.rosetta.Marshal;
-import org.onap.aaf.rosetta.ParseException;
-import org.onap.aaf.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
-
- }
-
- public static final Iterator<Void> PENDING_ITERATOR = new Iterator<Void>() {
- @Override
- public boolean hasNext() {
- return false;
- }
-
- @Override
- public Void next() {
- return null;
- }
-
- @Override
- public void remove() {
- }
- };
-
- public static<T> DocMarshal<T> root(Marshal<T> m) {
- return (DocMarshal<T>)new DocMarshal<T>(m);
- }
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldArray.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldArray.java
deleted file mode 100644
index 5683367..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldArray.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.onap.aaf.rosetta.Ladder;
-import org.onap.aaf.rosetta.Marshal;
-import org.onap.aaf.rosetta.ParseException;
-import org.onap.aaf.rosetta.Parsed;
-
-
-public abstract class FieldArray<T,S> extends Marshal<T> {
- 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
- }
-
- protected abstract List<S> data(T t);
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldBlob.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldBlob.java
deleted file mode 100644
index f8275c9..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldBlob.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-public abstract class FieldBlob<T> extends FieldMarshal<T>{
- public FieldBlob(String name) {
- super(name);
- }
-
- 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);
- }
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDate.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDate.java
deleted file mode 100644
index 799cdb0..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDate.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import javax.xml.datatype.XMLGregorianCalendar;
-
-public abstract class FieldDate<T> extends FieldMarshal<T> {
- public FieldDate(String name) {
- super(name);
- }
-
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- return DataWriter.DATE.write(data(t), sb);
- }
-
- protected abstract XMLGregorianCalendar data(T t);
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDateTime.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDateTime.java
deleted file mode 100644
index bd64748..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldDateTime.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import javax.xml.datatype.XMLGregorianCalendar;
-
-public abstract class FieldDateTime<T> extends FieldMarshal<T> {
- public FieldDateTime(String name) {
- super(name);
- }
-
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- return DataWriter.DATE_TIME.write(data(t), sb);
- }
-
- protected abstract XMLGregorianCalendar data(T t);
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldHexBinary.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldHexBinary.java
deleted file mode 100644
index c765625..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldHexBinary.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-public abstract class FieldHexBinary<T> extends FieldMarshal<T>{
- public FieldHexBinary(String name) {
- super(name);
- }
-
- protected abstract byte[] data(T t);
-
- @Override
- protected boolean data(T t, StringBuilder sb) {
- return DataWriter.HEX_BINARY.write(data(t), sb);
- }
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldMarshal.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldMarshal.java
deleted file mode 100644
index 44d5aff..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldMarshal.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-
-import org.onap.aaf.rosetta.Marshal;
-import org.onap.aaf.rosetta.Parse;
-import org.onap.aaf.rosetta.Parsed;
-
-public abstract class FieldMarshal<T> extends Marshal<T> {
- 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;
- }
-
- /**
- * 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);
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldNumeric.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldNumeric.java
deleted file mode 100644
index 493cb8b..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldNumeric.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-public abstract class FieldNumeric<N,T> extends FieldMarshal<T> {
- public FieldNumeric(String name) {
- super(name);
- }
-
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- sb.append(data(t));
- return false;
- }
-
- protected abstract N data(T t);
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldString.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldString.java
deleted file mode 100644
index 662e5da..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/FieldString.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-public abstract class FieldString<T> extends FieldMarshal<T> {
- public FieldString(String name) {
- super(name);
- }
-
- protected abstract String data(T t);
-
- @Override
- final protected boolean data(T t, StringBuilder sb) {
- return DataWriter.STRING.write(data(t), sb);
- }
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ListIterator.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ListIterator.java
deleted file mode 100644
index 204437c..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ListIterator.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Need an Iterator that can peek the current value without changing
- *
- * @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();
- }
-
- @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();
- }
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjArray.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjArray.java
deleted file mode 100644
index e935887..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjArray.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.onap.aaf.rosetta.Ladder;
-import org.onap.aaf.rosetta.Marshal;
-import org.onap.aaf.rosetta.ParseException;
-import org.onap.aaf.rosetta.Parsed;
-
-
-public abstract class ObjArray<T,S> extends Marshal<T> {
- private String name;
- private Marshal<S> 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)) {
- } 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 = 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);
-
-}
diff --git a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjMarshal.java b/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjMarshal.java
deleted file mode 100644
index 0205eaa..0000000
--- a/rosetta/src/main/java/org/onap/aaf/rosetta/marshal/ObjMarshal.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package org.onap.aaf.rosetta.marshal;
-
-import java.util.Iterator;
-
-import org.onap.aaf.rosetta.Ladder;
-import org.onap.aaf.rosetta.Marshal;
-import org.onap.aaf.rosetta.ParseException;
-import org.onap.aaf.rosetta.Parsed;
-
-/**
- * Object Marshal
- * Assumes has Fields and other Objects
- * s
- *
- * @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 com.att.rosetta.Parse#parse(java.lang.Object, com.att.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)) {
- } else {
- 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
- }
-
- private class FieldsIterator implements Iterator<Marshal<T>> {
- private int idx = -1;
-
- @Override
- public boolean hasNext() {
- return idx<end;
- }
-
- @Override
- public Marshal<T> next() {
- return pml[++idx];
- }
-
- public Marshal<T> peek() {
- return idx<0?null:pml[idx];
- }
-
- @Override
- public void remove() {
- pml[idx]=null;
- }
-
- }
-
-}