private String[] getRowSamples( int position, int length ) { if ( position < 0 || position + length < 0 ) { return new String[0]; } String[] retval = new String[rows.size()]; for ( int i = 0; i < rows.size(); i++ ) { String line = rows.get( i ); if ( position < line.length() ) { if ( position + length >= line.length() ) { retval[i] = line.substring( position ); } else { try { retval[i] = line.substring( position, position + length ); } catch ( StringIndexOutOfBoundsException e ) { System.out.println( "SIOOB: " + e.toString() ); } } } else { retval[i] = ""; } } return retval; }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuffer sb = new StringBuffer(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuilder sb = new StringBuilder(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
} catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString());
} catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString());
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!mForcing) { if (!isDeleting) { try { int from = editText.getSelectionEnd() - count - differenceCount; if (from < 0) { from = 0; } sb.insert(from, s.subSequence(start, start + count)); } catch (StringIndexOutOfBoundsException e) { Log.e("PatternedEditText: ", e.toString()); //getSelectionEnd() returns 0 after screen rotation. //Added to handle filling EditText after rotation. //onRestoreInstanceState() is responsible for setting text. } } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * Decode the encoded bytes in value and write them to the OutputStream. */ private static void decodeBytes(String value, OutputStream os) throws ParseException, IOException { /* * Decode the ASCII characters in value * and write them to the stream. */ int i; for (i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '%') { try { String hex = value.substring(i + 1, i + 3); c = (char)Integer.parseInt(hex, 16); i += 2; } catch (NumberFormatException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); } } os.write((byte)c); } } }
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuilder sb = new StringBuilder(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
} catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString());
} catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString());
} catch (StringIndexOutOfBoundsException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString());
@Override public String exec(Tuple input) throws IOException { if (input == null || input.size() < 2) { warn("invalid number of arguments to Substring", PigWarning.UDF_WARNING_1); return null; } try { String source = (String)input.get(0); if (source == null) { warn("Source was null", ERRORS.NULL_SOURCE); return null; } Integer beginindex = (Integer)input.get(1); // third arg is optional if (input.size() == 3) { Integer endindex = (Integer)input.get(2); return source.substring(beginindex, Math.min(source.length(), endindex)); } else { return source.substring(beginindex); } } catch (StringIndexOutOfBoundsException e) { warn(e.toString(), ERRORS.OUT_OF_BOUNDS); return null; } }
/** * Method invoked on every tuple during foreach evaluation * @param input tuple; first column is assumed to have the column to convert * @exception java.io.IOException */ @Override public String exec(Tuple input) throws IOException { if (input == null || input.size() < 3) { warn("invalid number of arguments to SUBSTRING", PigWarning.UDF_WARNING_1); return null; } try { String source = (String)input.get(0); Integer beginindex = (Integer)input.get(1); Integer endindex = (Integer)input.get(2); return source.substring(beginindex, Math.min(source.length(), endindex)); } catch (NullPointerException npe) { warn(npe.toString(), PigWarning.UDF_WARNING_2); return null; } catch (StringIndexOutOfBoundsException npe) { warn(npe.toString(), PigWarning.UDF_WARNING_3); return null; } catch (ClassCastException e) { warn(e.toString(), PigWarning.UDF_WARNING_4); return null; } }