Example usage for java.lang Character toChars

List of usage examples for java.lang Character toChars

Introduction

In this page you can find the example usage for java.lang Character toChars.

Prototype

public static char[] toChars(int codePoint) 

Source Link

Document

Converts the specified character (Unicode code point) to its UTF-16 representation stored in a char array.

Usage

From source file:de.vandermeer.asciithemes.u8.U8_NumberingSchemes.java

/**
 * Numbering scheme using UTF Dingbat Negative Sanserif Circled Digit characters `-`.
 * //from  w w  w  . j  a v a  2 s . c o  m
 * ----
 *  item 1
 *  item 2
 *  item 3
 * ...
 *  item 10
 * ----
 * 
 * @return the line
 */
public static TA_Numbering numberDingbatNegativeSanserifCircledDigit() {
    return new TA_Numbering() {
        @Override
        public String getNumber(int number) {
            Validate.validState(0 < number && number < 11,
                    "numbering supported 0<number<11 - number was: " + number);
            return new String(Character.toChars(number + 10121));
        }

        @Override
        public int getMinNumber() {
            return 1;
        }

        @Override
        public int getMaxNumber() {
            return 10;
        }

        @Override
        public String getDescription() {
            return "numbering scheme using UTF Dingbat Negative Sanserif Circled Digit characters '-'";
        }
    };
}

From source file:spark.help.CustomNTriplesParser.java

protected int parseSubject(int c, StringBuilder sb) throws IOException, RDFParseException {
    //StringBuilder sb = new StringBuilder(100);

    // subject is either an uriref (<foo://bar>) or a nodeID (_:node1)
    if (c == '<') {
        // subject is an uriref

        c = parseUriRef(c, sb);//from ww  w.ja v a 2s  . com
        //subject = sb.toString();
        //subject = createURI(sb.toString());
    } else if (c == '_') {
        // subject is a bNode

        c = parseNodeID(c, sb);
        //subject = sb.toString();
        //subject = createBNode(sb.toString());
    } else if (c == -1) {
        throwEOFException();
    } else {
        reportFatalError("Expected '<' or '_', found: " + new String(Character.toChars(c)));
    }
    //System.out.println("subject = "+subject);
    return c;
}

From source file:org.eclipse.rdf4j.rio.ntriples.NTriplesParser.java

protected int parseSubject(int c) throws IOException, RDFParseException {
    StringBuilder sb = new StringBuilder(100);

    // subject is either an uriref (<foo://bar>) or a nodeID (_:node1)
    if (c == '<') {
        // subject is an uriref
        c = parseUriRef(c, sb);/*  ww w. j  av a2  s.c o  m*/
        subject = createURI(sb.toString());
    } else if (c == '_') {
        // subject is a bNode
        c = parseNodeID(c, sb);
        subject = createNode(sb.toString());
    } else if (c == -1) {
        throwEOFException();
    } else {
        reportFatalError("Expected '<' or '_', found: " + new String(Character.toChars(c)));
    }

    return c;
}

From source file:de.vandermeer.asciithemes.u8.U8_NumberingSchemes.java

/**
 * Numbering scheme using UTF Dingbat Sanserif Circled Digit characters `-`.
 * /*from  w  ww  .j  a v  a 2s . com*/
 * ----
 *  item 1
 * ? item 2
 *  item 3
 * ...
 *  item 10
 * ----
 * 
 * @return the line
 */
public static TA_Numbering numberDingbatSanserifCircledDigit() {
    return new TA_Numbering() {
        @Override
        public String getNumber(int number) {
            Validate.validState(0 < number && number < 11,
                    "numbering supported 0<number<11 - number was: " + number);
            return new String(Character.toChars(number + 10111));
        }

        @Override
        public int getMinNumber() {
            return 1;
        }

        @Override
        public int getMaxNumber() {
            return 10;
        }

        @Override
        public String getDescription() {
            return "numbering scheme using UTF Dingbat Sanserif Circled Digit characters '-'";
        }
    };
}

From source file:org.openrdf.rio.ntriples.NTriplesParser.java

protected int parseSubject(int c) throws IOException, RDFParseException {
    StringBuilder sb = new StringBuilder(100);

    // subject is either an uriref (<foo://bar>) or a nodeID (_:node1)
    if (c == '<') {
        // subject is an uriref
        c = parseUriRef(c, sb);/*  ww  w  . ja v a 2s. c om*/
        subject = createURI(sb.toString());
    } else if (c == '_') {
        // subject is a bNode
        c = parseNodeID(c, sb);
        subject = createBNode(sb.toString());
    } else if (c == -1) {
        throwEOFException();
    } else {
        reportFatalError("Expected '<' or '_', found: " + new String(Character.toChars(c)));
    }

    return c;
}

