Java 类java.io.CharConversionException 实例源码

项目:GitHub    文件:UTF32ParseTest.java   
public void testSimpleEOFs() throws Exception
{
    // 2 spaces
    byte[] data = { 0x00, 0x00, 0x00, 0x20,
            0x00, 0x00, 0x00, 0x20
    };

    for (int len = 5; len <= 7; ++len) {
        JsonParser parser = FACTORY.createParser(ObjectReadContext.empty(), data, 0, len);
        try {
            parser.nextToken();
            fail("Should not pass");
        } catch (CharConversionException e) {
            verifyException(e, "Unexpected EOF");
            verifyException(e, "of a 4-byte UTF-32 char");
        }
        parser.close();
    }
}
项目:GitHub    文件:UTF32ParseTest.java   
public void testSimpleInvalidUTF32() throws Exception
{
    // 2 characters, space, then something beyond valid Unicode set
    byte[] data = {
            0x00,
            0x00,
            0x00,
            0x20,
            (byte) 0xFE,
            (byte) 0xFF,
            0x00,
            0x01
    };

    JsonParser parser = FACTORY.createParser(ObjectReadContext.empty(), data);

    try {
        parser.nextToken();
        fail("Should not pass");
    } catch (CharConversionException e) {
        verifyException(e, "Invalid UTF-32 character 0xfefe0001");
    }
    parser.close();
}
项目:incubator-netbeans    文件:NotificationImpl.java   
private JComponent createDetails(String text, ActionListener action) {
    try {
        text = (action == null ? "<html>" : "<html><a href=\"_blank\">") + XMLUtil.toElementContent(text); //NOI18N
    } catch (CharConversionException ex) {
        throw new IllegalArgumentException(ex);
    }
    if (null == action) {
        return new JLabel(text);
    }
    JButton btn = new JButton(text);
    btn.setFocusable(false);
    btn.setBorder(BorderFactory.createEmptyBorder());
    btn.setBorderPainted(false);
    btn.setFocusPainted(false);
    btn.setOpaque(false);
    btn.setContentAreaFilled(false);
    btn.addActionListener(action);
    btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
    if (c != null) {
        btn.setForeground(c);
    }
    return btn;
}
项目:incubator-netbeans    文件:TextDetail.java   
/**
 * Append part of line that is before matched text.
 *
 * @param text Buffer to append to.
 * @param prefixStart Line index of the first character to be displayed.
 * @param matchStart Line index of the matched text.
 * @param trim Skip leading whitespace characters.
 */
private void appendMarkedTextPrefix(StringBuilder text, int prefixStart,
        int matchStart, boolean trim) throws CharConversionException {
    int first = 0; // index of first non-whitespace character
    if (trim) {
        CharSequence lineText = txtDetail.getLineText();
        while (first < matchStart && lineText.charAt(first) <= '\u0020') {
            first++;
        }
    }
    if (prefixStart > 0 && first < prefixStart) {
        text.append(ELLIPSIS);
    }
    text.append(escape(txtDetail.getLineTextPart(
            Math.max(prefixStart, first), matchStart)));
}
项目:incubator-netbeans    文件:TextDetail.java   
/**
 * Append part of line that contains the matched text.
 *
 * @param text Buffer to append to.
 * @param matchStart Line index of the first character of the matched
 * text.
 * @param matchEnd Line index after the last character of the matched
 * text.
 * @param lineLength Lenght of the line.
 * @param detailLength Lengt of matched part.
 */
