package step.core; import java.io.*; import java.util.*; public class StepValueConverter extends StepAbstractRepositoryVisitor { Stack valstk; public StepValueConverter(StepAbstractRepository repo) { super (repo); valstk = new Stack(); valstk.push((Object) new ArrayList()); } public ArrayList result() throws EmptyStackException { return (ArrayList) valstk.pop(); } public void accept(StepGenericRepository e) throws Exception { throw new Exception("unable to accept a repository"); } public void accept(StepAggregationValue e) throws Exception { ArrayList res = new ArrayList(); ((List)valstk.peek()).add(res); valstk.push(res); for (int i = 0; i < e.size(); i++) { e.get(i).accept(this); } valstk.pop(); } public void accept(StepStringValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepBinaryValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepEncodedStringValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepEnumerationValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepExternalRepresentation e) throws Exception { throw new Exception("unable to accept an external representation"); } public void accept(StepHeaderInstance e) throws Exception { ((List)valstk.peek()).add(e); } public void accept(StepGenericInstanceReference e) throws Exception { ((List)valstk.peek()).add(repo.instanceAt(e.getId())); } public void accept(StepIntegerValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepInternalRepresentation e) throws Exception { throw new Exception("unable to accept an external representation"); } public void accept(StepLogicalValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepNoValue e) throws Exception { ((List)valstk.peek()).add(null); } public void accept(StepRealValue e) throws Exception { ((List)valstk.peek()).add(e.getVal()); } public void accept(StepRedefinedValue e) throws Exception { ((List)valstk.peek()).add(null); } public void accept(StepSimpleRecord e) throws Exception { throw new Exception("unable to accept an external representation"); } public void accept(StepTypedValue e) throws Exception { e.getVal().accept(this); } }