Example usage for java.text CharacterIterator DONE

List of usage examples for java.text CharacterIterator DONE

Introduction

In this page you can find the example usage for java.text CharacterIterator DONE.

Prototype

char DONE

To view the source code for java.text CharacterIterator DONE.

Click Source Link

Document

Constant that is returned when the iterator has reached either the end or the beginning of the text.

Usage

From source file:org.squale.welcom.outils.Util.java

public static String formatEmailList(final String st) {
    final StringBuffer sb = new StringBuffer();
    final StringCharacterIterator iter = new StringCharacterIterator(st);

    for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
        if (c != ' ') {
            sb.append(c);/*from  www. ja v a  2s  .c  om*/
        }
    }

    return sb.toString();
}

From source file:org.wso2.carbon.ui.taglibs.Breadcrumb.java

/**
 * replaces backslash with forward slash
 * @param str// w w w .j  a va 2 s . co  m
 * @return
 */
private static String replaceBacklash(String str) {
    StringBuilder result = new StringBuilder();
    StringCharacterIterator iterator = new StringCharacterIterator(str);
    char character = iterator.current();
    while (character != CharacterIterator.DONE) {
        if (character == '\\') {
            result.append("/");
        } else {
            result.append(character);
        }
        character = iterator.next();
    }
    return result.toString();
}

From source file:stg.utils.StringUtils.java

/**
 * Returns the iterator for all the tokens that are delimited by space.
 * @param text String to be tokenized.//ww  w .j  av a  2  s  .  c o  m
 * @return Iterator<String>
 */
public static Iterator<String> listTokens(String text) {
    return listTokens(text, ' ', CharacterIterator.DONE);
}

From source file:stg.utils.StringUtils.java

/**
 * Returns the iterator for all the tokens that are delimited by a separator char.
 * @param text String to be tokenized.//from www  .j  a  v  a 2 s.co m
 * @param separatorChar  to be used as the delimiter.
 * @return Iterator<String>
 */
public static Iterator<String> listTokens(String text, char separatorChar) {
    return listTokens(text, separatorChar, CharacterIterator.DONE);
}

From source file:ar.com.tadp.xml.rinzo.core.model.XMLNode.java

/**
 * Devuelve el String sobre el que est posicionado el cursor
 *//*from   w w w  .  j a  v  a  2s . c  o  m*/
public String getStringAt(int offset) {
    int relativeOffset = offset - this.offset;
    int start = 0, end = 0;
    String content = this.getContent();
    StringCharacterIterator iter = new StringCharacterIterator(content);
    char c;

    for (c = iter.setIndex(relativeOffset); c != CharacterIterator.DONE
            && this.isFullIdentifierPart(c); c = iter.previous()) {
    }
    start = this.isFullIdentifierPart(iter.current()) ? iter.getIndex() : iter.getIndex() + 1;

    for (c = iter.setIndex(relativeOffset); c != CharacterIterator.DONE
            && this.isFullIdentifierPart(c); c = iter.next()) {
    }
    end = iter.getIndex();

    return (start <= end) ? content.substring(start, end) : "";
}

From source file:XmlCharacters.java

/**
 * Determine if the supplied name is a valid XML Name.
 * //from   www.  jav a2s  .  c om
 * @param name the string being checked
 * @return true if the supplied name is indeed a valid XML Name, or false otherwise
 */
public static boolean isValidName(String name) {
    if (name == null || name.length() == 0)
        return false;
    CharacterIterator iter = new StringCharacterIterator(name);
    char c = iter.first();
    if (!isValidNameStart(c))
        return false;
    while (c != CharacterIterator.DONE) {
        if (!isValidName(c))
            return false;
        c = iter.next();
    }
    return true;
}

From source file:org.apache.fop.svg.AbstractFOPTextPainter.java

/**
 * Extract the raw text from an ACI./*  w  w w.  j  a  v a  2 s  .com*/
 * @param aci ACI to inspect
 * @return the extracted text
 */
protected String getText(AttributedCharacterIterator aci) {
    StringBuffer sb = new StringBuffer(aci.getEndIndex() - aci.getBeginIndex());
    for (char c = aci.first(); c != CharacterIterator.DONE; c = aci.next()) {
        sb.append(c);
    }
    return sb.toString();
}

From source file:HexFormat.java

