Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Added type constant for custom-typed elements to ElementMetadata class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Seidel committed Mar 27, 2012
1 parent 737b187 commit 44f4b83
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ private void generateSerializeCode(final Queue<ElementMetadata> elementMetadata)
element.getEXIEventCode(), element.getElementEXIType(),
element.getElementName());
break;

// TODO: XML element is custom typed
case ElementMetadata.CUSTOM_TYPED:
serializerCode += String.format(
"exitCode += stream->writeNBits(3, %d);\n" +
"exitCode += encoder.encode%s(stream, typeObject->get%s()->get%s());\n\n",
element.getEXIEventCode(), element.getElementEXIType(),
element.getParentName(), element.getElementName());
break;

// XML element is a list
case ElementMetadata.XML_LIST:
Expand Down Expand Up @@ -307,6 +316,21 @@ private void generateDeserializeCode(final Queue<ElementMetadata> elementMetadat
element.getElementName(), element.getElementName().toLowerCase());
break;

// TODO: XML element is custom typed
case ElementMetadata.CUSTOM_TYPED:
deserializerCode += String.format(
"// Read EXI event code\n" +
"exitCode += stream->readNBits(3, &eventCodeBits);\n\n" +
"// Decode element value\n" +
"exitCode += decoder.decode%s(stream, &%s);\n\n" +
"if (0 == exitCode) {\n" +
"\ttypeObject->get%s()->set%s(%s);\n" +
"}\n\n",
element.getElementEXIType(), element.getElementName().toLowerCase(),
element.getParentName(), element.getElementName(),
element.getElementName().toLowerCase());
break;

// XML element is a list
case ElementMetadata.XML_LIST:
deserializerCode += String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import fabric.wsdlschemaparser.schema.FElement;
import fabric.wsdlschemaparser.schema.FList;
import fabric.wsdlschemaparser.schema.FSchemaTypeHelper;
import fabric.wsdlschemaparser.schema.SchemaHelper;

/**
* This class is a container for XML element metadata. While
Expand Down Expand Up @@ -49,6 +50,9 @@ public class ElementMetadata implements Comparable<ElementMetadata>

/** XML element is an array that may contain multiple values */
public static final int XML_ARRAY = 2;

// TODO: Constant added
public static final int CUSTOM_TYPED = 3;

/** Name of the XML element */
private String elementName;
Expand Down Expand Up @@ -102,8 +106,11 @@ public ElementMetadata(final FElement element)
// Set XML element name
this.elementName = element.getName();

// TODO: Line added
boolean isCustomTyped = !SchemaHelper.isBuiltinTypedElement(element);

// Element is an XML list
if (FSchemaTypeHelper.isList(element))
if (FSchemaTypeHelper.isList(element) && !isCustomTyped)
{
FList listType = (FList)element.getSchemaType();

Expand All @@ -116,6 +123,13 @@ else if (FSchemaTypeHelper.isArray(element))
this.elementEXIType = this.getEXITypeName(element.getSchemaType().getClass().getSimpleName());
this.type = ElementMetadata.XML_ARRAY;
}
// TODO: Block added
// Element is custom typed
else if (isCustomTyped)
{
this.elementEXIType = this.getEXITypeName(element.getSchemaType().getClass().getSimpleName());
this.type = ElementMetadata.CUSTOM_TYPED;
}
// Element is an atomic value
else
{
Expand Down

0 comments on commit 44f4b83

Please sign in to comment.