protected void startElement(DAVElement parent, DAVElement element, Attributes attrs)
     throws SVNException {
   if (element == FILE_REVISION) {
     myPath = attrs.getValue("path");
     myRevision = Long.parseLong(attrs.getValue("rev"));
   } else if (element == REVISION_PROPERTY
       || element == SET_PROPERTY
       || element == DELETE_PROPERTY) {
     myPropertyName = attrs.getValue("name");
     myPropertyEncoding = attrs.getValue("encoding");
   }
   if (element == TX_DELTA) {
     // handle file revision with props.
     if (myPath != null && myFileRevisionsHandler != null) {
       if (myProperties == null) {
         myProperties = Collections.EMPTY_MAP;
       }
       if (myPropertiesDelta == null) {
         myPropertiesDelta = Collections.EMPTY_MAP;
       }
       SVNFileRevision revision =
           new SVNFileRevision(myPath, myRevision, myProperties, myPropertiesDelta);
       myFileRevisionsHandler.openRevision(revision);
       myProperties = null;
       myPropertiesDelta = null;
       myPath = null;
       myFileRevisionsHandler.applyTextDelta(myPath, null);
     }
     setDeltaProcessing(true);
   }
 }
 @Override
 public void startElement(
     final String uri, final String localName, final String qName, final Attributes attributes)
     throws SAXException {
   if ("testResults".equals(localName)) {
     // Check the version and output a warning if it differs
     final String version = attributes.getValue("version");
     if (version == null) {
       log.warn("No version specified in JTL file");
     } else {
       if (!version.equals(JTL_VERSION)) {
         log.warn("Parsing unknown JTL version: " + version);
       }
     }
   } else if ("sample".equals(localName) || "httpSample".equals(localName)) {
     // Get the label
     String label = attributes.getValue("lb");
     if ((label == null) || (label.length() == 0)) {
       label = "null";
     }
     SamplerImpl sampler = (SamplerImpl) samplerMap.get(label);
     if (sampler == null) {
       sampler = new SamplerImpl(label);
       samplerMap.put(label, sampler);
     }
     final long sampleTime = getLongAttribute(attributes, "t");
     final long startTime = getLongAttribute(attributes, "ts");
     final boolean pass = getBooleanAttribute(attributes, "s");
     sampler.addSample(startTime, sampleTime, pass);
     totalSampler.addSample(startTime, sampleTime, pass);
   }
 }
    public void init(String name, Attributes atts) {

      logger.log(LogService.LOG_DEBUG, "Here is IconHandler:init()"); // $NON-NLS-1$
      super.init(name, atts);
      String icon_resource_val = atts.getValue(RESOURCE);
      if (icon_resource_val == null) {
        _isParsedDataValid = false;
        logger.log(
            LogService.LOG_ERROR,
            NLS.bind(
                MetaTypeMsg.MISSING_ATTRIBUTE,
                new Object[] {
                  RESOURCE,
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
        return;
      }

      String icon_size_val = atts.getValue(SIZE);
      if (icon_size_val == null) {
        // Not a problem, because SIZE is an optional attribute.
        icon_size_val = "0"; // $NON-NLS-1$
      } else if (icon_size_val.equalsIgnoreCase("")) { // $NON-NLS-1$
        icon_size_val = "0"; // $NON-NLS-1$
      }

      _icon = new Icon(icon_resource_val, Integer.parseInt(icon_size_val), _dp_bundle);
    }
示例#4
0
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      if (qName.equals("rdf:RDF")) {
        isRoot = false;
      } else if (qName.equals("rss") && attributes.getValue(0).equals("2.0")) {
        isRoot = false;
      } else if (isRoot) {
        throw new SAXException("It is a form of the RSS that is not supported.");
      }

      if (uri.startsWith(RDF_CALENDAR_NAMESPACE)) {
        qName = localName;
        if (qName.equals("Vcalendar")) {
          // xml.write("BEGIN:VCALENDAR\n");
        } else if (qName.equals("Vevent")) {
          xml.write("BEGIN:VEVENT\n");
          rrule = new StringBuffer();
          qNameList.clear();
        } else if (qName.equals("url")) {
          urlAttr = attributes.getValue(0);
        } else if (qName.equals("dtstart")) {
          parentTag = qName;
        } else if (qName.equals("dtend")) {
          parentTag = qName;
        } else if (qName.equals("dtstamp")) {
          parentTag = qName;
        }
      }
      // tagStack.add(qName);
      buf.reset();
      qNameList.add(qName);
      isMixed = false;
    }
示例#5
0
 private Charger createCharger(Attributes atts) {
   Id<Charger> id = Id.create(atts.getValue("id"), Charger.class);
   Link link = links.get(Id.createLinkId(atts.getValue("link")));
   double power_kW = ReaderUtils.getDouble(atts, "power", DEFAULT_CHARGER_POWER_kW);
   int plugs = ReaderUtils.getInt(atts, "capacity", DEFAULT_CHARGER_CAPACITY);
   return new ChargerImpl(id, power_kW * EvUnitConversions.W_PER_kW, plugs, link);
 }
 @Override
 public void startElement(String uri, String localName, String qName, Attributes attributes)
     throws SAXException {
   super.startElement(uri, localName, qName, attributes);
   if (localName.equals("repo")) {
     String pk = attributes.getValue("", "pubkey");
     if (pk != null) pubkey = pk;
   } else if (localName.equals("application") && curapp == null) {
     curapp = new DB.App();
     curapp.detail_Populated = true;
     Bundle progressData = createProgressData(repo.address);
     progressCounter++;
     progressListener.onProgress(
         new ProgressListener.Event(
             RepoXMLHandler.PROGRESS_TYPE_PROCESS_XML,
             progressCounter,
             totalAppCount,
             progressData));
   } else if (localName.equals("package") && curapp != null && curapk == null) {
     curapk = new DB.Apk();
     curapk.id = curapp.id;
     curapk.repo = repo.id;
     hashType = null;
   } else if (localName.equals("hash") && curapk != null) {
     hashType = attributes.getValue("", "type");
   }
   curchars.setLength(0);
 }
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {

    isReachablesElement = "Reachables".equals(qName);

    if (isReachablesElement || !isLocalViewsAttributeName) {

      isLocalViewsAttributeName = "Views".equals(attributes.getValue("Name"));
    }

    if (isLocalViewsAttributeName) {

      isSetElement = "Set".equals(qName);

      isEntryElement = "Entry".equals(qName);

      String valueAttribute;

      if (isSetElement) {

        valueAttribute = attributes.getValue("Agent");

        sets.add(new Set(valueAttribute));
      }

      if (isEntryElement) {

        valueAttribute = attributes.getValue("Data");

        entres.add(new Entry(valueAttribute));
      }
    }
  }
示例#8
0
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
        throws SAXException {
      System.out.println("::XMLParser::startElement::" + qName + ":" + atts);
      if (qName.equalsIgnoreCase(TAG_DOC)) {

        mDoc = true;
        mWikiDoc = new WikipediaDocument();

        String id = atts.getValue("id");
        if (id != null && id.trim().length() > 0) {
          mWikiDoc.setId(Integer.parseInt(id));
        }
        String url = atts.getValue("url");
        if (url != null && url.trim().length() > 0) {
          mWikiDoc.setWikilink(url);
        }
        String title = atts.getValue("title");
        if (title != null && title.trim().length() > 0) {
          mWikiDoc.setTitle(title);
        }
        String timestamp = atts.getValue("timestamp");
        if (timestamp != null && timestamp.trim().length() > 0) {
          mWikiDoc.setTimestamp(timestamp);
        }
      }
    }
示例#9
0
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser parser)
      throws SAXException {
    parser.startElementBuilder(localName, attrs);

    String id = attrs.getValue("id");
    String name = attrs.getValue("name");
    String packageName = attrs.getValue("http://www.jboss.org/drools", "packageName");

    RuleFlowProcess process = new RuleFlowProcess();
    process.setAutoComplete(true);
    process.setId(id);
    if (name == null) {
      name = id;
    }
    process.setName(name);
    process.setType("RuleFlow");
    if (packageName == null) {
      packageName = "org.drools.bpmn2";
    }
    process.setPackageName(packageName);

    ((ProcessBuildData) parser.getData()).setProcess(process);
    return process;
  }
示例#10
0
  @Override
  void startElement(String qName, Attributes attributes) throws SAXException {

    elementStack.push(qName);

    switch (QNAME.valueOf(qName)) {
      case candles:
        CandleGraph candleGraph = new CandleGraph();
        candleGraph.setPeriod(Integer.valueOf(attributes.getValue("period")));
        candleGraph.setStatus(CandleStatus.getFromValue(attributes.getValue("status")));
        candleGraph.setBoard(attributes.getValue("board"));
        candleGraph.setSeccode(attributes.getValue("seccode"));
        objectStack.push(candleGraph);
        break;

      case candle:
        Candle candle = new Candle();
        candle.setDate(Utils.parseDate(attributes.getValue("date")));
        candle.setOpen(Double.valueOf(attributes.getValue("open")));
        candle.setHigh(Double.valueOf(attributes.getValue("high")));
        candle.setLow(Double.valueOf(attributes.getValue("low")));
        candle.setClose(Double.valueOf(attributes.getValue("close")));
        candle.setVolume(Integer.valueOf(attributes.getValue("volume")));
        String oi = attributes.getValue("oi");
        if (oi != null) {
          candle.setOi(Integer.valueOf(oi));
        }
        objectStack.peek().getCandles().add(candle);
        break;
      default:
        break;
    }
  }
 private void startLeg(final Attributes atts) {
   this.currleg =
       this.currplan.createAndAddLeg(atts.getValue("mode").toLowerCase(Locale.ROOT).intern());
   this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time")));
   this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time")));
   this.currleg.setArrivalTime(Time.parseTime(atts.getValue("arr_time")));
 }
示例#12
0
    private String getAttribute(Attributes atts, String name) {
      for (int i = 0; i < atts.getLength(); i++) {
        if (atts.getLocalName(i).equals(name)) return atts.getValue(i);
      }

      throw new RuntimeException(String.format("No '%s' attribute present.", name));
    }
示例#13
0
 public void startElement(String s, String s1, String s2, Attributes attributes) {
   int i = excludeList.indexOf("," + s2 + ",");
   if (i >= 0) {
     inExcludeElement = true;
     return;
   }
   if (s2.equals("process")) {
     if (process_element_seen) {
       inDuplicateProcessElement = true;
       return;
     }
     process_element_seen = true;
   }
   if (inExcludeElement || inDuplicateProcessElement) {
     return;
   }
   if (SunOneMonitor.isElementInMakeUniqueList(s2)) {
     String s3 = process_uniqueCounter(s2, attributes);
     formulaEngine.registerElementForDerivedCounter(s3);
     return;
   }
   formulaEngine.registerElementForDerivedCounter(s2);
   writer.startElement("object name=\"" + s2 + "\"");
   int j = attributes.getLength();
   for (int k = 0; k < j; k++) {
     String s4 = attributes.getLocalName(k);
     String s5 = attributes.getValue(k);
     String s6 = s4 + "+" + s5;
     writer.emptyElement("counter name=\"" + s4 + "\" id=\"" + s6 + "\"");
   }
 }
示例#14
0
  private String process_uniqueCounter(String s, Attributes attributes) {
    String s1 = null;
    String s2 = SunOneMonitor.getAttrForUniqueCounter(s);
    int i = attributes.getLength();
    int j = 0;
    do {
      if (j >= i) {
        break;
      }
      String s3 = attributes.getLocalName(j);
      if (s3.equals(s2)) {
        s1 = s + "@" + s2 + "-" + attributes.getValue(j);
        break;
      }
      j++;
    } while (true);
    if (s1 == null) {
      s1 = s;
    }
    writer.startElement("object name=\"" + s1 + "\"");
    for (int k = 0; k < i; k++) {
      String s4 = attributes.getLocalName(k);
      String s5 = attributes.getValue(k);
      String s6 = s4 + "+" + s5;
      if (!s4.equals(s2)) {
        writer.emptyElement("counter name=\"" + s4 + "\" id=\"" + s6 + "\"");
      }
    }

    return s1;
  }
示例#15
0
    /* (non-Javadoc)
     * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
     */
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      super.startElement(uri, localName, qName, attributes);
      for (DefaultHandler delegate : delegates) {
        delegate.startElement(uri, localName, qName, attributes);
      }
      boolean policy = false;
      if (localName != null && localName.equals(POLICY)) {
        policy = true;
      }
      if (qName != null && qName.endsWith(COLON_POLICY)) {
        policy = true;
      }
      if (!policy) {
        return;
      } else {
        hasPolicy = true;
      }
      int count = attributes.getLength();
      for (int i = 0; i < count; i++) {
        String value = attributes.getValue(i);
        String attrLocalName = attributes.getLocalName(i);
        String attrQName = attributes.getQName(i);

        if ((attrLocalName != null && attrLocalName.equals(ID))
            || (attrLocalName != null && attrQName.endsWith(COLON_ID))) {
          policies.add(attributes.getValue(i));
        }
      }
    }
