Example #1
0
 @Override
 public void characters(char ch[], int start, int length) {
   if (inScaleMax == true) {
     rule.scaleMax = Long.parseLong(new String(ch, start, length));
   } else if (inScaleMin == true) {
     rule.scaleMin = Long.parseLong(new String(ch, start, length));
   }
 }
Example #2
0
 @Override
 public void endElement(String uri, String name, String qName) {
   if (inRule && qName.equals("rule")) {
     if (hadLine) {
       style.add(
           rule.cond, rule.conditions, new LinePrototype(rule.line, rule.scaleMax, rule.scaleMin));
     }
     if (hadLineMod) {
       style.add(
           rule.cond,
           rule.conditions,
           new LinemodPrototype(rule.linemod, rule.scaleMax, rule.scaleMin));
     }
     if (hadIcon) {
       style.add(
           rule.cond, rule.conditions, new IconPrototype(rule.icon, rule.scaleMax, rule.scaleMin));
     }
     if (hadArea) {
       style.add(
           rule.cond, rule.conditions, new AreaPrototype(rule.area, rule.scaleMax, rule.scaleMin));
     }
     inRule = false;
     hadLine = hadLineMod = hadIcon = hadArea = false;
     rule.init();
   } else if (inCondition && qName.equals("condition")) {
     inCondition = false;
   } else if (inLine && qName.equals("line")) {
     inLine = false;
   } else if (inLineMod && qName.equals("linemod")) {
     inLineMod = false;
   } else if (inIcon && qName.equals("icon")) {
     inIcon = false;
   } else if (inArea && qName.equals("area")) {
     inArea = false;
   } else if (qName.equals("scale_max")) {
     inScaleMax = false;
   } else if (qName.equals("scale_min")) {
     inScaleMin = false;
   }
 }
Example #3
0
 public XmlStyleSourceHandler(XmlStyleSource style) {
   this.style = style;
   inDoc = inRule = inCondition = inLine = inIcon = inArea = false;
   rule.init();
 }
Example #4
0
 @Override
 public void startElement(String uri, String name, String qName, Attributes atts) {
   if (inDoc == true) {
     if (qName.equals("rule")) {
       inRule = true;
     } else if (qName.equals("rules")) {
       if (style.name == null) {
         style.name = atts.getValue("name");
       }
       if (style.shortdescription == null) {
         style.shortdescription = atts.getValue("shortdescription");
       }
     } else if (qName.equals("scale_max")) {
       inScaleMax = true;
     } else if (qName.equals("scale_min")) {
       inScaleMin = true;
     } else if (qName.equals("condition") && inRule) {
       inCondition = true;
       XmlCondition c = rule.cond;
       if (c.key != null) {
         if (rule.conditions == null) {
           rule.conditions = new LinkedList<XmlCondition>();
         }
         rule.conditions.add(new XmlCondition(rule.cond));
         c = new XmlCondition();
         rule.conditions.add(c);
       }
       for (int count = 0; count < atts.getLength(); count++) {
         if (atts.getQName(count).equals("k")) {
           c.key = atts.getValue(count);
         } else if (atts.getQName(count).equals("v")) {
           c.value = atts.getValue(count);
         } else if (atts.getQName(count).equals("b")) {
           c.boolValue = atts.getValue(count);
         } else {
           error(
               "The element \""
                   + qName
                   + "\" has unknown attribute \""
                   + atts.getQName(count)
                   + "\"!");
         }
       }
       if (c.key == null) {
         error("The condition has no key!");
       }
     } else if (qName.equals("line")) {
       hadLine = inLine = true;
       startElementLine(qName, atts, rule.line);
     } else if (qName.equals("linemod")) {
       hadLineMod = inLineMod = true;
       startElementLinemod(qName, atts, rule.linemod);
     } else if (qName.equals("icon")) {
       inIcon = true;
       for (int count = 0; count < atts.getLength(); count++) {
         if (atts.getQName(count).equals("src")) {
           IconReference icon = new IconReference(atts.getValue(count), style);
           hadIcon = (icon != null);
           rule.icon.icon = icon;
         } else if (atts.getQName(count).equals("annotate")) {
           rule.icon.annotate = Boolean.parseBoolean(atts.getValue(count));
         } else if (atts.getQName(count).equals("priority")) {
           rule.icon.priority = Integer.parseInt(atts.getValue(count));
         } else {
           error(
               "The element \""
                   + qName
                   + "\" has unknown attribute \""
                   + atts.getQName(count)
                   + "\"!");
         }
       }
     } else if (qName.equals("area")) {
       hadArea = inArea = true;
       for (int count = 0; count < atts.getLength(); count++) {
         if (atts.getQName(count).equals("colour")) {
           rule.area.color = convertColor(atts.getValue(count));
         } else if (atts.getQName(count).equals("closed")) {
           rule.area.closed = Boolean.parseBoolean(atts.getValue(count));
         } else if (atts.getQName(count).equals("priority")) {
           rule.area.priority = Integer.parseInt(atts.getValue(count));
         } else {
           error(
               "The element \""
                   + qName
                   + "\" has unknown attribute \""
                   + atts.getQName(count)
                   + "\"!");
         }
       }
     } else {
       error("The element \"" + qName + "\" is unknown!");
     }
   }
 }