private void appendMarkedTextMatch(StringBuilder text, int matchStart,
        int matchEnd, int lineLength, int matchedLength)
        throws CharConversionException {

    text.append("<b>");  // NOI18N
    if (matchedLength > DETAIL_DISPLAY_LENGTH) {
        int off = (DETAIL_DISPLAY_LENGTH - ELLIPSIS.length()) / 2;
        text.append(escape(txtDetail.getLineTextPart(
                matchStart, matchStart + off)));
        text.append("</b>");
        text.append(ELLIPSIS);
        text.append("<b>");
        text.append(escape(txtDetail.getLineTextPart(
                matchEnd - off, matchEnd)));
    } else {
        text.append(escape(
                txtDetail.getLineTextPart(matchStart, matchEnd)));
    }
    int markEnd = matchStart + txtDetail.getMarkLength();
    text.append("</b>"); // NOI18N
    if (markEnd > lineLength) { // mark up to the text end?
        text.append(ELLIPSIS);
    }
}
项目:incubator-netbeans    文件:CustomizerComponentFactory.java   
public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
    String text;
    if (value == UIUtil.WAIT_VALUE) {
        text = UIUtil.WAIT_VALUE;
    } else if (value == INVALID_PLATFORM) {
        text = INVALID_PLATFORM;
        renderer.setHtml(true);
    } else {
        ModuleDependency md = (ModuleDependency) value;
        // XXX the following is wrong; spec requires additional logic:
        boolean bold = boldfaceApiModules && md.getModuleEntry().getPublicPackages().length > 0;
        boolean deprecated = md.getModuleEntry().isDeprecated();
        renderer.setHtml(bold || deprecated);
        String locName = md.getModuleEntry().getLocalizedName();
        text = locName;
        if (bold || deprecated) {
            try {
                text = "<html>" + (bold ? "<b>" : "") + (deprecated ? "<s>" : "") + XMLUtil.toElementContent(locName); // NOI18N
            } catch (CharConversionException e) {
                // forget it
            }
        }
    }
    return renderer.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus);
}
项目:incubator-netbeans    文件:ProjectsRootNode.java   
public @Override String getHtmlDisplayName() {
    String htmlName = getOriginal().getHtmlDisplayName();
    if (htmlName == null) {
        try {
            htmlName = XMLUtil.toElementContent(getOriginal().getDisplayName());
        } catch (CharConversionException ex) {
            // ignore
        }
    }
    if (htmlName == null) {
        return null;
    }
    if (files != null && files.iterator().hasNext()) {
        try {
            String annotatedMagic = files.iterator().next().getFileSystem().
                    getDecorator().annotateNameHtml(MAGIC, files);
            if (annotatedMagic != null) {
                htmlName = annotatedMagic.replace(MAGIC, htmlName);
            }
        } catch (FileStateInvalidException e) {
            LOG.log(Level.INFO, null, e);
        }
    }      
    return isMainAsync()? "<b>" + htmlName + "</b>" : htmlName;
}
项目:incubator-netbeans    文件:AdjustConfigurationPanel.java   
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    AnalyzerFactory a = (AnalyzerFactory) value;
    String text = SPIAccessor.ACCESSOR.getAnalyzerDisplayName(a);
    boolean isErroneous;
    synchronized (errors) {
        isErroneous = errors.containsKey(a);
    }
    if (isErroneous) {
        try {
            text = "<html><font color='ref'>" + XMLUtil.toElementContent(text);
        } catch (CharConversionException ex) {
            LOG.log(Level.FINE, null, ex);
        }
    }
    return super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus);
}
项目:incubator-netbeans    文件:BasicInfoPanel.java   
@Messages("ERR_Coord_breaks_pom=Error: Group Id or Artifact Id would invalidate Maven POM xml file.")
private boolean checkCoord(JTextField field) {
    String coord = field.getText();
    boolean result = false;
    try {
        String escaped = XMLUtil.toAttributeValue(coord);
        result = escaped.length() == coord.length() && coord.indexOf(">") == -1
                && coord.indexOf(" ") == -1;
    } catch (CharConversionException ex) {
        // ignore this one
    }
    if (result) {
        result = !containsMultiByte(coord);
    } else {
        category.setErrorMessage(ERR_Coord_breaks_pom());
    }

    if (result) {
        category.setErrorMessage(null);
    }

    return result;
}
项目:incubator-netbeans    文件:PlatformNode.java   
@Override
public String getHtmlDisplayName () {
    final Pair<String,JavaPlatform> platHolder = pp.getPlatform();
    if (platHolder == null) {
        return null;
    }
    final JavaPlatform jp = platHolder.second();
    if (jp == null || !jp.isValid()) {
        String displayName = this.getDisplayName();
        try {
            displayName = XMLUtil.toElementContent(displayName);
        } catch (CharConversionException ex) {
            // OK, no annotation in this case
            return null;
        }
        return "<font color=\"#A40000\">" + displayName + "</font>"; //NOI18N
    } else {
        return null;
    }
}
项目:incubator-netbeans    文件:BreadCrumbsNodeImpl.java   
static String escape(String s) {
    if (s != null) {
        //unescape unicode sequences first (would be better if Pretty would not print them, but that might be more difficult):
        Matcher matcher = UNICODE_SEQUENCE.matcher(s);

        if (matcher.find()) {
            StringBuilder result = new StringBuilder();
            int lastReplaceEnd = 0;
            do {
                result.append(s.substring(lastReplaceEnd, matcher.start()));
                int ch = Integer.parseInt(matcher.group(1), 16);
                result.append((char) ch);
                lastReplaceEnd = matcher.end();
            } while (matcher.find());
            result.append(s.substring(lastReplaceEnd));
            s = result.toString();
        }
        try {
            return XMLUtil.toAttributeValue(s);
        } catch (CharConversionException ex) {
        }
    }
    return null;
}
项目:incubator-netbeans    文件:Task.java   
@Override
public void perform() {
    if (!terminal().isVisibleInContainer()) {
    return ;
    }
    String newTitle = terminal().getTitle();
    if (terminal().isConnected() && newTitle != null) {
    String escaped;
    try {
        escaped = XMLUtil.toAttributeValue(newTitle);
    } catch (CharConversionException ex) {
        escaped = newTitle;
    }

    newTitle = "<html><b>" + escaped + "</b></html>";   // NOI18N
    }
    container().setTitle(terminal(), newTitle);
}
项目:incubator-netbeans    文件:DataEditorSupport.java   
@Override
protected String messageHtmlName() {
    if (! obj.isValid()) {
        return null;
    }

    String name = obj.getNodeDelegate().getHtmlDisplayName();
    if (name == null) {
        try {
            name = XMLUtil.toElementContent(obj.getNodeDelegate().getDisplayName());
        } catch (CharConversionException ex) {
            return null;
        }
    }

    return annotateName(name, true, isModified(), !obj.getPrimaryFile().canWrite());
}
项目:incubator-netbeans    文件:Utilities.java   
public static String target2String(TypeElement target) {
    final Name qualifiedName = target.getQualifiedName(); //#130759
    if (qualifiedName == null) {
        Logger.getLogger(Utilities.class.getName()).warning("Target qualified name could not be resolved."); //NOI18N
        return ""; //NOI18N
    } else {
        String qnString = qualifiedName.toString();
        if (qnString.length() == 0) {
            //probably an anonymous class
            qnString = target.asType().toString();
        }

        try {
            qnString = XMLUtil.toElementContent(qnString);
        } catch (CharConversionException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.FINE, null, ex);
        }

        return qnString;
    }
}
项目:incubator-netbeans    文件:RemotePlatformProvider.java   
private static void writeProperties(
        @NonNull final Map<String,String> props,
        @NonNull final Element element,
        @NonNull final Document doc) throws IOException {
    final Collection<String> sortedProps = new TreeSet<>(props.keySet());
    for (String name : sortedProps) {
        final String val = props.get(name);
        try {
            XMLUtil.toAttributeValue(name);
            XMLUtil.toAttributeValue(val);
            final Element propElement = doc.createElement(ELM_PROPERTY);
            propElement.setAttribute(ATTR_NAME,name);
            propElement.setAttribute(ATTR_VALUE,val);
            element.appendChild(propElement);
        } catch (CharConversionException e) {
            LOG.log(
                Level.WARNING,
                "Cannot store property: {0} value: {1}",       //NOI18N
                new Object[] {
                    name,
                    val
                });
        }
    }
}
项目:incubator-netbeans    文件:SQLEditorSupport.java   
@Override
protected String messageToolTip() {
    if (isConsole()) {
        DatabaseConnection dc = getDatabaseConnection();
        if (dc != null) {
            try {
                return String.format(
                        "<html>%s<br>%s<br>JDBC-URL: %s</html>",
                        XMLUtil.toAttributeValue(
                        getDataObject().getPrimaryFile().getName()),
                        XMLUtil.toAttributeValue(dc.getDisplayName()),
                        XMLUtil.toAttributeValue(dc.getDatabaseURL()));
            } catch (CharConversionException ex) {
                LOGGER.log(Level.WARNING, "", ex);
        return getDataObject().getPrimaryFile().getName();
            }
    } else {
            return getDataObject().getPrimaryFile().getName();
        }
    } else {
        return super.messageToolTip();
    }
}
项目:incubator-netbeans    文件:NotificationImpl.java   
private JComponent createDetails( String text, ActionListener action ) {
    if( null == action ) {
        return new JLabel(text);
    }
    try {
        text = "<html><u>" + XMLUtil.toElementContent(text); //NOI18N
    } catch( CharConversionException ex ) {
        throw new IllegalArgumentException(ex);
    }
    JButton btn = new JButton(text);
    btn.setFocusable(false);
    btn.setBorder(BorderFactory.createEmptyBorder());
    btn.setBorderPainted(false);
    btn.setFocusPainted(false);
    btn.setOpaque(false);
    btn.setContentAreaFilled(false);
    btn.addActionListener(action);
    btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
    if (c != null) {
        btn.setForeground(c);
    }
    return btn;
}
项目:incubator-netbeans    文件:HudsonJobBuildNode.java   
public HudsonJobBuildNode(HudsonJobBuild build) {
    super(makeChildren(build), Lookups.singleton(build));
    setName(Integer.toString(build.getNumber()));
    setDisplayName(NbBundle.getMessage(HudsonJobBuildNode.class, "HudsonJobBuildNode.displayName", build.getNumber()));
    Color effectiveColor;
    if (build.isBuilding()) {
        effectiveColor = build.getJob().getColor();
    } else {
        effectiveColor = Utilities.getColorForBuild(build);
    }
    try {
        htmlDisplayName = effectiveColor.colorizeDisplayName(XMLUtil.toElementContent(getDisplayName()));
    } catch (CharConversionException x) {
        htmlDisplayName = null;
    }
    setIconBaseWithExtension(effectiveColor.iconBase());
    this.build = build;
}
项目:tomcat7    文件:ServletOutputStream.java   
/**
 * Writes a <code>String</code> to the client, without a carriage
 * return-line feed (CRLF) character at the end.
 * 
 * @param s
 *            the <code>String</code> to send to the client
 * @exception IOException
 *                if an input or output exception occurred
 */
