/** Copyright (C) Conformiq Software Ltd. | |
* All rights reserved. | |
* | |
* Created Wed Aug 27 16:49:21 2008. | |
* | |
* @file TTCNTypeName.java | |
* | |
* @author Conformiq Software Ltd. | |
* | |
* | |
*/ | |
package com.conformiq.adaptation.ttcn; | |
import java.util.Queue; | |
import java.util.Set; | |
import com.conformiq.qtronic2.QMLArrayType; | |
import com.conformiq.qtronic2.QMLBooleanType; | |
import com.conformiq.qtronic2.QMLNumberType; | |
import com.conformiq.qtronic2.QMLOptionalType; | |
import com.conformiq.qtronic2.QMLRecordType; | |
import com.conformiq.qtronic2.QMLStringType; | |
import com.conformiq.qtronic2.QMLTypeVisitor; | |
class TTCNTypeName implements QMLTypeVisitor | |
{ | |
public TTCNTypeName(final Queue<QMLRecordType> workList, | |
final Set<QMLRecordType> alreadyDumped, final Set<String> arrays) | |
{ | |
this.workList = workList; | |
this.alreadyDumped = alreadyDumped; | |
this.arrays = arrays; | |
optional = false; | |
} | |
public void visit(QMLArrayType a) | |
{ | |
// We first visit the element type to get the correct name | |
// for it. | |
a.getType().accept(this); | |
// arrays.add(a.getType().getTypeName()); | |
arrays.add(name); | |
optional = false; | |
name += "Array"; | |
} | |
public void visit(QMLBooleanType b) | |
{ | |
name = "boolean"; | |
} | |
public void visit(QMLNumberType n) | |
{ | |
if (n.isFloat() || n.isDouble()) | |
{ | |
name = "float"; | |
} | |
else | |
{ | |
name = "integer"; | |
} | |
} | |
public void visit(QMLRecordType r) | |
{ | |
if (!alreadyDumped.contains(r)) | |
{ | |
workList.offer(r); | |
} | |
name = r.getTypeName(); | |
} | |
public void visit(QMLStringType s) | |
{ | |
name = "charstring"; | |
} | |
public void visit(QMLOptionalType p) | |
{ | |
p.getType().accept(this); | |
optional = true; | |
} | |
private boolean optional; | |
public boolean getOptional() | |
{ | |
return optional; | |
} | |
private String name = ""; | |
public String getName() | |
{ | |
return name; | |
} | |
protected Set<String> arrays; | |
private final Queue<QMLRecordType> workList; | |
private final Set<QMLRecordType> alreadyDumped; | |
}; |