Example usage for java.lang Character isISOControl

List of usage examples for java.lang Character isISOControl

Introduction

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

Prototype

public static boolean isISOControl(int codePoint) 

Source Link

Document

Determines if the referenced character (Unicode code point) is an ISO control character.

Usage

From source file:ddf.catalog.transformer.xml.EscapingPrintWriter.java

private static boolean isWellKnownCharacter(char c) {
    return Character.isDefined(c) && !Character.isISOControl(c) && !Character.isSurrogate(c);
}

From source file:MemComboBoxDemo.java

public void keyReleased(KeyEvent e) {
    char ch = e.getKeyChar();
    if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))
        return;/*from   w  w w .j av a2s  .c om*/
    int pos = editor.getCaretPosition();
    String str = editor.getText();
    if (str.length() == 0)
        return;

    for (int k = 0; k < comboBox.getItemCount(); k++) {
        String item = comboBox.getItemAt(k).toString();
        if (item.startsWith(str)) {
            editor.setText(item);
            editor.setCaretPosition(item.length());
            editor.moveCaretPosition(pos);
            break;
        }
    }
}

From source file:com.igormaznitsa.mindmap.plugins.exporters.MDExporter.java

@Nonnull
private static String makeLineFromString(@Nonnull final String text) {
    final StringBuilder result = new StringBuilder(text.length());

    for (final char c : text.toCharArray()) {
        if (Character.isISOControl(c)) {
            result.append(' ');
        } else {//  w w w.j a  v a2 s  .  c o m
            result.append(c);
        }
    }

    return result.toString();
}

From source file:com.sec.ose.osi.ui.frm.main.identification.common.JComboLicenseName.java

public JComboLicenseName() {
    final JTextField editor;
    this.initLicenseComboBox();

    this.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (isEnabled()) {
                if (e.getActionCommand().equals("comboBoxChanged")
                        || e.getActionCommand().equals("comboBoxEdited")) {
                    if (getSelectedIndex() > 0) {
                        setSelectedIndex(getSelectedIndex());
                        IdentifyMediator.getInstance()
                                .setSelectedLicenseName(String.valueOf(getSelectedItem()));
                        log.debug("selected license name : "
                                + IdentifyMediator.getInstance().getSelectedLicenseName());
                    } else {
                        IdentifyMediator.getInstance().setSelectedLicenseName("");
                    }/*from   w w w.  j  a v a2  s .c  o m*/
                }
            }
        }
    });
    editor = (JTextField) this.getEditor().getEditorComponent();
    editor.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            char ch = e.getKeyChar();

            if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE
                    && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)))
                return;
            if (ch == KeyEvent.VK_ENTER) {
                hidePopup();
                return;
            }

            String str = editor.getText();

            if (getComponentCount() > 0) {
                removeAllItems();
            }

            addItem(str);
            try {
                String tmpLicense = null;
                ArrayList<String> AllLicenseList = new ArrayList<String>();
                AllLicenseList = LicenseAPIWrapper.getAllLicenseList();
                if (str.length() > 0) {
                    for (int i = 0; i < AllLicenseList.size(); i++) {
                        tmpLicense = AllLicenseList.get(i);
                        if (tmpLicense.toLowerCase().startsWith(str.toLowerCase()))
                            addItem(tmpLicense);
                    }
                } else {
                    for (int i = 0; i < AllLicenseList.size(); i++) {
                        addItem(AllLicenseList.get(i));
                    }
                }
            } catch (Exception e1) {
                log.warn(e1.getMessage());
            }

            hidePopup();
            if (str.length() > 0)
                showPopup();
        }
    });

    editor.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            if (editor.getText().length() > 0)
                showPopup();
        }

        public void focusLost(FocusEvent e) {
            hidePopup();
        }
    });
}

From source file:com.sec.ose.osi.ui.frm.main.identification.JComboProjectName.java

public JComboProjectName() {

    this.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    this.setEditable(true);
    this.setPreferredSize(new Dimension(400, 27));
    this.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            long start = System.currentTimeMillis();
            actionOnProjectSelectedonProjectComboBox();
            long end = System.currentTimeMillis();
            log.debug(//from   ww w .  jav a2s  .co m
                    "[JComboProjectName.addActionListener()] Project Loding TIME : " + (end - start) / 1000.0);
        }
    });

    final JTextField editor = (JTextField) this.getEditor().getEditorComponent();
    editor.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {

            char ch = e.getKeyChar();
            int count = 0;
            String newProjectName = editor.getText();

            if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE
                    && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) {
                return;
            }

            if (newProjectName.length() <= 0 && ch == KeyEvent.VK_BACK_SPACE) {
                count++;
                if (count >= 2) {
                    String projectName = IdentifyMediator.getInstance().getSelectedProjectName();
                    ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(projectName);
                    count = 0;
                    return;
                }
            }
            if (JComboProjectName.this.getComponentCount() > 0) {
                JComboProjectName.this.removeAllItems();
            }

            JComboProjectName.this.addItem(newProjectName);
            try {
                Collection<OSIProjectInfo> ProjectsInfo = OSIProjectInfoMgr.getInstance().getAllProjects();

                String tmpProName = null;
                boolean bAnalysis = false;
                if (newProjectName.length() > 0) {
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        tmpProName = projectInfo.getProjectName();
                        bAnalysis = projectInfo.isAnalyzed();
                        if (tmpProName.toLowerCase().contains(newProjectName.toLowerCase()) && bAnalysis)
                            JComboProjectName.this.addItem(tmpProName);
                    }
                    if (JComboProjectName.this.getItemCount() <= 1) {
                        JComboProjectName.this.removeAllItems();
                        JOptionPane.showOptionDialog(null, "There is no project.", "Project Filter",
                                JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
                    }
                } else {
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        if (projectInfo.isManaged() == true && projectInfo.isAnalyzed()) {
                            JComboProjectName.this.addItem(projectInfo.getProjectName());
                        }
                    }
                    JComboProjectName.this.addItem(DIVIDER_LINE);
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        if (projectInfo.isManaged() == false && projectInfo.isAnalyzed()) {
                            JComboProjectName.this.addItem(projectInfo.getProjectName());
                        }
                    }
                    ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText("");
                }
            } catch (Exception e1) {
                log.warn(e1.getMessage());
            }

            JComboProjectName.this.hidePopup();
            if (newProjectName.length() > 0)
                JComboProjectName.this.showPopup();
        }
    });

}