示例#16
0
  /** Appends a start tag to charBuf. This method is used during the parsing of an XML Literal. */
  private void appendStartTag(String qName, Attributes attributes) {
    // Write start of start tag
    charBuf.append("<" + qName);

    // Write any new namespace prefix definitions
    for (Map.Entry<String, String> entry : newNamespaceMappings.entrySet()) {
      String prefix = entry.getKey();
      String namespace = entry.getValue();
      appendNamespaceDecl(charBuf, prefix, namespace);
    }

    // Write attributes
    int attCount = attributes.getLength();
    for (int i = 0; i < attCount; i++) {
      appendAttribute(charBuf, attributes.getQName(i), attributes.getValue(i));
    }

    // Write end of start tag
    charBuf.append(">");

    // Check for any used prefixes that are not
    // defined in the XML literal itself
    int colonIdx = qName.indexOf(':');
    String prefix = (colonIdx > 0) ? qName.substring(0, colonIdx) : "";

    if (!xmlLiteralPrefixes.contains(prefix) && !unknownPrefixesInXMLLiteral.contains(prefix)) {
      unknownPrefixesInXMLLiteral.add(prefix);
    }
  }
 public void startElement(String namespaceURI, String localName, String qName, Attributes attr) {
   String prefix = "";
   if (qName.lastIndexOf(":") != -1) prefix = qName.substring(0, qName.lastIndexOf(":"));
   String attrPrefix, attrQName;
   Attribute att;
   // if root element is null, then this first element will be the root element
   Element elem = new Element(localName, prefix, namespaceURI);
   for (int i = 0; i < attr.getLength(); i++) {
     attrQName = attr.getQName(i);
     if (attrQName.lastIndexOf(":") != -1)
       attrPrefix = attrQName.substring(0, attrQName.lastIndexOf(":"));
     else attrPrefix = "";
     att =
         new Attribute(
             attr.getLocalName(i),
             attr.getValue(i),
             Namespace.getNamespace(attrPrefix, attr.getURI(i)));
     elem.setAttribute(att);
   }
   if (rootElem == null) {
     rootElem = elem;
     curElem = rootElem;
   } else {
     curElem.addContent(elem);
     // set to the next element
     curElem = elem;
   }
 }