public void print(String s) throws IOException {
    if (s == null)
        s = "null";
    int len = s.length();
    for (int i = 0; i < len; i++) {
        char c = s.charAt(i);

        //
        // XXX NOTE: This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework. It must suffice until servlet output
        // streams properly encode their output.
        //
        if ((c & 0xff00) != 0) { // high order byte must be zero
            String errMsg = lStrings.getString("err.not_iso8859_1");
            Object[] errArgs = new Object[1];
            errArgs[0] = Character.valueOf(c);
            errMsg = MessageFormat.format(errMsg, errArgs);
            throw new CharConversionException(errMsg);
        }
        write(c);
    }
}
项目:lams    文件:ServletOutputStream.java   
/**
 * Writes a <code>String</code> to the client, 
 * without a carriage return-line feed (CRLF) 
 * character at the end.
 *
 *
 * @param s                       the <code>String</code> to send to the client
 *
 * @exception IOException         if an input or output exception occurred
 *
 */

public void print(String s) throws IOException {
    if (s==null) s="null";
    int len = s.length();
    for (int i = 0; i < len; i++) {
        char c = s.charAt (i);

        //
        // XXX NOTE:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        //
        if ((c & 0xff00) != 0) {        // high order byte must be zero
            String errMsg = lStrings.getString("err.not_iso8859_1");
            Object[] errArgs = new Object[1];
            errArgs[0] = Character.valueOf(c);
            errMsg = MessageFormat.format(errMsg, errArgs);
            throw new CharConversionException(errMsg);
        }
        write (c);
    }
}
项目:OpenJSharp    文件:XmlReader.java   
public int read(char buf [], int offset, int len) throws IOException {
    int i, c;

    if (instream == null)
        return -1;

    for (i = 0; i < len; i++) {
        if (start >= finish) {
            start = 0;
            finish = instream.read(buffer, 0, buffer.length);
            if (finish <= 0) {
                if (finish <= 0)
                    this.close();
                break;
            }
        }
        c = buffer[start++];
        if ((c & 0x80) != 0)
            throw new CharConversionException("Illegal ASCII character, 0x"
                    + Integer.toHexString(c & 0xff));
        buf[offset + i] = (char) c;
    }
    if (i == 0 && finish <= 0)
        return -1;
    return i;
}
项目:apache-tomcat-7.0.73-with-comment    文件:ServletOutputStream.java   
/**
 * Writes a <code>String</code> to the client, without a carriage
 * return-line feed (CRLF) character at the end.
 * 
 * @param s
 *            the <code>String</code> to send to the client
 * @exception IOException
 *                if an input or output exception occurred
 */
