Java Code Examples for org.yaml.snakeyaml.util.UriEncoder#decode()
The following examples show how to use
org.yaml.snakeyaml.util.UriEncoder#decode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScannerImpl.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * <p> * Scan a sequence of %-escaped URI escape codes and convert them into a * String representing the unescaped values. * </p> * * FIXME This method fails for more than 256 bytes' worth of URI-encoded * characters in a row. Is this possible? Is this a use-case? * * @see http://www.ietf.org/rfc/rfc2396.txt, section 2.4, Escaped Encoding. */ private String scanUriEscapes(String name, Mark startMark) { // First, look ahead to see how many URI-escaped characters we should // expect, so we can use the correct buffer size. int length = 1; while (reader.peek(length * 3) == '%') { length++; } // See the specification for details. // URIs containing 16 and 32 bit Unicode characters are // encoded in UTF-8, and then each octet is written as a // separate character. Mark beginningMark = reader.getMark(); ByteBuffer buff = ByteBuffer.allocate(length); while (reader.peek() == '%') { reader.forward(); try { byte code = (byte) Integer.parseInt(reader.prefix(2), 16); buff.put(code); } catch (NumberFormatException nfe) { throw new ScannerException("while scanning a " + name, startMark, "expected URI escape sequence of 2 hexadecimal numbers, but found " + reader.peek() + "(" + ((int) reader.peek()) + ") and " + reader.peek(1) + "(" + ((int) reader.peek(1)) + ")", reader.getMark()); } reader.forward(2); } buff.flip(); try { return UriEncoder.decode(buff); } catch (CharacterCodingException e) { throw new ScannerException("while scanning a " + name, startMark, "expected URI in UTF-8: " + e.getMessage(), beginningMark); } }
Example 2
Source File: ScannerImpl.java From snake-yaml with Apache License 2.0 | 5 votes |
/** * <p> * Scan a sequence of %-escaped URI escape codes and convert them into a * String representing the unescaped values. * </p> * * FIXME This method fails for more than 256 bytes' worth of URI-encoded * characters in a row. Is this possible? Is this a use-case? * * @see <a href="http://www.ietf.org/rfc/rfc2396.txt"></a>, section 2.4, Escaped Encoding. */ private String scanUriEscapes(String name, Mark startMark) { // First, look ahead to see how many URI-escaped characters we should // expect, so we can use the correct buffer size. int length = 1; while (reader.peek(length * 3) == '%') { length++; } // See the specification for details. // URIs containing 16 and 32 bit Unicode characters are // encoded in UTF-8, and then each octet is written as a // separate character. Mark beginningMark = reader.getMark(); ByteBuffer buff = ByteBuffer.allocate(length); while (reader.peek() == '%') { reader.forward(); try { byte code = (byte) Integer.parseInt(reader.prefix(2), 16); buff.put(code); } catch (NumberFormatException nfe) { throw new ScannerException("while scanning a " + name, startMark, "expected URI escape sequence of 2 hexadecimal numbers, but found " + reader.peek() + "(" + ((int) reader.peek()) + ") and " + reader.peek(1) + "(" + ((int) reader.peek(1)) + ")", reader.getMark()); } reader.forward(2); } buff.flip(); try { return UriEncoder.decode(buff); } catch (CharacterCodingException e) { throw new ScannerException("while scanning a " + name, startMark, "expected URI in UTF-8: " + e.getMessage(), beginningMark); } }
Example 3
Source File: Tag.java From orion.server with Eclipse Public License 1.0 | 4 votes |
public String getClassName() { if (!value.startsWith(Tag.PREFIX)) { throw new YAMLException("Invalid tag: " + value); } return UriEncoder.decode(value.substring(Tag.PREFIX.length())); }
Example 4
Source File: Tag.java From snake-yaml with Apache License 2.0 | 4 votes |
public String getClassName() { if (!value.startsWith(Tag.PREFIX)) { throw new YAMLException("Invalid tag: " + value); } return UriEncoder.decode(value.substring(Tag.PREFIX.length())); }