示例#18
0
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser xmlPackageReader)
      throws SAXException {
    xmlPackageReader.startElementBuilder(localName, attrs);

    WorkflowProcessImpl process = (WorkflowProcessImpl) xmlPackageReader.getParent();

    ActionNode actionNode = new ActionNode();

    final String name = attrs.getValue("name");
    emptyAttributeCheck(localName, "name", name, xmlPackageReader);
    actionNode.setName(name);

    final String id = attrs.getValue("id");
    emptyAttributeCheck(localName, "id", name, xmlPackageReader);
    actionNode.setId(new Long(id));

    process.addNode(actionNode);
    ((ProcessBuildData) xmlPackageReader.getData()).addNode(actionNode);

    return actionNode;
  }
示例#19
0
  static RenderTheme create(String elementName, Attributes attributes) {
    Integer version = null;
    int mapBackground = Color.WHITE;
    float baseStrokeWidth = 1;
    float baseTextSize = 1;

    for (int i = 0; i < attributes.getLength(); ++i) {
      String name = attributes.getLocalName(i);
      String value = attributes.getValue(i);

      if ("schemaLocation".equals(name)) {
        continue;
      } else if ("version".equals(name)) {
        version = Integer.valueOf(Integer.parseInt(value));
      } else if ("map-background".equals(name)) {
        mapBackground = Color.parseColor(value);
      } else if ("base-stroke-width".equals(name)) {
        baseStrokeWidth = Float.parseFloat(value);
      } else if ("base-text-size".equals(name)) {
        baseTextSize = Float.parseFloat(value);
      } else {
        RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
      }
    }

    validate(elementName, version, baseStrokeWidth, baseTextSize);
    return new RenderTheme(mapBackground, baseStrokeWidth, baseTextSize);
  }
 @Override
 public void startElement(
     final String uri, final String localName, final String qName, final Attributes attributes)
     throws SAXException {
   if (qName.equals("database")) {
     stack.push(new Object());
     if (StringUtils.isNotBlank(attributes.getValue("package"))) {
       destinationPackage = new JavaPackage(attributes.getValue("package"));
     }
   } else if (qName.equals("option")) {
     stack.push(new Option(attributes.getValue("key"), attributes.getValue("value")));
   } else if (qName.equals("table")) {
     stack.push(getTable(attributes));
   } else if (qName.equals("column")) {
     stack.push(getColumn(attributes));
   } else if (qName.equals("foreign-key")) {
     stack.push(getForeignKey(attributes));
   } else if (qName.equals("reference")) {
     stack.push(getReference(attributes));
   } else if (qName.equals("unique")) {
     stack.push(getIndex(attributes, IndexType.UNIQUE));
   } else if (qName.equals("index")) {
     stack.push(getIndex(attributes, IndexType.INDEX));
   } else if (qName.equals("unique-column") || qName.equals("index-column")) {
     stack.push(getIndexColumn(attributes));
   }
 }
