List of usage examples for java.lang Character isSpace
@Deprecated(since = "1.1") public static boolean isSpace(char ch)
From source file:Main.java
public static final int ReadInt(PushbackInputStream in, int def) { int b;/*from w w w . ja v a2 s . co m*/ boolean neg = false; int i = 0, digits = 0; try { while (true) { b = (int) in.read() & 0xff; if (b == '-' && digits == 0) neg = !neg; else if (Character.isDigit(b)) { i = 10 * i + (b - (int) '0'); ++digits; } else if (digits != 0 || !Character.isSpace((char) b)) { if (b != -1) in.unread(b); break; } } } catch (IOException e) { } try { while ((b = in.read()) != '/' && b != -1) ; } catch (IOException e) { } if (neg) i = -i; return digits > 0 ? i : def; }
From source file:InputFileDeclared.java
public String getWord() throws IOException { int c;/*from w w w. j av a 2s . co m*/ StringBuffer buf = new StringBuffer(); do { c = in.read(); if (Character.isSpace((char) c)) return buf.toString(); else buf.append((char) c); } while (c != -1); return buf.toString(); }
From source file:com.redhat.smonkey.RndDate.java
private Date applyDiff(Date base, String diff, boolean neg) { cal.setTime(base);/*from w w w . j ava 2s .c o m*/ StringBuilder bld = new StringBuilder(); int value = 0; String unit; int state = 0; boolean done = false; int calfield; for (int i = 0; i < diff.length() && !done; i++) { char c = diff.charAt(i); switch (state) { case 0: if (Character.isSpace(c)) ; else if (Character.isDigit(c)) { bld.append(c); state = 1; } else throw new RuntimeException("Bad expression:" + diff); break; case 1: if (Character.isDigit(c)) { bld.append(c); } else if (Character.isSpace(c)) { state = 2; value = Integer.valueOf(bld.toString()); bld = new StringBuilder(); } else { state = 3; value = Integer.valueOf(bld.toString()); bld = new StringBuilder(); bld.append(c); } break; case 2: if (!Character.isSpace(c)) { state = 3; bld.append(c); } break; case 3: if (!Character.isSpace(c)) { bld.append(c); } else done = true; break; } } if (state == 2 || state == 3) { unit = bld.toString(); if ("sec".equals(unit)) { calfield = Calendar.SECOND; } else if ("min".equals(unit)) { calfield = Calendar.MINUTE; } else if ("hr".equals(unit)) { calfield = Calendar.HOUR_OF_DAY; } else if ("d".equals(unit)) { calfield = Calendar.DAY_OF_MONTH; } else if ("m".equals(unit)) { calfield = Calendar.MONTH; } else if ("y".equals(unit)) { calfield = Calendar.YEAR; } else throw new RuntimeException("Bad expression:" + diff); } else throw new RuntimeException("Bad expression:" + diff); cal.add(calfield, neg ? -value : value); return cal.getTime(); }
From source file:com.volosyukivan.WiFiInputMethod.java
private void wordRight(InputConnection conn) { boolean shift = pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT); ExtractedText text = conn.getExtractedText(req, 0); if (text == null) return;/*from w ww. j a v a 2 s . c o m*/ int end = text.selectionEnd; String str = text.text.toString(); int len = str.length(); for (; end < len; end++) { if (!Character.isSpace(str.charAt(end))) break; } for (; end < len; end++) { if (Character.isSpace(str.charAt(end))) break; } int start = shift ? text.selectionStart : end; Log.d("wifikeyboard", "start = " + start + " end = " + end); conn.setSelection(start, end); }
From source file:com.almarsoft.GroundhogReader.lib.MessageTextProcessor.java
private static String escapeHtmlWithLinks(String line) { StringBuffer buf = null;//from ww w .ja v a2 s. c o m // Shortcut for most cases with line not having a link int idx = line.toLowerCase().indexOf("http://"); if (idx == -1) { return StringEscapeUtils.escapeHtml(line); } else { buf = new StringBuffer(); buf.append(StringEscapeUtils.escapeHtml(line.substring(0, idx))); char c; String endLine; StringBuffer urlBuf = new StringBuffer(); int lineLen = line.length(); for (; idx < lineLen; idx++) { c = line.charAt(idx); if (Character.isSpace(c)) { break; } urlBuf.append(c); } if (urlBuf.length() > 0) { buf.append("<A HREF=\""); buf.append(urlBuf); buf.append("\" >"); buf.append(urlBuf); buf.append("</A> "); } endLine = line.substring(idx); if (endLine.length() > 0) buf.append(StringEscapeUtils.escapeHtml(line.substring(idx))); } return buf.toString(); }
From source file:com.volosyukivan.WiFiInputMethod.java
private void wordLeft(InputConnection conn) { boolean shift = pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT); ExtractedText text = conn.getExtractedText(req, 0); if (text == null) return;/*from www .j ava2s . c om*/ int end = text.selectionEnd - 1; String str = text.text.toString(); for (; end >= 0; end--) { if (!Character.isSpace(str.charAt(end))) break; } for (; end >= 0; end--) { if (Character.isSpace(str.charAt(end))) break; } end++; int start = shift ? text.selectionStart : end; Log.d("wifikeyboard", "start = " + start + " end = " + end); conn.setSelection(start, end); }
From source file:de.micromata.genome.gwiki.utils.html.Html2WikiFilter.java
@SuppressWarnings("deprecation") private boolean requireTextDecoMacroSyntax(final GWikiFragmentTextDeco fragDeco) { fragDeco.iterate(new GWikiSimpleFragmentVisitor() { @Override/*from ww w . j a v a2 s.c om*/ public void begin(GWikiFragment fragment) { if (fragDeco.isRequireMacroSyntax() == true) { return; } if (fragment instanceof GWikiFragmentP || fragment instanceof GWikiFragmentBr) { fragDeco.setRequireMacroSyntax(true); } } }, null); if (fragDeco.isRequireMacroSyntax() == true) { return true; } GWikiFragment lf = parseContext.lastFrag(); if (lf == null) { return false; } if ((lf instanceof GWikiFragmentText) == false) { return false; } GWikiFragmentText tl = (GWikiFragmentText) lf; String source = tl.getSource(); if (StringUtils.isEmpty(source) == true) { return false; } char lc = source.charAt(source.length() - 1); if (Character.isSpace(lc) == false) { return true; } return false; }
From source file:com.zimbra.cs.html.DefangFilter.java
/** * @param result/*from w w w . ja va 2 s. c o m*/ * @return */ public static String removeAnySpacesAndEncodedChars(String result) { String sanitizedStr = result; StringBuilder sb = new StringBuilder(); int index = result.indexOf(":"); if (index > -1) { String jsString = result.substring(0, index); char[] chars = jsString.toCharArray(); for (int i = 0; i < chars.length; ++i) { if (!Character.isSpace(chars[i])) { sb.append(chars[i]); } } } String temp = sb.toString(); temp = StringEscapeUtils.unescapeHtml(temp); if (index != -1 && (temp.toLowerCase().contains("javascript") || temp.toLowerCase().contains("vbscript"))) { sanitizedStr = temp + result.substring(index); } return sanitizedStr; }