From source file:com.sangupta.clitools.file.HexDump.java

public static void hexDump(PrintStream outStream, BufferedInputStream bis, int currentRow, int maxRows)
        throws IOException {
    int row = currentRow + 1;
    if (maxRows == 0) {
        maxRows = Integer.MAX_VALUE;
    } else {// w  ww .ja va 2  s  .c o m
        maxRows += currentRow;
    }

    StringBuilder builder1 = new StringBuilder(100);
    StringBuilder builder2 = new StringBuilder(100);

    while (bis.available() > 0) {
        outStream.printf("%04X  ", row * 16);
        for (int j = 0; j < 16; j++) {
            if (bis.available() > 0) {
                int value = (int) bis.read();
                builder1.append(String.format("%02X ", value));

                if (!Character.isISOControl(value)) {
                    builder2.append((char) value);
                } else {
                    builder2.append(".");
                }
            } else {
                for (; j < 16; j++) {
                    builder1.append("   ");
                }
            }
        }
        outStream.print(builder1);
        outStream.println(builder2);
        row++;

        if (row > maxRows) {
            break;
        }

        builder1.setLength(0);
        builder2.setLength(0);
    }
}

From source file:com.igormaznitsa.mindmap.model.ModelUtils.java

@Nonnull
public static String escapeMarkdownStr(@Nonnull final String text) {
    final StringBuilder buffer = new StringBuilder(text.length() * 2);
    for (final char c : text.toCharArray()) {
        if (c == '\n') {
            buffer.append("<br/>"); //NOI18N
            continue;
        } else if (Character.isISOControl(c)) {
            continue;
        } else if (MD_ESCAPED_CHARS.indexOf(c) >= 0) {
            buffer.append('\\');
        }/*from  ww w  .ja v  a  2 s  .c om*/

        buffer.append(c);
    }
    return buffer.toString();
}

From source file:org.eclipse.gyrex.admin.ui.internal.pages.overview.SystemStatus.java

final void writeEscaped(final Writer writer, final Object object) throws IOException {
    if (object == null)
        return;// w  w w .j a  v a2  s. c o  m

    final String string = object.toString();
    for (int i = 0; i < string.length(); i++) {
        final char c = string.charAt(i);

        switch (c) {
        case '&':
            writer.write("&amp;");
            break;
        case '<':
            writer.write("&lt;");
            break;
        case '>':
            writer.write("&gt;");
            break;

        default:
            if (Character.isISOControl(c) && !Character.isWhitespace(c)) {
                writer.write('?');
            } else {
                writer.write(c);
            }
        }
    }
}

From source file:net.sf.keystore_explorer.utilities.io.HexUtil.java

private static String getHexClearLineDump(byte[] bytes, int len) {
    StringBuffer sbHex = new StringBuffer();
    StringBuffer sbClr = new StringBuffer();

    for (int cnt = 0; cnt < len; cnt++) {
        // Convert byte to int
        byte b = bytes[cnt];
        int i = b & 0xFF;

        // First part of byte will be one hex char
        int i1 = (int) Math.floor(i / 16);

        // Second part of byte will be one hex char
        int i2 = i % 16;

        // Get hex characters
        sbHex.append(Character.toUpperCase(Character.forDigit(i1, 16)));
        sbHex.append(Character.toUpperCase(Character.forDigit(i2, 16)));

        if ((cnt + 1) < len) {
            // Divider between hex characters
            sbHex.append(' ');
        }//from  w  w w  .ja va 2 s .  c  o  m

        // Get clear character

        // Character to display if character not defined in Unicode or is a
        // control charcter
        char c = '.';

        // Not a control character and defined in Unicode
        if ((!Character.isISOControl((char) i)) && (Character.isDefined((char) i))) {
            Character clr = new Character((char) i);
            c = clr.charValue();
        }

        sbClr.append(c);
    }

    /*
     * Put both dumps together in one string (hex, clear) with appropriate
     * padding between them (pad to array length)
     */
    StringBuffer strBuff = new StringBuffer();

    strBuff.append(sbHex.toString());

    int i = bytes.length - len;
    for (int cnt = 0; cnt < i; cnt++) {
        strBuff.append("   "); // Each missing byte takes up three spaces
    }

    strBuff.append("   "); // The gap between hex and clear output is three
    // spaces
    strBuff.append(sbClr.toString());

    return strBuff.toString();
}

From source file:jetbrains.exodus.sshd.RhinoCommand.java

private boolean isPrintableChar(char c) {
    Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
    return (!Character.isISOControl(c)) && c != KeyEvent.CHAR_UNDEFINED && block != null
            && block != Character.UnicodeBlock.SPECIALS;
}