示例#21
0
 public Object createObject(Attributes atts) {
   return new JROrigin(
       atts.getValue(JRXmlConstants.ATTRIBUTE_report),
       atts.getValue(JRXmlConstants.ATTRIBUTE_group),
       ((Byte) JRXmlConstants.getBandTypeMap().get(atts.getValue(JRXmlConstants.ATTRIBUTE_band)))
           .byteValue());
 }
示例#22
0
  private void setNSDeclAsAttr(Attributes atts) {
    Enumeration keys = nsMap.keys();
    if (keys.hasMoreElements()) {
      if (!(atts instanceof AttributesImpl)) {
        atts = new AttributesImpl(atts);
      }
      while (keys.hasMoreElements()) {
        String prefix = (String) keys.nextElement();
        String uri = (String) nsMap.get(prefix);
        if ("".equals(prefix)) {
          int index = atts.getIndex("xmlns");
          if (index == -1) {

            ((AttributesImpl) atts).addAttribute("", "", "xmlns", "CDATA", uri);
          } else {
            ((AttributesImpl) atts).setAttribute(index, "", "", "xmlns", "CDATA", uri);
          }
        } else {
          int index = atts.getIndex("xmlns:" + prefix);
          if (index == -1) {
            ((AttributesImpl) atts).addAttribute("", "", "xmlns:" + prefix, "CDATA", uri);
          } else {
            ((AttributesImpl) atts).setAttribute(index, "", "", "xmlns:" + prefix, "CDATA", uri);
          }
        }
      }
      nsMap.clear();
    }
  }
