Esempio n. 1
0
void JavaCodeGenerator::deserializeField(ofstream& ofs, TypeDeclaration& theField) {

    if (theField.declarationType == DLT_ARRAY) {
        string arrayLength = nextParamName();
        ofs << "int " + arrayLength + " = SerializationUtil.readVariableLength(dis);" << endl;
        if (theField.userTypeDefinition == NULL) {
            ofs << theField.name + " = new " + getPrimitiveTypeName(theField.dataType) + "[" + arrayLength + "];" << endl;
            ofs << "for(int i=0; i < " + arrayLength + ";i++){" << endl;

            readField(ofs, theField.dataType, theField.name + "[i]");

            ofs << "}" << endl;
        } else {
            ofs << theField.name + " = new " + theField.userTypeDefinition->name + "[" + arrayLength + "];" << endl;
            ofs << "for(int i=0; i < " + theField.name + ".length;i++){" << endl;
            ofs << theField.name + "[i] = new " << theField.userTypeDefinition->name << "();" << endl;
            ofs << theField.name + "[i].deserialize(dis);" << endl;
            ofs << "}" << endl;
        }

    } else if (theField.declarationType == DLT_USER) {
        ofs << theField.name + " = new " << theField.userTypeDefinition->name << "();" << endl;
        ofs << theField.name + ".deserialize(dis);" << endl;
    } else if (theField.declarationType == DLT_PRIMITIVE) {
        

        readField(ofs, theField.dataType, theField.name);
    } else if (theField.declarationType == DLT_BYTE_ARRAY) {
        string arrayLength = nextParamName();
        ofs << "int " + arrayLength + " = SerializationUtil.readVariableLength(dis);" << endl;
        ofs << theField.name + " = new byte[" + arrayLength + "];";
        ofs << "dos.read(" + theField.name + ");" << endl;
    }
}
Esempio n. 2
0
string JavaCodeGenerator::getTypeName(TypeDeclaration& declaration) {
    DeclarationType declarationType = declaration.declarationType;
    if (declarationType == DLT_PRIMITIVE) {
        DataType dataType = declaration.dataType;
        return getPrimitiveTypeName(dataType);
    } else if (declarationType == DLT_USER) {
        return declaration.userTypeDefinition->name;
    } else if (declarationType == DLT_ARRAY) {
        if (declaration.userTypeDefinition == NULL) {
            return getPrimitiveTypeName(declaration.dataType) + "[]";
        } else {
            return declaration.userTypeDefinition->name + "[]";
        }
    } else if (declarationType == DLT_BYTE_ARRAY) {
        return "byte[]";
    }

    return "---------";
}
Esempio n. 3
0
/* Get the name of this type  (ie "integer" for xs:integer)-- 
 * same as the primitive type name. UntypedAtomic cannot be 
 * extended */
const XMLCh* ATUntypedAtomicImpl::getTypeName() const {
  return getPrimitiveTypeName();
}