public void print(String s) throws IOException {
    if (s == null)
        s = "null";
    int len = s.length();
    for (int i = 0; i < len; i++) {
        char c = s.charAt(i);

        //
        // XXX NOTE: This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework. It must suffice until servlet output
        // streams properly encode their output.
        //
        if ((c & 0xff00) != 0) { // high order byte must be zero
            String errMsg = lStrings.getString("err.not_iso8859_1");
            Object[] errArgs = new Object[1];
            errArgs[0] = Character.valueOf(c);
            errMsg = MessageFormat.format(errMsg, errArgs);
            throw new CharConversionException(errMsg);
        }
        write(c);
    }
}
项目:openjdk-jdk10    文件:XmlReader.java   
public int read(char buf [], int offset, int len) throws IOException {
    int i, c;

    if (instream == null)
        return -1;

    for (i = 0; i < len; i++) {
        if (start >= finish) {
            start = 0;
            finish = instream.read(buffer, 0, buffer.length);
            if (finish <= 0) {
                if (finish <= 0)
                    this.close();
                break;
            }
        }
        c = buffer[start++];
        if ((c & 0x80) != 0)
            throw new CharConversionException("Illegal ASCII character, 0x"
                    + Integer.toHexString(c & 0xff));
        buf[offset + i] = (char) c;
    }
    if (i == 0 && finish <= 0)
        return -1;
    return i;
}
项目:lazycat    文件:ServletOutputStream.java   
/**
 * Writes a <code>String</code> to the client, without a carriage
 * return-line feed (CRLF) character at the end.
 * 
 * @param s
 *            the <code>String</code> to send to the client
 * @exception IOException
 *                if an input or output exception occurred
 */