示例#23
0
  @SuppressWarnings("unchecked")
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser parser)
      throws SAXException {
    parser.startElementBuilder(localName, attrs);

    String id = attrs.getValue("id");
    String type = attrs.getValue("structureRef");
    if (type == null || type.trim().length() == 0) {
      type = "java.lang.Object";
    }

    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    Map<String, ItemDefinition> itemDefinitions =
        (Map<String, ItemDefinition>) buildData.getMetaData("ItemDefinitions");
    if (itemDefinitions == null) {
      itemDefinitions = new HashMap<String, ItemDefinition>();
      buildData.setMetaData("ItemDefinitions", itemDefinitions);
    }
    ItemDefinition itemDefinition = new ItemDefinition(id);
    itemDefinition.setStructureRef(type);
    itemDefinitions.put(id, itemDefinition);
    return itemDefinition;
  }
  private boolean checkAttributes(Attributes attributes) {
    String fileAttribute = attributes.getValue(FILE_ATTR);
    String urlAttribute = attributes.getValue(URL_ATTR);
    String resourceAttribute = attributes.getValue(RESOURCE_ATTR);

    int count = 0;

    if (!OptionHelper.isEmpty(fileAttribute)) {
      count++;
    }
    if (!OptionHelper.isEmpty(urlAttribute)) {
      count++;
    }
    if (!OptionHelper.isEmpty(resourceAttribute)) {
      count++;
    }

    if (count == 0) {
      addError("One of \"path\", \"resource\" or \"url\" attributes must be set.");
      return false;
    } else if (count > 1) {
      addError("Only one of \"file\", \"url\" or \"resource\" attributes should be set.");
      return false;
    } else if (count == 1) {
      return true;
    }
    throw new IllegalStateException("Count value [" + count + "] is not expected");
  }