/**
 * Parse a hex number into a Number object. Hexadecimal numbers may be
 * indicated with a leading character designation of '0x'. If up to 1 byte
 * is parsed, returns a Byte. If more than 1 and up to 2 bytes are parsed,
 * return a Short. If more than 2 and up to 4 bytes are parsed, return an
 * Integer. If more than 4 and up to 8 bytes are parsed, return a Long.
 * /*from   w  w w.  ja v a  2  s  .c om*/
 * @param text
 *            a hexadecimal number
 * @param parsePosition
 *            position to start parsing from
 * @return return an integer form of Number object if parse is successful;
 *         <CODE>null</CODE> otherwise
 * 
 * @since 1.0
 */
public Number parse(String text, ParsePosition parsePosition) {
    boolean skipWhitespace = true;
    int startIndex, nibbles;

    // remove whitespace
    StringCharacterIterator iter = new StringCharacterIterator(text, parsePosition.getIndex());
    for (char c = iter.current(); c != CharacterIterator.DONE; c = iter.next()) {
        if (skipWhitespace && Character.isWhitespace(c)) {
            // skip whitespace
            continue;
        }
        break;
    }

    // skip a leading hex designation of the characters '0x'
    if (text.regionMatches(iter.getIndex(), "0x", 0, 2)) {
        parsePosition.setIndex(iter.getIndex() + 2);
    } else {
        parsePosition.setIndex(iter.getIndex());
    }

    startIndex = parsePosition.getIndex();
    Number result = (Number) parseObject(text, parsePosition);

    if (result == null) {
        return (result);
    }

    nibbles = parsePosition.getIndex() - startIndex;
    if (nibbles <= 2) {
        result = new Byte(result.byteValue());
    } else if (nibbles <= 4) {
        result = new Short(result.shortValue());
    } else if (nibbles <= 8) {
        result = new Integer(result.intValue());
    } else if (nibbles <= 16) {
        result = new Long(result.longValue());
    }
    return (result);
}

From source file:org.semanticscience.narf.structures.parts.Sequence.java

/**
 * Create the set of nucleotides from a nucleic acid sequence string. A
 * mapping is constructed of the residue position of the nucleotides to the
 * nucleotides. The method enables the sequence to commence at an arbitrary
 * sequence position.//from   w ww. ja va 2  s. c om
 * 
 * @param aSequence
 *            sequence string
 * @param aStartingPosition
 *            the residue position of the first nucleotide
 * @return a mapping of the nucleotide residue positions to their respective
 *         nucleotide residue position
 * @throws InvalidSequenceException
 *             if any of the characters in the sequence string is not a
 *             valid residue identifier
 * @throws InvalidResidueException
 *             if the created nucleotide contains a residue exception
 * @since 1.6
 */
SortedMap<Integer, Nucleotide> makeNucleotides(String aSequence, int aStartingPosition)
        throws InvalidSequenceException, InvalidResidueException {
    //first make the sequence all upper case
    aSequence = aSequence.toUpperCase();
    if ((aSequence == null) || (aSequence.length() == 0)) {
        throw new InvalidSequenceException("The provided sequence has no characters.");
    }

    if (!this.checkStringSequence(aSequence)) {
        throw new InvalidSequenceException(
                "The inputted sequence has a invalid sequence character.\n" + aSequence + "\n");
    }

    SortedMap<Integer, Nucleotide> returnMe = new TreeMap<Integer, Nucleotide>();
    int currentPosition = aStartingPosition;
    CharacterIterator it = new StringCharacterIterator(aSequence);

    for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) {
        returnMe.put(currentPosition, new Nucleotide(currentPosition, String.valueOf(ch)));
        currentPosition++;
    }
    return returnMe;
}

From source file:XmlCharacters.java

/**
 * Determine if the supplied name is a valid XML NCName.
 * //www. j  a  v  a2  s .  c  o  m
 * @param name the string being checked
 * @return true if the supplied name is indeed a valid XML NCName, or false otherwise
 */
public static boolean isValidNcName(String name) {
    if (name == null || name.length() == 0)
        return false;
    CharacterIterator iter = new StringCharacterIterator(name);
    char c = iter.first();
    if (!isValidNcNameStart(c))
        return false;
    while (c != CharacterIterator.DONE) {
        if (!isValidNcName(c))
            return false;
        c = iter.next();
    }
    return true;
}