public void print(String s) throws IOException {
    if (s == null)
        s = "null";
    int len = s.length();
    for (int i = 0; i < len; i++) {
        char c = s.charAt(i);

        //
        // XXX NOTE: This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework. It must suffice until servlet output
        // streams properly encode their output.
        //
        if ((c & 0xff00) != 0) { // high order byte must be zero
            String errMsg = lStrings.getString("err.not_iso8859_1");
            Object[] errArgs = new Object[1];
            errArgs[0] = Character.valueOf(c);
            errMsg = MessageFormat.format(errMsg, errArgs);
            throw new CharConversionException(errMsg);
        }
        write(c);
    }
}
项目:openjdk9    文件:XmlReader.java   
public int read(char buf [], int offset, int len) throws IOException {
    int i, c;

    if (instream == null)
        return -1;

    for (i = 0; i < len; i++) {
        if (start >= finish) {
            start = 0;
            finish = instream.read(buffer, 0, buffer.length);
            if (finish <= 0) {
                if (finish <= 0)
                    this.close();
                break;
            }
        }
        c = buffer[start++];
        if ((c & 0x80) != 0)
            throw new CharConversionException("Illegal ASCII character, 0x"
                    + Integer.toHexString(c & 0xff));
        buf[offset + i] = (char) c;
    }
    if (i == 0 && finish <= 0)
        return -1;
    return i;
}
项目:beyondj    文件:ServletOutputStream.java   
/**
 * Writes a <code>String</code> to the client, 
 * without a carriage return-line feed (CRLF) 
 * character at the end.
 *
 *
 * @param s                       the <code>String</code> to send to the client
 *
 * @exception IOException         if an input or output exception occurred
 *
 */

