Java 类org.yaml.snakeyaml.util.UriEncoder 实例源码

项目:belladati-sdk-java    文件:AttributesTest.java   
@Test(dataProvider = "postAttributeValueImage_provider")
public void postAttributeValueImage(String value) throws URISyntaxException {
    String url = String.format(imageUri, dataSetId, code, UriEncoder.encode(value));

    final boolean[] executed = new boolean[1];
    server.register(url, new TestRequestHandler() {
        @Override
        protected void handle(HttpHolder holder) throws IOException {
            assertEquals(holder.getUrlParameters().size(), 0);
            holder.response.setEntity(new StringEntity(""));
            executed[0] = true;
        }
    });

    getService().postAttributeValueImage(dataSetId, code, value, getTestImageFile());

    assertTrue(executed[0]);
}
项目:belladati-sdk-java    文件:UtilsTest.java   
@Test(dataProvider = "loadFile_provider")
public void loadFile(String filepath) throws URISyntaxException, IOException {
    String encoded = UriEncoder.encode(filepath);
    server.register(String.format(fileUrl, encoded), new TestRequestHandler() {
        @Override
        protected void handle(HttpHolder holder) throws IOException {
            assertEquals(holder.getUrlParameters().size(), 0);
            holder.response.setEntity(new InputStreamEntity(getTestImageStream()));
        }
    });

    ByteArrayInputStream stream = (ByteArrayInputStream) getService().loadFile(filepath);

    assertNotNull(stream);
    assertEquals(stream.available(), getTestImageStream().available());
}
项目:belladati-sdk-java    文件:UtilsTest.java   
@Test(dataProvider = "mergePdfFiles_provider")
public void mergePdfFiles(List<String> paths) throws URISyntaxException, IOException {
    String joinedPaths = "";
    for (String path : paths) {
        if (!joinedPaths.isEmpty()) {
            joinedPaths += ";";
        }
        joinedPaths += UriEncoder.encode(path);
    }

    server.register(String.format(mergePdfUrl, joinedPaths), new TestRequestHandler() {
        @Override
        protected void handle(HttpHolder holder) throws IOException {
            assertEquals(holder.getUrlParameters().size(), 0);
            holder.response.setEntity(new InputStreamEntity(getTestImageStream()));
        }
    });

    ByteArrayInputStream stream = (ByteArrayInputStream) getService().mergePdfFiles(paths);

    assertNotNull(stream);
    assertEquals(stream.available(), getTestImageStream().available());
}
项目:AndroidApktool    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
    this.secondary = !tag.startsWith(PREFIX);
}
项目:AndroidApktool    文件:ScannerImpl.java   
/**
 * <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);
    }
}
项目:5zig-TIMV-Plugin    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
    this.secondary = !tag.startsWith(PREFIX);
}
项目:5zig-TIMV-Plugin    文件:ScannerImpl.java   
/**
 * <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) {
            int c1 = reader.peek();
            final String s1 = String.valueOf(Character.toChars(c1));
            int c2 = reader.peek(1);
            final String s2 = String.valueOf(Character.toChars(c2));
            throw new ScannerException("while scanning a " + name, startMark,
                    "expected URI escape sequence of 2 hexadecimal numbers, but found "
                            + s1 + "(" + c1 + ") and "
                            + s2 + "(" + c2 + ")",
                    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);
    }
}
项目:snake-yaml    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
    this.secondary = !tag.startsWith(PREFIX);
}
项目:snake-yaml    文件:ScannerImpl.java   
/**
 * <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);
    }
}
项目:SubServers-2    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
    this.secondary = !tag.startsWith(PREFIX);
}
项目:SubServers-2    文件:ScannerImpl.java   
/**
 * <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) {
            int c1 = reader.peek();
            final String s1 = String.valueOf(Character.toChars(c1));
            int c2 = reader.peek(1);
            final String s2 = String.valueOf(Character.toChars(c2));
            throw new ScannerException("while scanning a " + name, startMark,
                    "expected URI escape sequence of 2 hexadecimal numbers, but found "
                            + s1 + "(" + c1 + ") and "
                            + s2 + "(" + c2 + ")",
                    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);
    }
}
项目:snakeyaml    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
    this.secondary = !tag.startsWith(PREFIX);
}
项目:snakeyaml    文件:ScannerImpl.java   
/**
 * <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);
    }
}
项目:TestTheTeacher    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
}
项目:TestTheTeacher    文件:ScannerImpl.java   
/**
 * <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);
    }
}
项目:StormCV    文件:FtpConnector.java   
@Override
public void moveTo(String loc) throws IOException{
    try{
        this.location = new URI(UriEncoder.encode(loc));
        checkAndConnect();
        int code = client.cwd(location.getPath());
        if(code == 250) return;
        code = client.cwd(location.getPath().substring(0, location.getPath().lastIndexOf('/')));
    }catch(Exception e){
        logger.warn("Unable to move to "+location+" due to: "+e.getMessage());
        throw new IOException(e);
    }
}
项目:org.openntf.domino    文件:Tag.java   
public Tag(String tag) {
    if (tag == null) {
        throw new NullPointerException("Tag must be provided.");
    } else if (tag.length() == 0) {
        throw new IllegalArgumentException("Tag must not be empty.");
    } else if (tag.trim().length() != tag.length()) {
        throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
    }
    this.value = UriEncoder.encode(tag);
}
项目:org.openntf.domino    文件:ScannerImpl.java   
/**
 * <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(final String name, final 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);
    }
}
项目:AndroidApktool    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:AndroidApktool    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}
项目:5zig-TIMV-Plugin    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:5zig-TIMV-Plugin    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}
项目:snake-yaml    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:snake-yaml    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}
项目:SubServers-2    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:SubServers-2    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}
项目:snakeyaml    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:snakeyaml    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}
项目:TestTheTeacher    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:TestTheTeacher    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}
项目:org.openntf.domino    文件:Tag.java   
public Tag(Class<? extends Object> clazz) {
    if (clazz == null) {
        throw new NullPointerException("Class for tag must be provided.");
    }
    this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
}
项目:org.openntf.domino    文件:Tag.java   
public String getClassName() {
    if (!value.startsWith(Tag.PREFIX)) {
        throw new YAMLException("Invalid tag: " + value);
    }
    return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
}