Esempio n. 1
0
  private DataAttributeDefinition getDataAttributeByName(String name) {
    for (DataAttributeDefinition dad : dataAttributes) {
      if (dad.getName().equals(name)) return dad;
    }

    return null;
  }
Esempio n. 2
0
  public DataObjectType(Node xmlNode) throws SclParserException {
    super(xmlNode);

    this.cdc = ParserUtils.parseAttribute(xmlNode, "cdc");

    if (this.cdc == null) throw new SclParserException(xmlNode, "cdc is missing!");

    NodeList elementNodes = xmlNode.getChildNodes();

    if (elementNodes != null) {
      this.dataAttributes = new LinkedList<DataAttributeDefinition>();
      this.subDataObjects = new LinkedList<DataObjectDefinition>();

      for (int i = 0; i < elementNodes.getLength(); i++) {
        Node elementNode = elementNodes.item(i);

        if (elementNode.getNodeName().equals("DA")) {
          DataAttributeDefinition dad = new DataAttributeDefinition(elementNode);

          DataAttributeDefinition otherDefinition = getDataAttributeByName(dad.getName());

          if (otherDefinition != null) {

            if (otherDefinition.getFc() == dad.getFc())
              throw new SclParserException(
                  xmlNode,
                  "DO type definition contains multiple elements of name \""
                      + dad.getName()
                      + "\"");
          }

          if (getDataObjectByName(dad.getName()) != null) {
            throw new SclParserException(
                xmlNode,
                "DO type definition contains multiple elements of name \"" + dad.getName() + "\"");
          }

          dataAttributes.add(dad);
        } else if (elementNode.getNodeName().equals("SDO")) {
          DataObjectDefinition dod = new DataObjectDefinition(elementNode);

          if ((getDataAttributeByName(dod.getName()) != null)
              || (getDataObjectByName(dod.getName()) != null))
            throw new SclParserException(
                xmlNode,
                "DO type definition contains multiple elements of name \"" + dod.getName() + "\"");

          this.subDataObjects.add(dod);
        }
      }
    }
  }