From source file:org.eclipse.rdf4j.rio.ntriples.NTriplesParser.java

protected int parsePredicate(int c) throws IOException, RDFParseException {
    StringBuilder sb = new StringBuilder(100);

    // predicate must be an uriref (<foo://bar>)
    if (c == '<') {
        // predicate is an uriref
        c = parseUriRef(c, sb);/*from   www . j a v a 2s  .c o m*/
        predicate = createURI(sb.toString());
    } else if (c == -1) {
        throwEOFException();
    } else {
        reportFatalError("Expected '<', found: " + new String(Character.toChars(c)));
    }

    return c;
}

From source file:spark.help.CustomNTriplesParser.java

protected int parsePredicate(int c, StringBuilder sb) throws IOException, RDFParseException {
    //StringBuilder sb = new StringBuilder(100);

    // predicate must be an uriref (<foo://bar>)
    if (c == '<') {
        // predicate is an uriref
        //predicate = "";
        c = parseUriRef(c, sb);//from   w ww.  j  a v  a2  s .  c o m
        //predicate = sb.toString();
        //predicate = createURI(sb.toString());
    } else if (c == -1) {
        throwEOFException();
    } else {
        reportFatalError("Expected '<', found: " + new String(Character.toChars(c)));
    }

    return c;
}

From source file:de.vandermeer.asciithemes.u8.U8_NumberingSchemes.java

/**
 * Numbering scheme using UTF Superscript characters `-?`.
 * //w ww  .  j  av  a 2s  .c o m
 * ----
 *  item 1
 *  item 2
 *  item 3
 * ...
 * ? item 9
 * ----
 * 
 * @return the line
 */
public static TA_Numbering numberSuperscript() {
    return new TA_Numbering() {
        @Override
        public String getNumber(int number) {
            Validate.validState(0 < number && number < 10,
                    "numbering supported 0<number<10 - number was: " + number);
            if (number == 1) {
                return new String(Character.toChars(number + 184));
            } else if (number > 3) {
                //4-10
                return new String(Character.toChars(number + 8304));
            } else {
                //2, 3
                return new String(Character.toChars(number + 176));
            }
        }

        @Override
        public int getMinNumber() {
            return 1;
        }

        @Override
        public int getMaxNumber() {
            return 9;
        }

        @Override
        public String getDescription() {
            return "numbering scheme using UTF Superscript characters '-?'";
        }
    };
}

From source file:org.openrdf.rio.turtle.TurtleParser.java

protected void parsePrefixID() throws IOException, RDFParseException, RDFHandlerException {
    skipWSC();//  www  .  java 2 s  .  c om

    // Read prefix ID (e.g. "rdf:" or ":")
    StringBuilder prefixID = new StringBuilder(8);

    while (true) {
        int c = readCodePoint();

        if (c == ':') {
            unread(c);
            break;
        } else if (TurtleUtil.isWhitespace(c)) {
            break;
        } else if (c == -1) {
            throwEOFException();
        }

        prefixID.append(Character.toChars(c));
    }

    skipWSC();

    verifyCharacterOrFail(readCodePoint(), ":");

    skipWSC();

    // Read the namespace URI
    IRI namespace = parseURI();

    // Store and report this namespace mapping
    String prefixStr = prefixID.toString();
    String namespaceStr = namespace.toString();

    setNamespace(prefixStr, namespaceStr);

    if (rdfHandler != null) {
        rdfHandler.handleNamespace(prefixStr, namespaceStr);
    }
}

From source file:org.eclipse.rdf4j.rio.ntriples.NTriplesParser.java

protected int parseObject(int c) throws IOException, RDFParseException {
    StringBuilder sb = getBuffer();

    // object is either an uriref (<foo://bar>), a nodeID (_:node1) or a
    // literal ("foo"-en or "1"^^<xsd:integer>).
    if (c == '<') {
        // object is an uriref
        c = parseUriRef(c, sb);//from   ww  w  .  ja  va2s.  c om
        object = createURI(sb.toString());
    } else if (c == '_') {
        // object is a bNode
        c = parseNodeID(c, sb);
        object = createNode(sb.toString());
    } else if (c == '"') {
        // object is a literal
        StringBuilder lang = getLanguageTagBuffer();
        StringBuilder datatype = getDatatypeUriBuffer();
        c = parseLiteral(c, sb, lang, datatype);
        object = createLiteral(sb.toString(), lang.toString(), datatype.toString());
    } else if (c == -1) {
        throwEOFException();
    } else {
        reportFatalError("Expected '<', '_' or '\"', found: " + new String(Character.toChars(c)) + "");
    }

    return c;
}