/** * <p>Constructs a <code>UnicodeEscaper</code> outside of the specified values (exclusive). </p> * * @param codepointLow below which to escape * @param codepointHigh above which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper outsideOf(final int codepointLow, final int codepointHigh) { return new UnicodeEscaper(codepointLow, codepointHigh, false); }
/** * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"} * * @param codepoint * a Unicode code point * @return the hex string for the given codepoint * * @since 3.2 */ protected String toUtf16Escape(final int codepoint) { return "\\u" + hex(codepoint); } }
/** * <p>Constructs a <code>UnicodeEscaper</code> above the specified value (exclusive). </p> * * @param codepoint above which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper above(final int codepoint) { return outsideOf(0, codepoint); }
/** * {@inheritDoc} */ @Override public boolean translate(final int codepoint, final Writer out) throws IOException { if (between) { if (codepoint < below || codepoint > above) { return false; } } else { if (codepoint >= below && codepoint <= above) { return false; } } // TODO: Handle potential + sign per various Unicode escape implementations if (codepoint > 0xffff) { out.write(toUtf16Escape(codepoint)); } else { out.write("\\u"); out.write(HEX_DIGITS[(codepoint >> 12) & 15]); out.write(HEX_DIGITS[(codepoint >> 8) & 15]); out.write(HEX_DIGITS[(codepoint >> 4) & 15]); out.write(HEX_DIGITS[(codepoint) & 15]); } return true; }
/** * {@inheritDoc} */ @Override public boolean translate(final int codepoint, final Writer out) throws IOException { if (between) { if (codepoint < below || codepoint > above) { return false; } } else { if (codepoint >= below && codepoint <= above) { return false; } } // TODO: Handle potential + sign per various Unicode escape implementations if (codepoint > 0xffff) { out.write(toUtf16Escape(codepoint)); } else { out.write("\\u"); out.write(HEX_DIGITS[(codepoint >> 12) & 15]); out.write(HEX_DIGITS[(codepoint >> 8) & 15]); out.write(HEX_DIGITS[(codepoint >> 4) & 15]); out.write(HEX_DIGITS[(codepoint) & 15]); } return true; }
/** * <p>Constructs a <code>UnicodeEscaper</code> below the specified value (exclusive). </p> * * @param codepoint below which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper below(final int codepoint) { return outsideOf(codepoint, Integer.MAX_VALUE); }
/** * <p>Constructs a <code>UnicodeEscaper</code> between the specified values (inclusive). </p> * * @param codepointLow above which to escape * @param codepointHigh below which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper between(final int codepointLow, final int codepointHigh) { return new UnicodeEscaper(codepointLow, codepointHigh, true); }
/** * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"} * * @param codepoint * a Unicode code point * @return the hex string for the given codepoint * * @since 3.2 */ protected String toUtf16Escape(final int codepoint) { return "\\u" + hex(codepoint); } }
/** * {@inheritDoc} */ @Override public boolean translate(final int codepoint, final Writer out) throws IOException { if (between) { if (codepoint < below || codepoint > above) { return false; } } else { if (codepoint >= below && codepoint <= above) { return false; } } // TODO: Handle potential + sign per various Unicode escape implementations if (codepoint > 0xffff) { out.write(toUtf16Escape(codepoint)); } else { out.write("\\u"); out.write(HEX_DIGITS[(codepoint >> 12) & 15]); out.write(HEX_DIGITS[(codepoint >> 8) & 15]); out.write(HEX_DIGITS[(codepoint >> 4) & 15]); out.write(HEX_DIGITS[(codepoint) & 15]); } return true; }
/** * <p>Constructs a <code>UnicodeEscaper</code> below the specified value (exclusive). </p> * * @param codepoint below which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper below(final int codepoint) { return outsideOf(codepoint, Integer.MAX_VALUE); }
/** * <p>Constructs a <code>UnicodeEscaper</code> between the specified values (inclusive). </p> * * @param codepointLow above which to escape * @param codepointHigh below which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper between(final int codepointLow, final int codepointHigh) { return new UnicodeEscaper(codepointLow, codepointHigh, true); }
/** * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"} * * @param codepoint * a Unicode code point * @return the hex string for the given codepoint * * @since 3.2 */ protected String toUtf16Escape(final int codepoint) { return "\\u" + hex(codepoint); } }
/** * {@inheritDoc} */ @Override @GwtIncompatible("incompatible method") public boolean translate(final int codepoint, final Writer out) throws IOException { if (between) { if (codepoint < below || codepoint > above) { return false; } } else { if (codepoint >= below && codepoint <= above) { return false; } } // TODO: Handle potential + sign per various Unicode escape implementations if (codepoint > 0xffff) { out.write(toUtf16Escape(codepoint)); } else { out.write("\\u"); out.write(HEX_DIGITS[(codepoint >> 12) & 15]); out.write(HEX_DIGITS[(codepoint >> 8) & 15]); out.write(HEX_DIGITS[(codepoint >> 4) & 15]); out.write(HEX_DIGITS[(codepoint) & 15]); } return true; }
/** * <p>Constructs a <code>UnicodeEscaper</code> above the specified value (exclusive). </p> * * @param codepoint above which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper above(final int codepoint) { return outsideOf(0, codepoint); }
/** * <p>Constructs a <code>UnicodeEscaper</code> between the specified values (inclusive). </p> * * @param codepointLow above which to escape * @param codepointHigh below which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper between(final int codepointLow, final int codepointHigh) { return new UnicodeEscaper(codepointLow, codepointHigh, true); }
/** * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"} * * @param codepoint * a Unicode code point * @return the hex string for the given codepoint * * @since 3.2 */ protected String toUtf16Escape(final int codepoint) { return "\\u" + hex(codepoint); } }
/** * <p>Constructs a <code>UnicodeEscaper</code> below the specified value (exclusive). </p> * * @param codepoint below which to escape * @return the newly created {@code UnicodeEscaper} instance */ public static UnicodeEscaper below(final int codepoint) { return outsideOf(codepoint, Integer.MAX_VALUE); }