public void print(String s) throws IOException {
    if (s==null) s="null";
    int len = s.length();
    for (int i = 0; i < len; i++) {
        char c = s.charAt (i);

        //
        // XXX NOTE:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        //
        if ((c & 0xff00) != 0) {        // high order byte must be zero
            String errMsg = lStrings.getString("err.not_iso8859_1");
            Object[] errArgs = new Object[1];
            errArgs[0] = Character.valueOf(c);
            errMsg = MessageFormat.format(errMsg, errArgs);
            throw new CharConversionException(errMsg);
        }
        write (c);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:XmlReader.java   
public int read(char buf [], int offset, int len) throws IOException {
    int i, c;

    if (instream == null)
        return -1;

    for (i = 0; i < len; i++) {
        if (start >= finish) {
            start = 0;
            finish = instream.read(buffer, 0, buffer.length);
            if (finish <= 0) {
                if (finish <= 0)
                    this.close();
                break;
            }
        }
        c = buffer[start++];
        if ((c & 0x80) != 0)
            throw new CharConversionException("Illegal ASCII character, 0x"
                    + Integer.toHexString(c & 0xff));
        buf[offset + i] = (char) c;
    }
    if (i == 0 && finish <= 0)
        return -1;
    return i;
}
项目:javify    文件:XmlParser.java   
/**
 * Convert a buffer of US-ASCII or ISO-8859-1-encoded bytes into
 * UTF-16 characters.
 *
 * <p>When readDataChunk () calls this method, the raw bytes are in
 * rawReadBuffer, and the final characters will appear in
 * readBuffer.
 *
 * @param count The number of bytes to convert.
 * @param mask For ASCII conversion, 0x7f; else, 0xff.
 * @see #readDataChunk
 * @see #rawReadBuffer
 * @see #readBuffer
 */
private void copyIso8859_1ReadBuffer(int count, char mask)
  throws IOException
{
  int i, j;
  for (i = 0, j = readBufferPos; i < count; i++, j++)
    {
      char c = (char) (rawReadBuffer[i] & 0xff);
      if ((c & mask) != 0)
        {
          throw new CharConversionException("non-ASCII character U+"
                                            + Integer.toHexString(c));
        }
      if (c == 0x0085 && xmlVersion == XML_11)
        {
          c = '\r';
        }
      readBuffer[j] = c;
      if (c == '\r')
        {
          sawCR = true;
        }
    }
  readBufferLength = j;
}
项目:jvm-stm    文件:XmlParser.java   
/**
 * Convert a buffer of US-ASCII or ISO-8859-1-encoded bytes into
 * UTF-16 characters.
 *
 * <p>When readDataChunk () calls this method, the raw bytes are in 
 * rawReadBuffer, and the final characters will appear in 
 * readBuffer.
 *
 * @param count The number of bytes to convert.
 * @param mask For ASCII conversion, 0x7f; else, 0xff.
 * @see #readDataChunk
 * @see #rawReadBuffer
 * @see #readBuffer
 */
private void copyIso8859_1ReadBuffer(int count, char mask)
  throws IOException
{
  int i, j;
  for (i = 0, j = readBufferPos; i < count; i++, j++)
    {
      char c = (char) (rawReadBuffer[i] & 0xff);
      if ((c & mask) != 0)
        {
          throw new CharConversionException("non-ASCII character U+"
                                            + Integer.toHexString(c));
        }
      if (c == 0x0085 && xmlVersion == XML_11)
        {
          c = '\r';
        }
      readBuffer[j] = c;
      if (c == '\r')
        {
          sawCR = true;
        }
    }
  readBufferLength = j;
}
项目:infobip-open-jdk-8    文件:XmlReader.java   
public int read(char buf [], int offset, int len) throws IOException {
    int i, c;

    if (instream == null)
        return -1;

    for (i = 0; i < len; i++) {
        if (start >= finish) {
            start = 0;
            finish = instream.read(buffer, 0, buffer.length);
            if (finish <= 0) {
                if (finish <= 0)
                    this.close();
                break;
            }
        }
        c = buffer[start++];
        if ((c & 0x80) != 0)
            throw new CharConversionException("Illegal ASCII character, 0x"
                    + Integer.toHexString(c & 0xff));
        buf[offset + i] = (char) c;
    }
    if (i == 0 && finish <= 0)
        return -1;
    return i;
}
项目:TikiOne-steam-Cleaner-Plus    文件:Translation.java   
public static List<CountryLanguage> getAvailLangList()
        throws IOException,
               CharConversionException,
               InfinitiveLoopException {
    List<CountryLanguage> langList = new ArrayList<>(2);
    File i18nFolder = new File(CONF_BASEPATH);
    File[] langFiles = i18nFolder.listFiles((File dir, String name) -> name.endsWith(CONF_EXT) && !name.equalsIgnoreCase("encoding.ini"));
    Ini langIni = new Ini();
    for (File langFile : langFiles) {
        langIni.load(langFile, Main.CONF_ENCODING);
        String langDesc = langIni.getKeyValue(" ??? ", "", "name");
        String langFilename = langFile.getName();
        langFilename = langFilename.substring(0, langFilename.indexOf('.'));
        langList.add(new CountryLanguage(langFilename, langDesc));
    }
    return langList;
}
项目:TikiOne-steam-Cleaner-Plus    文件:Patterns.java   
private List<Redist> getRedistPatternsAndDesc(String configKey)
        throws CharConversionException,
        InfinitiveLoopException {
    List<Redist> redistList = new ArrayList<>(8);
    String[] redistTokens = ini.getKeyValue("", CONFIG_REDIST_PATTERNS, configKey).split("\"", 0);
    boolean FileDescToggle = true;
    String redistName = null;
    String redtsiDescription;
    for (String redist : redistTokens) {
        if (redist.length() > 0) { // Skip first and last tokens.
            if (FileDescToggle) {
                redistName = redist;
            } else {
                redtsiDescription = redist;
                redistList.add(new Redist(redistName, redtsiDescription));
            }
            FileDescToggle ^= true;
        }
    }
    return redistList;
}
项目:TikiOne-steam-Cleaner-Plus    文件:Config.java   
public List<String> getPossibleSteamFolders()
        throws CharConversionException,
        InfinitiveLoopException {
    String folderList = ini.getKeyValue("/", CONFIG_STEAM_FOLDERS, CONFIG_STEAM_FOLDERS__POSSIBLE_DIRS);
    String[] patterns = folderList.split(Matcher.quoteReplacement(";"), 0);
    List<String> allSteamPaths = new ArrayList<>(80);
    File[] roots = File.listRoots();
    String[] driveLetters = new String[roots.length];
    for (int nRoot = 0; nRoot < roots.length; nRoot++) {
        driveLetters[nRoot] = roots[nRoot].getAbsolutePath();
    }
    String varDriveLetter = /* Matcher.quoteReplacement( */ "{drive_letter}"/* ) */;
    for (String basePattern : patterns) {
        for (String driveLetter : driveLetters) {
            allSteamPaths.add(basePattern.replace(varDriveLetter, driveLetter));
        }
    }
    Collections.addAll(allSteamPaths, patterns);
    return allSteamPaths;
}
项目:TikiOne-steam-Cleaner-Plus    文件:CustomFolders.java   
/**
 * Set the list of unchecked items to memorize.
 *
 * @param items the items to memorize.
 * @throws CharConversionException
 * @throws InfinitiveLoopException
 */
public void setCustomFolders(List<String> items)
        throws CharConversionException,
               InfinitiveLoopException {
    List<String> prevItems = getCustomFolders();
    if (!prevItems.containsAll(items) || !items.containsAll(prevItems)) {
        updated = true;
        StringBuilder buffer = new StringBuilder(512);
        boolean first = true;
        for (String item : items) {
            if (first) {
                buffer.append(item);
            } else {
                buffer.append('\"').append(item);
            }
            first = false;
        }
        ini.setKeyValue(CONFIG_CUSTOM_FOLDERS, CONFIG_CUSTOM_FOLDERS__ITEM_LIST, buffer.toString());
    }
}
项目:TikiOne-steam-Cleaner-Plus    文件:DangerousItems.java   
public List<Pattern> getDangerousFolders()
        throws CharConversionException,
               InfinitiveLoopException {
    List<Pattern> dangerousFolders = new ArrayList<>(16);
    String[] keys = ini.getKeyValue("", CONFIG_AUTOEXCLUDE_PATTERNS, CONFIG_AUTOEXCLUDE_PATTERNS__FOLDERS_LIST).split("\"", 0);
    for (String pattern : keys) {
        if (pattern.length() > 0) {
            try {
                dangerousFolders.add(Pattern.compile(pattern));
            } catch (PatternSyntaxException ex) {
                Log.error(ex);
            }
        }
    }
    return dangerousFolders;
}
项目:TikiOne-steam-Cleaner-Plus    文件:UncheckedItems.java   
/**
 * Set the list of unchecked items to memorize.
 *
 * @param items the items to memorize.
 * @throws CharConversionException
 * @throws InfinitiveLoopException
 */
public void setUncheckedItems(List<String> items)
        throws CharConversionException,
               InfinitiveLoopException {
    List<String> prevItems = getUncheckedItems();
    if (!prevItems.containsAll(items) || !items.containsAll(prevItems)) {
        updated = true;
        StringBuilder buffer = new StringBuilder(512);
        boolean first = true;
        for (String item : items) {
            if (first) {
                buffer.append(item);
            } else {
                buffer.append('\"').append(item);
            }
            first = false;
        }
        ini.setKeyValue(CONFIG_UNCHECKED_REDIST_ITEMS, CONFIG_UNCHECKED_REDIST_ITEMS__ITEM_LIST, buffer.toString());
    }
}
项目:TikiOne-steam-Cleaner-Plus    文件:Translation.java   
public static List<CountryLanguage> getAvailLangList()
        throws IOException,
               CharConversionException,
               InfinitiveLoopException {
    List<CountryLanguage> langList = new ArrayList<>(2);
    File i18nFolder = new File(CONF_BASEPATH);
    File[] langFiles = i18nFolder.listFiles((File dir, String name) -> name.endsWith(CONF_EXT) && !name.equalsIgnoreCase("encoding.ini"));
    Ini langIni = new Ini();
    for (File langFile : langFiles) {
        langIni.load(langFile, Main.CONF_ENCODING);
        String langDesc = langIni.getKeyValue(" ??? ", "", "name");
        String langFilename = langFile.getName();
        langFilename = langFilename.substring(0, langFilename.indexOf('.'));
        langList.add(new CountryLanguage(langFilename, langDesc));
    }
    return langList;
}
项目:TikiOne-steam-Cleaner-Plus    文件:Patterns.java   
private List<Redist> getRedistPatternsAndDesc(String configKey)
        throws CharConversionException,
        InfinitiveLoopException {
    List<Redist> redistList = new ArrayList<>(8);
    String[] redistTokens = ini.getKeyValue("", CONFIG_REDIST_PATTERNS, configKey).split("\"", 0);
    boolean FileDescToggle = true;
    String redistName = null;
    String redtsiDescription;
    for (String redist : redistTokens) {
        if (redist.length() > 0) { // Skip first and last tokens.
            if (FileDescToggle) {
                redistName = redist;
            } else {
                redtsiDescription = redist;
                redistList.add(new Redist(redistName, redtsiDescription));
            }
            FileDescToggle ^= true;
        }
    }
    return redistList;
}
项目:TikiOne-steam-Cleaner-Plus    文件:Config.java   
public List<String> getPossibleSteamFolders()
        throws CharConversionException,
        InfinitiveLoopException {
    String folderList = ini.getKeyValue("/", CONFIG_STEAM_FOLDERS, CONFIG_STEAM_FOLDERS__POSSIBLE_DIRS);
    String[] patterns = folderList.split(Matcher.quoteReplacement(";"), 0);
    List<String> allSteamPaths = new ArrayList<>(80);
    File[] roots = File.listRoots();
    String[] driveLetters = new String[roots.length];
    for (int nRoot = 0; nRoot < roots.length; nRoot++) {
        driveLetters[nRoot] = roots[nRoot].getAbsolutePath();
    }
    String varDriveLetter = /* Matcher.quoteReplacement( */ "{drive_letter}"/* ) */;
    for (String basePattern : patterns) {
        for (String driveLetter : driveLetters) {
            allSteamPaths.add(basePattern.replace(varDriveLetter, driveLetter));
        }
    }
    Collections.addAll(allSteamPaths, patterns);
    return allSteamPaths;
}
项目:TikiOne-steam-Cleaner-Plus    文件:CustomFolders.java   
/**
 * Set the list of unchecked items to memorize.
 *
 * @param items the items to memorize.
 * @throws CharConversionException
 * @throws InfinitiveLoopException
 */
public void setCustomFolders(List<String> items)
        throws CharConversionException,
               InfinitiveLoopException {
    List<String> prevItems = getCustomFolders();
    if (!prevItems.containsAll(items) || !items.containsAll(prevItems)) {
        updated = true;
        StringBuilder buffer = new StringBuilder(512);
        boolean first = true;
        for (String item : items) {
            if (first) {
                buffer.append(item);
            } else {
                buffer.append('\"').append(item);
            }
            first = false;
        }
        ini.setKeyValue(CONFIG_CUSTOM_FOLDERS, CONFIG_CUSTOM_FOLDERS__ITEM_LIST, buffer.toString());
    }
}