示例#25
0
  public void startElement(String namespaceURI, String sName, String qName, Attributes attrs)
      throws SAXException {

    echoText();

    String eName = sName; // element name
    if ("".equals(eName)) {
      eName = qName; // not namespace-aware
    }

    if ("HTTPSamplerProxy".equals(eName)) {
      startBuffer();
    }

    emit("<" + eName);
    if (attrs != null) {
      for (int i = 0; i < attrs.getLength(); i++) {
        String aName = attrs.getLocalName(i); // Attr name
        if ("".equals(aName)) aName = attrs.getQName(i);

        emit(" ");
        if ("HTTPSamplerProxy".equals(eName) && "testname".equals(aName)) {
          this.testName = attrs.getValue(i);
        }
        emit(aName + "=\"" + attrs.getValue(i) + "\"");
      }
    }

    emit(">");
  }
  /** Retrieve and remove the namespaces declarations from the list of attributes. */
  private Attributes extractNamespaces(Attributes attrs) throws SAXException {
    AttributesImpl attrsOnly;
    String rawName;
    int i;
    int indexColon;
    String prefix;
    int length;

    if (attrs == null) {
      return null;
    }
    length = attrs.getLength();
    attrsOnly = new AttributesImpl(attrs);

    for (i = length - 1; i >= 0; --i) {
      rawName = attrsOnly.getQName(i);

      // We have to exclude the namespaces declarations from the attributes
      // Append only when the feature http://xml.org/sax/features/namespace-prefixes"
      // is TRUE
      if (rawName.startsWith("xmlns")) {
        if (rawName.length() == 5) {
          startPrefixMapping("", attrs.getValue(i));
          attrsOnly.removeAttribute(i);
        } else if (rawName.charAt(5) == ':') {
          startPrefixMapping(rawName.substring(6), attrs.getValue(i));
          attrsOnly.removeAttribute(i);
        }
      }
    }
    return attrsOnly;
  }
