Example usage for org.jdom2 Element getValue

List of usage examples for org.jdom2 Element getValue

Introduction

In this page you can find the example usage for org.jdom2 Element getValue.

Prototype

@Override
public String getValue() 

Source Link

Document

Returns the XPath 1.0 string value of this element, which is the complete, ordered content of all text node descendants of this element (i.e. the text that's left after all references are resolved and all other markup is stripped out.)

Usage

From source file:pdf2xml.TopComparator.java

License:Open Source License

public static Text_Element getTextElement(Element text, List<Font> fonts) {
    String value = text.getValue().trim();

    int top = Integer.parseInt(text.getAttribute("top").getValue());
    int left = Integer.parseInt(text.getAttribute("left").getValue());
    int width = Integer.parseInt(text.getAttribute("width").getValue());
    int height = Integer.parseInt(text.getAttribute("height").getValue());
    int font = Integer.parseInt(text.getAttribute("font").getValue());

    Type typ = Type.NUMBER;
    try {//from   ww  w .j a va  2  s . c  o m
        Integer.parseInt(value);
        Float.parseFloat(value);
    } catch (NumberFormatException nfe) {
        typ = Type.TEXT;
    }

    List<Element> bold_elements = text.getChildren("b");
    List<Element> italic_elements = text.getChildren("i");

    Style style;
    if (bold_elements.size() > 0) {
        if (italic_elements.size() > 0) {
            style = Style.BOLD_ITALIC;
        } else {
            style = Style.BOLD;
        }
    } else if (italic_elements.size() > 0) {
        style = Style.ITALIC;
    } else {
        style = Style.NORMAL;
    }

    // This is a hack, but we need access to the font specs to know the size
    int font_size = fonts.get(font).size;

    return new Text_Element(value, top, left, width, height, font, font_size, style, typ);

}

From source file:practica1edd.Interfaz.java

public Interfaz() throws IOException {

        super("Scrabble");

        String fichas = "AAAAAAAAAAAA" + "BB" + "CCCC" + "DDDDD" + "EEEEEEEEEEEE" + "F" + "GG" + "HH" + "IIIIII"
                + "J" + "LLLL" + "MM" + "NNNNN" + "" + "OOOOOOOOO" + "PP" + "Q" + "RRRRR" + "SSSSSS" + "TTTT"
                + "UUUUU" + "V" + "X" + "Y" + "Z";

        Random rands = new Random();

        for (int i = 0; i < 95; i++) {
            String auxa, auxb;//from w ww.  j  ava 2 s.  c  om

            int a = rands.nextInt(fichas.length()) + 1;
            String aux3 = "" + fichas.charAt(a - 1);
            cola.agregar(aux3);
            auxa = fichas.substring(0, a - 1);
            auxb = fichas.substring(a);
            fichas = auxa + auxb;

        }

        this.setVisible(false);

        JButton Leer = new JButton();
        JButton Jugar = new JButton();

        Leer.setText("Leer Archivo");
        Leer.setBounds(100, 100, 150, 100);

        Jugar.setText("Jugar");
        Jugar.setBounds(400, 100, 150, 100);

        Jugar.addActionListener(new ActionListener() { // clase interna annima

            // terminar la aplicacin cuando el usuario haga clic en elementoSalir
            public void actionPerformed(ActionEvent evento) {

                if (arch == false) {

                    JOptionPane.showMessageDialog(null, "No se ha cargo ningun archivo", "ERROR", 1, Ia);
                } else {
                    setVisible(false);

                    try {
                        matriz.mostrarGraphviz();
                    } catch (IOException ex) {
                        Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    Jugadores();
                }
            }

        }

        );

        Leer.addActionListener(new ActionListener() { // clase interna annima

            // terminar la aplicacin cuando el usuario haga clic en elementoSalir
            public void actionPerformed(ActionEvent evento)

            {

                String auxA = "";
                auxA = Archivo.dialogoSelectorImagen();
                File arp;

                String word = null;
                File archivo = new File(auxA);

                if (auxA == "") {
                    JOptionPane.showMessageDialog(null, "No se cargo ningun archivo", "ERROR", 1, Is);
                } else if (archivo.exists() == false) {

                    JOptionPane.showMessageDialog(null, "El Archivo no existe", "", 1, Ie);

                    System.out.println(word);

                } else {
                    arch = true;

                    int p = 0;
                    String dimension = "";
                    String dobles = "";
                    String triples = "";
                    String adiccionario = "";

                    SAXBuilder builder = new SAXBuilder(false);
                    try {
                        Document doc = builder.build(auxA);
                        Element raiz = doc.getRootElement();

                        List<Element> studentList = raiz.getChildren();

                        for (int temp = 0; temp < studentList.size(); temp++) {

                            Element student = studentList.get(temp);

                            if (student.getName() == "diccionario") {
                                adiccionario = student.getValue();

                            }

                            if (student.getName() == "dimension") {
                                dimension = student.getValue();
                            }

                            if (student.getName() == "dobles") {
                                dobles = student.getValue();

                            }

                            if (student.getName() == "triples") {
                                triples = student.getValue();
                            }

                        }

                    } catch (Exception e) {
                        System.out.println(e);
                    }
                    dimen = Integer.parseInt(dimension);
                    for (int i = 0; i < dimen; i++) {
                        for (int j = 0; j < dimen; j++) {
                            matriz.Agregar(j, i, "fondo");
                        }
                    }

                    String dic[] = adiccionario.split("\n");

                    for (String dia : dic) {
                        if (dia.equals("")) {
                        } else {
                            diccionario.agregar(dia);
                        }
                    }

                    String doble[] = dobles.split("\n");

                    int ppe = 0;

                    for (int pa = 0; pa < doble.length; pa++) {

                        if (ppe == 3) {

                            int m1 = Integer.parseInt(doble[pa - 1]);
                            int m2 = Integer.parseInt(doble[pa]);
                            matriz.modificar(m1, m2, "doble");

                            ppe = 0;
                        } else {
                            ppe = ppe + 1;
                        }
                    }

                    String triple[] = triples.split("\n");

                    ppe = 0;

                    for (int pa = 0; pa < triple.length; pa++) {

                        if (ppe == 3) {
                            int m1 = Integer.parseInt(triple[pa - 1]);
                            int m2 = Integer.parseInt(triple[pa]);
                            matriz.modificar(m1, m2, "triple");

                            ppe = 0;
                        } else {
                            ppe = ppe + 1;
                        }
                    }

                    try {
                        matriz.mostrarGraphviz();
                    } catch (IOException ex) {
                        Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    diccionario.mostrarGraph();

                }

            }

        });

        this.setLayout(null);
        this.add(Leer);
        this.add(Jugar);
        this.setBounds(600, 250, 670, 370);
        this.setResizable(false);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // if(b==false){
        //dialogo();
        // }

    }

From source file:prog2.Mainwindow.java

/**
 * @author Scott Samson//from ww w.  j av a2 s  .  c  o m
 * 
 * @param current
 * @param depth
 * @param boneRecs 
 */
public static void listChildren(Element current, int depth, Vector boneRecs) {
    List children = current.getChildren();
    Iterator iterator = children.iterator();
    BoneRec bone = new BoneRec();

    // get next file name
    if (current.getName().equals("uniqueid")) {
        bone.setUID(current.getValue().trim());
        String filename = "bonexml/" + current.getValue().trim() + ".xml";
        // add iterator to get elevation
        // switch on elevation to determine color
        // add color/name to points list ahead of xmlRead call
        //System.out.println(boneRecs.get(boneRecs.size()-1));
        try {
            bone.setPoints(xmlRead(filename));
            boneRecs.add(bone);
        } catch (Exception e) {
            System.out.println(e);
        }

    } else if (current.getName().equals("year")) {
        bone = (BoneRec) boneRecs.elementAt(boneRecs.size() - 1);
        bone.setYear(Integer.parseInt(current.getValue().trim()));
        boneRecs.setElementAt(bone, boneRecs.size() - 1);
    } else if (current.getName().equals("elevation")) {
        bone = (BoneRec) boneRecs.elementAt(boneRecs.size() - 1);
        bone.setElev(Double.parseDouble(current.getValue().trim()));
        boneRecs.setElementAt(bone, boneRecs.size() - 1);
    } else if (current.getName().equals("taxon")) {
        bone = (BoneRec) boneRecs.elementAt(boneRecs.size() - 1);
        bone.setTaxon(current.getValue().trim());
        boneRecs.setElementAt(bone, boneRecs.size() - 1);
    } else if (current.getName().equals("subelement")) {
        bone = (BoneRec) boneRecs.elementAt(boneRecs.size() - 1);
        bone.setSubElement(current.getValue().trim());
        boneRecs.setElementAt(bone, boneRecs.size() - 1);
    } else if (current.getName().equals("completeness")) {
        bone = (BoneRec) boneRecs.elementAt(boneRecs.size() - 1);
        bone.setCompleteness(current.getValue().trim());
        boneRecs.setElementAt(bone, boneRecs.size() - 1);
    } else if (current.getName().equals("gender")) {
        bone = (BoneRec) boneRecs.elementAt(boneRecs.size() - 1);
        bone.setGender(current.getValue().trim());
        boneRecs.setElementAt(bone, boneRecs.size() - 1);
    }

    //bone.print();
    // recursively process each child node
    while (iterator.hasNext()) {
        Element child = (Element) iterator.next();
        listChildren(child, depth + 1, boneRecs);
    }
}

From source file:prueba2spider.Lecturaxml.java

public void Lecturaxml(String xmlFile, Cola lo, ListaCD listaurl, Lecturaweb Leer1, ListaDE listadoble)
        throws JDOMException, IOException {

    SAXBuilder builder = new SAXBuilder();
    p = REGEX_HIPER_PATTER;/*www  .  java2 s.com*/
    Document document = (Document) builder.build(xmlFile);
    Element rootNode = document.getRootElement();
    List list = rootNode.getChildren();
    String configuracion[] = new String[3];

    for (int e = 0; e < list.size(); e++) {

        Element node = (Element) list.get(e);

        String configuracio = node.getValue();
        configuracion[e] = configuracio;

    }
    a = lo.Mostrarasociado();
    lo.MostrarNodo();
    String red = lo.MostrarNodo();
    lo.SacarNodo();
    Leer1.Lecturaweb(red, lo, listaurl, listadoble, a);
    maxthreads = Integer.parseInt(configuracion[0]);
    recursivity = Integer.parseInt(configuracion[1]);
    reindex = Integer.parseInt(configuracion[2]);
    lo.MostrarNodo();
    final CyclicBarrier barreraInicio = new CyclicBarrier(maxthreads + contador);
    final CyclicBarrier barreraFin = new CyclicBarrier(maxthreads + contador);

    for (int i = 0; i < maxthreads; i++) {
        Thread hilo = new Thread("h" + i) {
            @Override
            public void run() {

                try {
                    barreraInicio.await();
                    while (lo.Mostrarasociado() <= recursivity) {

                        System.out.println(lo.MostrarNodo());

                        if (lo.MostrarNodo() != null) {
                            System.out.println(this.getName() + lo.Mostrarasociado());
                            a = lo.Mostrarasociado();
                            lo.MostrarNodo();
                            String red = lo.MostrarNodo();
                            lo.SacarNodo();
                            Leer1.Lecturaweb(red, lo, listaurl, listadoble, a);

                        }

                    }

                    barreraFin.await();

                } catch (InterruptedException | BrokenBarrierException e) {
                }
            }
        };
        hilo.start();

    }

    try {

        barreraInicio.await();
        barreraFin.await();

    } catch (InterruptedException | BrokenBarrierException e) {
    }

    System.out.println(lo.ImprimirNodo());

    System.out.println(listaurl.mostrar());
    System.out.println(listadoble.mostrardesdeHead());

}

From source file:prueba2spider.Lecturaxmlparaurls.java

/**
*Metodo para leer la informacion de los urls de un archivo xml
* @author rafael,anderson/*from ww  w  .  j  a va2s  .com*/
* *@param xmlFile
* *@param lo
* *@param x
* *@param enlace
*/

public void Lecturaxmlparaurls(String xmlFile, Cola lo, String x, Nodo_para_cola enlace) {

    SAXBuilder builder = new SAXBuilder();

    try {

        Document document = (Document) builder.build(xmlFile);
        Element rootNode = document.getRootElement();
        List list = rootNode.getChildren();

        for (int i = 0; i < list.size(); i++) {

            Element node = (Element) list.get(i);

            lo.InsertarNodo(node.getValue(), 0);

        }

    } catch (IOException io) {

        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        ;
        System.out.println(jdomex.getMessage());
    }

}

From source file:ru.caramel.juniperbot.web.utils.FeedUtils.java

License:Open Source License

public static String getForeignValue(SyndEntry entry, String name) {
    if (entry == null) {
        return null;
    }/*from   w  ww  . ja v  a2s . c o  m*/
    Element element = getForeignValue(entry.getForeignMarkup(), name);
    return element != null ? element.getValue() : null;
}

From source file:ru.iteco.xmldoc.Component.java

License:Open Source License

public String getNlsBundle() {
    Element nlsEl = element.getChild("nlsbundle");
    if (nlsEl != null)
        return nlsEl.getValue();
    return "";
}

From source file:ru.iteco.xmldoc.Component.java

License:Open Source License

public String getPageStart() {
    Element pagesEl = element.getChild("pages");
    if (pagesEl != null) {
        Element startEl = pagesEl.getChild("start");
        if (startEl == null) {
            Element filterEl = pagesEl.getChild("filter");
            if (filterEl != null)
                startEl = filterEl.getChild("start");
        }/* w w w.  ja  va2s .  com*/
        if (startEl != null)
            return startEl.getValue();
    }
    return "";
}

From source file:ru.iteco.xmldoc.Component.java

License:Open Source License

public String getComponentClass() {
    Element clsEl = element.getChild("class");
    if (clsEl != null)
        return clsEl.getValue();
    return "";
}

From source file:starmap.StarXMLHandler.java

public void ReadChildren(Element current) {
    List items = current.getChildren();
    Element type = (Element) items.get(0);
    if (type.getName().equalsIgnoreCase("constellation")) {
        // get children of current node
        List constellations = items;
        Iterator iterator = constellations.iterator();

        //loop through all stars
        for (Object constellation : constellations) {
            //get star i and read its attributes
            Element node = (Element) constellation;
            List attributes = node.getChildren();
            constTmp = new Constellation();
            constTmp.ConstellationColor = randColor();
            for (Object attribute : attributes) {
                Element attr = (Element) attribute;
                String value = attr.getValue().substring(1, attr.getValue().length() - 1);
                constTmp.SetProperty(attr.getName(), value);
            }//w ww .  j av  a  2  s  . c o m
            ConstList.add(constTmp);
        }
        ConstellationRead = true;
    } else if (type.getName().equalsIgnoreCase("star")) {
        // get children of current node
        List stars = items;

        //loop through all stars
        for (Object star : stars) {
            //get star i and read its attributes
            Element node = (Element) star;
            List attributes = node.getChildren();
            starTmp = new Star();
            for (Object attribute : attributes) {
                Element attr = (Element) attribute;
                String value = attr.getValue().substring(1, attr.getValue().length() - 1);
                starTmp.SetProperty(attr.getName(), value);
            }
            StarList.add(starTmp);
            if (starTmp.common_name.length() > 0) {
                NamedStarMap.put(starTmp.common_name, starTmp);
            }
            if (starTmp.name.equalsIgnoreCase("???") == false) {
                NamedStarMap.put(starTmp.name, starTmp);
            }
        }
        StarRead = true;
    }
}