public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(OPTION)) {
        OptionHandler optionHandler = new OptionHandler(this);
        optionHandler.init(name, atts);
        if (optionHandler._isParsedDataValid) {
          // Only add valid Option
          _optionLabel_vector.addElement(optionHandler._label_val);
          _optionValue_vector.addElement(optionHandler._value_val);
        }
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
Пример #2
0
  /** Collects the triples of a model in a vector. */
  public static Vector getStatementVector(Model m) throws ModelException {

    Vector v = new Vector();
    for (Enumeration en = m.elements(); en.hasMoreElements(); ) {

      Statement t = (Statement) en.nextElement();
      v.addElement(t);
    }
    return v;
  }
    protected void finished() {

      logger.log(
          LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler():finished()"); // $NON-NLS-1$
      if (!_isParsedDataValid) return;
      int numOfValues = _optionValue_vector.size();
      _ad.setOption(_optionLabel_vector, _optionValue_vector, true);
      String[] values = _ad.getOptionValues();
      if (values == null) values = new String[0];
      if (numOfValues != values.length)
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.INVALID_OPTIONS_XML,
                new Object[] {
                  elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()
                }));

      if (ad_defaults_str != null) {
        _ad.setDefaultValue(ad_defaults_str, true);
        if (_ad.getDefaultValue() == null)
          logger.log(
              LogService.LOG_WARNING,
              NLS.bind(
                  MetaTypeMsg.INVALID_DEFAULTS_XML,
                  new Object[] {
                    ad_defaults_str,
                    elementId,
                    _dp_url,
                    _dp_bundle.getBundleId(),
                    _dp_bundle.getSymbolicName()
                  }));
      }

      _parent_ADs_vector.addElement(_ad);
    }
Пример #4
0
 // 외부 언파스드 엔티티 선언을 만났을 때 발생하는 이벤트를 처리하는 메소드
 public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
     throws SAXException {
   UnparsedEntityDecl ued = new UnparsedEntityDecl(name, publicId, systemId, notationName);
   vUnparsedEntityDecl.addElement(ued);
 }
Пример #5
0
  /**
   * Reads XML element(s) into an indexed bean property by first locating the XML element(s)
   * corresponding to this property.
   *
   * @param ob The bean whose property is being set
   * @param desc The property that will be set
   * @param nodes The list of XML items that may contain the property
   * @throws IOException If there is an error reading the document
   */
  public void readIndexedProperty(
      Object ob, IndexedPropertyDescriptor desc, NodeList nodes, NamedNodeMap attrs)
      throws IOException {
    // Create a vector to hold the property values
    Vector v = new Vector();

    int numAttrs = attrs.getLength();

    for (int i = 0; i < numAttrs; i++) {
      // See if this attribute matches the property name
      if (namesMatch(desc.getName(), attrs.item(i).getNodeName())) {
        // Get the property value
        Object obValue = getObjectValue(desc, attrs.item(i).getNodeValue());

        if (obValue != null) {
          // Add the value to the list of values to be set
          v.addElement(obValue);
        }
      }
    }

    int numNodes = nodes.getLength();

    for (int i = 0; i < numNodes; i++) {
      Node node = nodes.item(i);

      // Skip non-element nodes
      if (!(node instanceof Element)) continue;

      Element element = (Element) node;

      // See if this element tag matches the property name
      if (namesMatch(desc.getName(), element.getTagName())) {
        // Get the property value
        Object obValue = getObjectValue(desc, element);

        if (obValue != null) {
          // Add the value to the list of values to be set
          v.addElement(obValue);
        }
      }
    }

    // Get the method used to set the property value
    Method setter = desc.getWriteMethod();

    // If this property has no setter, don't write it
    if (setter == null) return;

    // Create a new array of property values
    Object propArray = Array.newInstance(desc.getPropertyType().getComponentType(), v.size());

    // Copy the vector into the array
    v.copyInto((Object[]) propArray);

    try {
      // Store the array of property values
      setter.invoke(ob, new Object[] {propArray});
    } catch (InvocationTargetException exc) {
      throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
    } catch (IllegalAccessException exc) {
      throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
    }
  }
Пример #6
0
  /**
   * Reads an XML element into a bean property by first locating the XML element corresponding to
   * this property.
   *
   * @param ob The bean whose property is being set
   * @param desc The property that will be set
   * @param nodes The list of XML items that may contain the property
   * @throws IOException If there is an error reading the document
   */
  public void readProperty(Object ob, PropertyDescriptor desc, NodeList nodes, NamedNodeMap attrs)
      throws IOException {
    int numAttrs = attrs.getLength();

    for (int i = 0; i < numAttrs; i++) {
      // See if the attribute name matches the property name
      if (namesMatch(desc.getName(), attrs.item(i).getNodeName())) {
        // Get the method used to set this property
        Method setter = desc.getWriteMethod();

        // If this object has no setter, don't bother writing it
        if (setter == null) continue;

        // Get the value of the property
        Object obValue = getObjectValue(desc, attrs.item(i).getNodeValue());
        if (obValue != null) {
          try {
            // Set the property value
            setter.invoke(ob, new Object[] {obValue});
          } catch (InvocationTargetException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          } catch (IllegalAccessException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          }
        }

        return;
      }
    }

    int numNodes = nodes.getLength();

    Vector arrayBuild = null;

    for (int i = 0; i < numNodes; i++) {
      Node node = nodes.item(i);

      // If this node isn't an element, skip it
      if (!(node instanceof Element)) continue;

      Element element = (Element) node;

      // See if the tag name matches the property name
      if (namesMatch(desc.getName(), element.getTagName())) {
        // Get the method used to set this property
        Method setter = desc.getWriteMethod();

        // If this object has no setter, don't bother writing it
        if (setter == null) continue;

        // Get the value of the property
        Object obValue = getObjectValue(desc, element);

        // 070201 MAW: Modified from change submitted by Steve Poulson
        if (setter.getParameterTypes()[0].isArray()) {
          if (arrayBuild == null) {
            arrayBuild = new Vector();
          }
          arrayBuild.addElement(obValue);

          // 070201 MAW: Go ahead and read through the rest of the nodes in case
          //             another one matches the array. This has the effect of skipping
          //             over the "return" statement down below
          continue;
        }

        if (obValue != null) {
          try {
            // Set the property value
            setter.invoke(ob, new Object[] {obValue});
          } catch (InvocationTargetException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          } catch (IllegalAccessException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          }
        }
        return;
      }
    }

    // If we build a vector of array members, convert the vector into
    // an array and save it in the property
    if (arrayBuild != null) {
      // Get the method used to set this property
      Method setter = desc.getWriteMethod();

      if (setter == null) return;

      Object[] obValues = (Object[]) Array.newInstance(desc.getPropertyType(), arrayBuild.size());

      arrayBuild.copyInto(obValues);

      try {
        setter.invoke(ob, new Object[] {obValues});
      } catch (InvocationTargetException exc) {
        throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
      } catch (IllegalAccessException exc) {
        throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
      }

      return;
    }
  }