示例#27
0
  /** Instantiates an layout of the given class and sets its name. */
  public void begin(InterpretationContext ec, String localName, Attributes attributes) {
    // Let us forget about previous errors (in this object)
    inError = false;
    String errorMsg;
    String pattern = attributes.getValue(Action.PATTERN_ATTRIBUTE);
    String actionClass = attributes.getValue(Action.ACTION_CLASS_ATTRIBUTE);

    if (OptionHelper.isEmpty(pattern)) {
      inError = true;
      errorMsg = "No 'pattern' attribute in <newRule>";
      addError(errorMsg);
      return;
    }

    if (OptionHelper.isEmpty(actionClass)) {
      inError = true;
      errorMsg = "No 'actionClass' attribute in <newRule>";
      addError(errorMsg);
      return;
    }

    try {
      addInfo("About to add new Joran parsing rule [" + pattern + "," + actionClass + "].");
      ec.getJoranInterpreter().getRuleStore().addRule(new Pattern(pattern), actionClass);
    } catch (Exception oops) {
      inError = true;
      errorMsg = "Could not add new Joran parsing rule [" + pattern + "," + actionClass + "]";
      addError(errorMsg);
    }
  }
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {

      if (qName.equals(XML_NODE_SETTING)) {

        final String key = attributes.getValue(XML_ATTRIBUTE_ID);
        final String value = attributes.getValue(XML_ATTRIBUTE_VALUE);
        fSettings.put(key, value);

      } else if (qName.equals(XML_NODE_PROFILE)) {

        fName = attributes.getValue(XML_ATTRIBUTE_NAME);
        fKind = attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);

        fSettings = new HashMap<String, String>(200);

      } else if (qName.equals(XML_NODE_ROOT)) {

        fProfiles = new ArrayList<Profile>();
        try {
          fVersion = Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
        } catch (NumberFormatException ex) {
          throw new SAXException(ex);
        }
      }
    }
示例#29
0
  @SuppressWarnings("unchecked")
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser parser)
      throws SAXException {
    parser.startElementBuilder(localName, attrs);

    String id = attrs.getValue("id");
    String name = attrs.getValue("name");
    String implRef = attrs.getValue("implementationRef");

    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    List<Interface> interfaces = (List<Interface>) buildData.getMetaData("Interfaces");
    if (interfaces == null) {
      interfaces = new ArrayList<Interface>();
      buildData.setMetaData("Interfaces", interfaces);
    }
    Interface i = new Interface(id, name);
    if (implRef != null) {
      i.setImplementationRef(implRef);
    }
    interfaces.add(i);
    return i;
  }
 private void processAttributes(final Attributes atts) {
   // Check the root for model annotation information
   for (int i = 0; i < atts.getLength(); i++) {
     final String name = atts.getLocalName(i);
     final String value = atts.getValue(i);
     final String qname = atts.getQName(i);
     // The UUID associated with the model is the ModelAnnotation UUID
     // unless this is a VDB in which case it is the VirtualDatabase UUID
     if (name.equalsIgnoreCase(UUID_ATTRIBUTE_NAME) && !this.foundVdbStartElement)
       this.getXmiHeader().setUUID(value);
     else if (name.equalsIgnoreCase(DESCRIPTION_ATTRIBUTE_NAME))
       this.getXmiHeader().setDescription(value);
     else if (name.equalsIgnoreCase(PRODUCER_NAME_ATTRIBUTE_NAME))
       this.getXmiHeader().setProducerName(value);
     else if (name.equalsIgnoreCase(PRODUCER_VERSION_ATTRIBUTE_NAME))
       this.getXmiHeader().setProducerVersion(value);
     else if (name.equalsIgnoreCase(PRIMARY_URI_ATTRIBUTE_NAME))
       this.getXmiHeader().setPrimaryMetamodelURI(value);
     else if (name.equalsIgnoreCase(MODEL_TYPE_ATTRIBUTE_NAME))
       this.getXmiHeader().setModelType(value);
     else if (name.equalsIgnoreCase(MODEL_NAMESPACE_URI))
       this.getXmiHeader().setModelNamespaceUri(value);
     else if (name.equalsIgnoreCase(VISIBLE_ATTRIBUTE_NAME)) this.getXmiHeader().setVisible(value);
     else if (qname.equalsIgnoreCase(XMI_VERSION_0020_ATTRIBUTE_NAME))
       this.getXmiHeader().setXmiVersion(value);
     else if (qname.equalsIgnoreCase(XMI_VERSION_0011_ATTRIBUTE_NAME))
       this.getXmiHeader().setXmiVersion(value);
   }
 }