Package ca.odell.glazedlists.impl.adt.barcode2

Examples of ca.odell.glazedlists.impl.adt.barcode2.Element


        this.alwaysTransform = alwaysTransform;
    }

    @Override
    public final Source invoke(Source request) throws Exception {
        Element requestElement = getDocumentElement(request);
        Element responseElement = invokeInternal(requestElement);
        return responseElement != null ? new JDOMSource(responseElement) : null;
    }
View Full Code Here


        } else if(variable.contentEquals("LastChange")){
          
            SAXBuilder sxb = new SAXBuilder();
            try {
                Document document = sxb.build(new InputSource(new StringReader(value)));
                Element root = document.getRootElement();
                List<Element> children = root.getChildren();
                Iterator<Element> iterator = children.iterator();
                while (iterator.hasNext()) { //for each instanceID
                    Element current = iterator.next();
                    List<Element> childList = current.getChildren();
                    Iterator<Element> iterChild = childList.iterator();
                    Element child;
                    while (iterChild.hasNext()) {
                        child = iterChild.next();
                        String attributeValue = child.getAttributeValue("val");
//                        if (child.getName().equalsIgnoreCase("Volume")) {
//                            if (child.getAttributeValue("channel").equalsIgnoreCase("Master")) {
//                                volume = attributeValue;
//                            }
//                        } else if (child.getName().equalsIgnoreCase("Mute")) {
//                            muteState = Boolean.valueOf(attributeValue);
//                        } else if (child.getName().equalsIgnoreCase("PresetName")) {
//                            currentPreset = attributeValue;
//                        } else if (child.getName().equalsIgnoreCase("CurrentTrackDuration")) {
//                            trackDuration = attributeValue;
//                        } else if (child.getName().equalsIgnoreCase("AVTransportURI")) {
//                            String[] split = attributeValue.split("/");
//                            title = split[split.length - 1];
/*                        } else*/ if (child.getName().equalsIgnoreCase("TransportState")) {
                            if (attributeValue.contentEquals("STOPPED")) {
                                update.offer("device" + UDN + "/value/" + "renderer_stop.png");
                            } else if (attributeValue.contentEquals("PAUSED_PLAYBACK")) {
                                update.offer("device" + UDN + "/value/" + "renderer_pause.png");
                            } else if (attributeValue.contentEquals("PLAYING")) {
View Full Code Here

        this(new DefaultJDOMFactory());
    }

    @Override
    protected Object createNode(final String name) {
        final Element element = documentFactory.element(encodeNode(name));
        final Element parent = top();
        if (parent != null) {
            parent.addContent(element);
        }
        return element;
    }
View Full Code Here

     * Creates a config XML element for this class.
     */
    @Override
    public Element getAsElement()
    {
        Element keyEl = new Element(Element_Key);
        keyEl.setAttribute(Attr_Special, this.key.toString());
        keyEl.setAttribute("length", String.valueOf(this.keyWidth));
        return keyEl;
    }
View Full Code Here

    protected void loadData(Element data)
    {
        if (data == null)
            throw new IllegalArgumentException("cannot load data, data ist null");

        Element li = data.getChild(Element_LanguageInfo);
        name = li.getAttributeValue(Attr_Name);
        nativeName = li.getAttributeValue(Attr_Name);
        fontName = li.getAttributeValue(Attr_Font);
        fixedWidthFontName = li.getAttributeValue(Attr_FixedWidthFont);
        localeString.add(li.getAttributeValue(Attr_LocaleString));
        Element countriesEl = li.getChild(ELEMENT_COUNTRIES);
        if (countriesEl != null)
        {
            List<Element> countries = countriesEl.getChildren(ELEMENT_COUNTRY);
            String[] locSplit = localeString.get(0).split("-");
            if (countries != null && !countries.isEmpty() && locSplit != null && locSplit.length >= 1)
                for (Element country : countries)
                    localeString.add(locSplit[0] + "-" + country.getAttributeValue(ATTR_CODE));
        }
        org = new LinkedList<String>();
        trans = new LinkedList<String>();

        // check the translated keys
        Element transKeys = li.getChild(Show);
        if (transKeys != null)
            for (Element l : transKeys.getChildren(in))
            {
                org.add(l.getAttribute("org").getValue());
                trans.add(l.getAttribute("translate").getValue());
            }
View Full Code Here

        return localeString;
    }

    public Element getAsElement()
    {
        Element root = new Element("KeyboardConfiguration");
        Element li = new Element(Element_LanguageInfo);
        root.addContent(li);
        li.setAttribute(Attr_Name, name);
        li.setAttribute(Attr_NativeName, nativeName);
        li.setAttribute(Attr_Font, fontName);
        li.setAttribute(Attr_FixedWidthFont, fixedWidthFontName);
        li.setAttribute(Attr_LocaleString, localeString.isEmpty() ? "international" : localeString.get(0));
        if (localeString.size() > 1)
        {
            Element countries = new Element(ELEMENT_COUNTRIES);
            for (int i = 1; i < localeString.size(); i++)
            {
                String[] split = localeString.get(i).split("-");
                if (split != null && split.length == 2)
                {
                    Element country = new Element(ELEMENT_COUNTRY);
                    country.setAttribute(ATTR_CODE, split[1]);
                    countries.addContent(country);
                }
            }
            if (countries.getChildren().isEmpty())
                li.addContent(countries);
        }
        Element keyboard;

        // backwards Translation key
        if (org.size() > 0)
        {
            Element et = new Element(Show);
            li.setContent(et);
            for (int f = 0; f < org.size(); f++)
            {
                Element ett = new Element(in);
                et.addContent(ett);
                ett.setAttribute(new org.jdom2.Attribute("org", org.get(f)));
                ett.setAttribute(new org.jdom2.Attribute("translate", trans.get(f)));
            }
        }

        if (imeList.size() > 0)
            for (int f = 0; f < imeList.size(); f++)
            {
                Element et = new Element(IME);
                et.setAttribute(new org.jdom2.Attribute(IME, imeList.get(f)));
                li.addContent(et);
            }

        for (int i = 0; i < size(); i++)
        {
            keyboard = new Element(Element_Keyboard);
            li.addContent(keyboard);

            for (LinkedList<KeyboardKey> list : this.get(i))
            {
                Element line = new Element(Element_Line);
                keyboard.addContent(line);
                for (KeyboardKey kk : list)
                    line.addContent(kk.getAsElement());
            }
        }

        return root;
    }
View Full Code Here

            insertString(textField, keyboard, getContent(keyboard.getModifier()));
    }

    public Element getAsElement()
    {
        Element key = new Element(Element_Key);
        if (normalKey != null)
            key.setAttribute(Attr_Normal, normalKey);
        if (shiftKey != null)
            key.setAttribute(Attr_Shift, shiftKey);
        if (altKey != null)
            key.setAttribute(Attr_Alt, altKey);
        if (altshiftKey != null)
            key.setAttribute(Attr_AltGr, altshiftKey);
        return key;
    }
View Full Code Here

    public static void main(String[] args)
    {
        for (KeyboardLayout layout : getInstance().values())
            try
            {
                Element root = layout.getAsElement();
                File file = new File(layout.name + ".xml");
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                Format format = Format.getPrettyFormat();
                format.setEncoding("utf-16");
                format.setTextMode(Format.TextMode.TRIM);
View Full Code Here

    this.annotatorNames = annotatorNames;
  }

  public Collection<KnowtatorAnnotation> parse(URI knowtatorXML) throws JDOMException, IOException {

    Element annotationsElem = new SAXBuilder().build(knowtatorXML.toURL()).getRootElement();

    // parse <annotation> elements
    Set<String> ignoredAnnotators = new HashSet<String>();
    Map<String, KnowtatorAnnotation> annotations = new HashMap<String, KnowtatorAnnotation>();
    for (Element annotationElem : annotationsElem.getChildren("annotation")) {
      for (Element annotatorElem : this.getChild(annotationElem, "annotator")) {
        String annotatorName = annotatorElem.getText();
        if (!this.annotatorNames.contains(annotatorName)) {
          ignoredAnnotators.add(annotatorName);
        } else {
          for (Element mentionElem : this.getChild(annotationElem, "mention")) {
            for (String id : this.getAttributeValue(mentionElem, "id")) {
              KnowtatorAnnotation annotation = new KnowtatorAnnotation();
              annotation.id = id;
              annotations.put(id, annotation);
              List<Element> spanElems = annotationElem.getChildren("span");
              if (!spanElems.isEmpty()) {
                for (Element spannedTextElem : this.getChild(annotationElem, "spannedText")) {
                  annotation.spannedText = spannedTextElem.getText();
                }
                for (Element spanElem : spanElems) {
                  for (String startStr : this.getAttributeValue(spanElem, "start")) {
                    for (String endStr : this.getAttributeValue(spanElem, "end")) {
                      annotation.addSpan(Integer.parseInt(startStr), Integer.parseInt(endStr));
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    LOGGER.fine(String.format("Ignored annotators %s in %s", ignoredAnnotators, knowtatorXML));

    // parse <stringSlotMention> elements
    Map<String, Slot<String>> stringSlots = new HashMap<String, Slot<String>>();
    for (Element slotMentionElem : annotationsElem.getChildren("stringSlotMention")) {
      for (IdAndSlot<String> idAndSlot : this.parseSlotMention(
          slotMentionElem,
          "stringSlotMentionValue")) {
        stringSlots.put(idAndSlot.id, idAndSlot.slot);
      }
    }

    // parse <booleanSlotMention> elements
    Map<String, Slot<Boolean>> booleanSlots = new HashMap<String, Slot<Boolean>>();
    for (Element slotMentionElem : annotationsElem.getChildren("booleanSlotMention")) {
      for (IdAndSlot<String> idAndSlot : this.parseSlotMention(
          slotMentionElem,
          "booleanSlotMentionValue")) {
        Slot<String> slot = idAndSlot.slot;
        Boolean value = Boolean.parseBoolean(slot.value);
        booleanSlots.put(idAndSlot.id, new Slot<Boolean>(slot.name, value));
      }
    }

    // parse <complexSlotMention> elements
    Map<String, Slot<KnowtatorAnnotation>> mentionSlots = new HashMap<String, Slot<KnowtatorAnnotation>>();
    for (Element slotMentionElem : annotationsElem.getChildren("complexSlotMention")) {
      for (IdAndSlot<String> idAndSlot : this.parseSlotMention(
          slotMentionElem,
          "complexSlotMentionValue")) {
        Slot<String> slot = idAndSlot.slot;
        KnowtatorAnnotation mention = annotations.get(slot.value);
        if (mention != null) {
          mentionSlots.put(idAndSlot.id, new Slot<KnowtatorAnnotation>(slot.name, mention));
        }
      }
    }

    // parse <classMention> elements
    for (Element classMentionElem : annotationsElem.getChildren("classMention")) {
      for (String id : this.getAttributeValue(classMentionElem, "id")) {
        KnowtatorAnnotation annotation = annotations.get(id);
        if (annotation == null) {
          continue;
        }
View Full Code Here

    return annotations.values();
  }

  private Option<Element> getChild(final Element element, final String cname) {
    final Element child = element.getChild(cname);
    if (child == null) {
      String xml = this.xmlOutputter.outputString(element);
      LOGGER.warning(String.format("no %s for %s", cname, xml));
    }
    return new Option<Element>(child);
View Full Code Here

TOP

Related Classes of ca.odell.glazedlists.impl.adt.barcode2.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.