Example usage for org.apache.commons.lang Entities HTML40

List of usage examples for org.apache.commons.lang Entities HTML40

Introduction

In this page you can find the example usage for org.apache.commons.lang Entities HTML40.

Prototype

Entities HTML40

To view the source code for org.apache.commons.lang Entities HTML40.

Click Source Link

Document

The set of entities supported by HTML 4.0.

Usage

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setNameFromHTML(String name) {
    if (name != null) {
        name = removeHTMLTags(name);//from   ww  w  . j  av  a  2 s .  c  o m
        this.name = Entities.HTML40.unescape(name);
    }
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setCommentsFromHTML(String comments) {
    if (comments != null) {
        comments = removeHTMLTags(comments);
        comments = Entities.HTML40.unescape(comments);
        comments = comments.replaceAll(",", "");
        comments = comments.replaceAll(" ", "");
        try {//from w w  w .j  a  va  2 s  .  c  om
            this.comments = Integer.parseInt(comments);
        } catch (Throwable e) {
            //e.printStackTrace();
        }
    }
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setCategoryFromHTML(String category) {
    if (category != null) {
        category = removeHTMLTags(category);
        this.category = Entities.HTML40.unescape(category).trim();
        /*int separator = this.category.indexOf(">");
                /*from www  .j a va2s .  co m*/
        if(separator != -1) {
           this.category = this.category.substring(separator+1).trim();
        }*/
    }
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setNbPeersFromHTML(String nbPeers) {
    if (nbPeers != null) {
        nbPeers = removeHTMLTags(nbPeers);
        String nbPeersS = Entities.HTML40.unescape(nbPeers);
        nbPeersS = nbPeersS.replaceAll(",", "");
        nbPeersS = nbPeersS.replaceAll(" ", "");
        try {/* ww w . j a v a  2 s.  com*/
            this.nbPeers = Integer.parseInt(nbPeersS);
        } catch (Throwable e) {
            //this.nbPeers = 0;
            //e.printStackTrace();
        }
    }
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setNbSeedsFromHTML(String nbSeeds) {
    if (nbSeeds != null) {
        nbSeeds = removeHTMLTags(nbSeeds);
        String nbSeedsS = Entities.HTML40.unescape(nbSeeds);
        nbSeedsS = nbSeedsS.replaceAll(",", "");
        nbSeedsS = nbSeedsS.replaceAll(" ", "");
        try {/* ww  w . j av a 2s.c o m*/
            this.nbSeeds = Integer.parseInt(nbSeedsS);
        } catch (Throwable e) {
            //this.nbSeeds = 0;
            //e.printStackTrace();
        }
    }
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setNbSuperSeedsFromHTML(String nbSuperSeeds) {
    if (nbSuperSeeds != null) {
        nbSuperSeeds = removeHTMLTags(nbSuperSeeds);
        String nbSuperSeedsS = Entities.HTML40.unescape(nbSuperSeeds);
        nbSuperSeedsS = nbSuperSeedsS.replaceAll(",", "");
        nbSuperSeedsS = nbSuperSeedsS.replaceAll(" ", "");
        try {/* w w  w.j  a v a 2s  .c  om*/
            this.nbSuperSeeds = Integer.parseInt(nbSuperSeedsS);
        } catch (Throwable e) {
            //this.nbSeeds = 0;
            //e.printStackTrace();
        }
    }
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setPublishedDateFromHTML(String publishedDate) {
    if (publishedDate != null) {
        publishedDate = removeHTMLTags(publishedDate);
        String publishedDateS = Entities.HTML40.unescape(publishedDate).replace((char) 160, (char) 32);
        this.publishedDate = dateParser.parseDate(publishedDateS);
    }//from w w w  . j a va 2s . c  o m
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setSizeFromHTML(String size) {
    if (size != null) {
        size = removeHTMLTags(size);/*from   ww w .j  a va2 s . c o  m*/
        String sizeS = Entities.HTML40.unescape(size).replace((char) 160, (char) 32);
        sizeS = sizeS.replaceAll("<[^>]+>", " ");
        //Add a space between the digits and unit if there is none
        sizeS = sizeS.replaceFirst("(\\d)([a-zA-Z])", "$1 $2");
        try {
            StringTokenizer st = new StringTokenizer(sizeS, " ");
            double base = Double.parseDouble(st.nextToken());
            String unit = "b";
            try {
                unit = st.nextToken().toLowerCase();
            } catch (Throwable e) {
                //No unit
            }
            long multiplier = 1;
            long KB_UNIT = 1024;
            long KIB_UNIT = 1024;
            if ("mb".equals(unit)) {
                multiplier = KB_UNIT * KB_UNIT;
            } else if ("mib".equals(unit)) {
                multiplier = KIB_UNIT * KIB_UNIT;
            } else if ("m".equals(unit)) {
                multiplier = KIB_UNIT * KIB_UNIT;
            } else if ("gb".equals(unit)) {
                multiplier = KB_UNIT * KB_UNIT * KB_UNIT;
            } else if ("gib".equals(unit)) {
                multiplier = KIB_UNIT * KIB_UNIT * KIB_UNIT;
            } else if ("g".equals(unit)) {
                multiplier = KIB_UNIT * KIB_UNIT * KIB_UNIT;
            } else if ("kb".equals(unit)) {
                multiplier = KB_UNIT;
            } else if ("kib".equals(unit)) {
                multiplier = KIB_UNIT;
            } else if ("k".equals(unit)) {
                multiplier = KIB_UNIT;
            }

            this.size = (long) (base * multiplier);
        } catch (Throwable e) {
            //e.printStackTrace();
        }
    }
}

From source file:com.aelitis.azureus.core.metasearch.Result.java

protected static final String unescapeEntities(String input) {
    if (input == null) {
        return (null);
    }// w w  w  .  j  ava  2 s  .  com
    return (Entities.HTML40.unescape(input));
}

From source file:com.aelitis.azureus.core.metasearch.impl.web.WebResult.java

public void setVotesFromHTML(String votes_str) {
    if (votes_str != null) {
        votes_str = removeHTMLTags(votes_str);
        votes_str = Entities.HTML40.unescape(votes_str);
        votes_str = votes_str.replaceAll(",", "");
        votes_str = votes_str.replaceAll(" ", "");
        try {//from w  w w. j a v  a2s .  c o m
            this.votes = Integer.parseInt(votes_str);
        } catch (Throwable e) {
            //e.printStackTrace();
        }
    }
}