Logo Search packages:      
Sourcecode: jing-trang version File versions  Download package

void com::thaiopensource::validate::nvdl::SchemaImpl::Handler::parseOption ( Attributes  attributes  )  throws SAXException [inline, private]

Parse a validate option.

Parameters:
attributes The option element attributes.
Exceptions:
SAXException 

Definition at line 781 of file SchemaImpl.java.

References error(), com::thaiopensource::validate::nvdl::SchemaReceiverImpl::getOption(), locator, md, com::thaiopensource::validate::nvdl::SchemaImpl::Handler::ModeData::mustSupportOptions, com::thaiopensource::validate::nvdl::SchemaImpl::NVDL_URI, com::thaiopensource::validate::nvdl::SchemaImpl::Handler::ModeData::options, and sr.

Referenced by startElement().

                                                                        {
      // get the mustSupport flag
      boolean mustSupport;
      String mustSupportValue = attributes.getValue("", "mustSupport");
      if (mustSupportValue != null) {
        mustSupportValue = mustSupportValue.trim();
        mustSupport = mustSupportValue.equals("1") || mustSupportValue.equals("true");
      }
      else
        mustSupport = false;
      // Resolve the option if specified relative to the NVDL URI.
      String name = Uri.resolve(NVDL_URI, attributes.getValue("", "name"));
      Option option = sr.getOption(name);
      // check if we got a known option.
      if (option == null) {
        if (mustSupport)
          error("unknown_option", name);
      }
      else {
      // known option, look for arguments
        String arg = attributes.getValue("", "arg");
        try {
          PropertyId pid = option.getPropertyId();
          Object value = option.valueOf(arg);
          Object oldValue = md.options.get(pid);
          if (oldValue != null) {
            value = option.combine(new Object[]{oldValue, value});
            if (value == null)
              error("duplicate_option", name);
            else
              md.options.put(pid, value);
          }
          else {
            md.options.put(pid, value);
            md.mustSupportOptions.addElement(new MustSupportOption(name, pid,
                                                                locator == null
                                                                ? null
                                                                : new LocatorImpl(locator)));
          }
        }
        catch (OptionArgumentPresenceException e) {
          error(arg == null ? "option_requires_argument" : "option_unexpected_argument", name);
        }
        catch (OptionArgumentException e) {
          if (arg == null)
            error("option_requires_argument", name);
          else
            error("option_bad_argument", name, arg);
        }
      }
    }


Generated by  Doxygen 1.6.0   Back to index