Java 类java.util.IllegalFormatFlagsException 实例源码

项目:form-follows-function    文件:F3Formatter.java   
private void checkNumeric() {
    if (width != -1 && width < 0)
        throw new IllegalFormatWidthException(width);

    if (precision != -1 && precision < 0)
        throw new IllegalFormatPrecisionException(precision);

    // '-' and '0' require a width
    if (width == -1
        && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD)))
        throw new MissingFormatWidthException(toString());

    // bad combination
    if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE))
        || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD)))
        throw new IllegalFormatFlagsException(f.toString());
}
项目:bazel    文件:FormatSpecifier.java   
private void checkNumeric() {
    if (width != -1 && width < 0)
        throw new IllegalFormatWidthException(width);

    if (precision != -1 && precision < 0)
        throw new IllegalFormatPrecisionException(precision);

    // '-' and '0' require a width
    if (width == -1
            && (f.contains(Flags.LEFT_JUSTIFY) || f
                    .contains(Flags.ZERO_PAD)))
        throw new MissingFormatWidthException(toString());

    // bad combination
    if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE))
            || (f.contains(Flags.LEFT_JUSTIFY) && f
                    .contains(Flags.ZERO_PAD)))
        throw new IllegalFormatFlagsException(f.toString());
}
项目:bazel    文件:FormatSpecifier.java   
private void checkText() {
    if (precision != -1)
        throw new IllegalFormatPrecisionException(precision);
    switch (c) {
    case Conversion.PERCENT_SIGN:
        if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf()
                && f.valueOf() != Flags.NONE.valueOf())
            throw new IllegalFormatFlagsException(f.toString());
        // '-' requires a width
        if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
            throw new MissingFormatWidthException(toString());
        break;
    case Conversion.LINE_SEPARATOR:
        if (width != -1)
            throw new IllegalFormatWidthException(width);
        if (f.valueOf() != Flags.NONE.valueOf())
            throw new IllegalFormatFlagsException(f.toString());
        break;
    default:
           throw new UnknownFormatConversionException(String.valueOf(c));
    }
}
项目:gedis    文件:Gedis.java   
/**
 * 从连接配置信息字符串中解析出主机、端口、密码
 *
 * @param ipPortPassword 连接配置信息
 * @return Gedis 初始化参数
 */
private static GedisInitParam getConnectInfo(String ipPortPassword) {
    if (isEmpty(ipPortPassword)) {
        return null;
    }
    Pattern pattern = Pattern.compile(Constants.CONNECT_CONFIG_REG);
    Matcher matcher = pattern.matcher(ipPortPassword);
    if (!matcher.matches() || matcher.groupCount() != 3) {
        throw new IllegalFormatFlagsException("Gedis connection config is not formated as: ip:port?password");
    }
    String ip = matcher.group(1);
    int port = Integer.parseInt(matcher.group(2));
    String password = matcher.group(3);
    return new GedisInitParam(ip, port, password);
}
项目:compose-executor    文件:DockerRewriteHelper.java   
private String replacePort(String portString,Iterator<Long> portIterator){
    if(portIterator.hasNext()){
        String [] tokens = portString.split(":");
        if(tokens.length > 1){
            return portIterator.next()+":"+tokens[1];
        }else{
            throw new IllegalFormatFlagsException("port mappings in docker-compose file not valid");
        }
    }else{
        throw new NoSuchElementException("Insufficient number of ports allocated");
    }
}
项目:In-the-Box-Fork    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException#IllegalFormatFlagsException(String)
 */
public void test_illegalFormatFlagsException() {
    try {
        new IllegalFormatFlagsException(null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // expected
    }
}
项目:In-the-Box-Fork    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getFlags()
 */
public void test_getFlags() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertEquals(flags, illegalFormatFlagsException.getFlags());
}
项目:In-the-Box-Fork    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getMessage()
 */
public void test_getMessage() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertTrue(null != illegalFormatFlagsException.getMessage());

}
项目:In-the-Box-Fork    文件:IllegalFormatFlagsExceptionTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

    IllegalFormatFlagsException initEx = (IllegalFormatFlagsException) initial;
    IllegalFormatFlagsException desrEx = (IllegalFormatFlagsException) deserialized;

    assertEquals("Flags", initEx.getFlags(), desrEx.getFlags());
}
项目:cn1    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException#IllegalFormatFlagsException(String)
 */
public void test_illegalFormatFlagsException() {
    try {
        new IllegalFormatFlagsException(null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // expected
    }
}
项目:cn1    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getFlags()
 */
public void test_getFlags() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertEquals(flags, illegalFormatFlagsException.getFlags());
}
项目:cn1    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getMessage()
 */
public void test_getMessage() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertTrue(null != illegalFormatFlagsException.getMessage());

}
项目:cn1    文件:IllegalFormatFlagsExceptionTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

    IllegalFormatFlagsException initEx = (IllegalFormatFlagsException) initial;
    IllegalFormatFlagsException desrEx = (IllegalFormatFlagsException) deserialized;

    assertEquals("Flags", initEx.getFlags(), desrEx.getFlags());
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException#IllegalFormatFlagsException(String)
 */
public void test_illegalFormatFlagsException() {
    try {
        new IllegalFormatFlagsException(null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // expected
    }
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getFlags()
 */
public void test_getFlags() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertEquals(flags, illegalFormatFlagsException.getFlags());
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getMessage()
 */
public void test_getMessage() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertTrue(null != illegalFormatFlagsException.getMessage());

}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

    IllegalFormatFlagsException initEx = (IllegalFormatFlagsException) initial;
    IllegalFormatFlagsException desrEx = (IllegalFormatFlagsException) deserialized;

    assertEquals("Flags", initEx.getFlags(), desrEx.getFlags());
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException#IllegalFormatFlagsException(String)
 */
public void test_illegalFormatFlagsException() {
    try {
        new IllegalFormatFlagsException(null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // expected
    }
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getFlags()
 */
public void test_getFlags() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertEquals(flags, illegalFormatFlagsException.getFlags());
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests java.util.IllegalFormatFlagsException.getMessage()
 */
public void test_getMessage() {
    String flags = "TESTFLAGS";
    IllegalFormatFlagsException illegalFormatFlagsException = new IllegalFormatFlagsException(
            flags);
    assertTrue(null != illegalFormatFlagsException.getMessage());

}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

    IllegalFormatFlagsException initEx = (IllegalFormatFlagsException) initial;
    IllegalFormatFlagsException desrEx = (IllegalFormatFlagsException) deserialized;

    assertEquals("Flags", initEx.getFlags(), desrEx.getFlags());
}
项目:Hijacker    文件:RootFile.java   
RootFile(String path) throws IllegalArgumentException{
    if(path==null) throw new IllegalArgumentException("File path can't be null");
    if(path.length()==0) throw new IllegalArgumentException("File path has zero length");
    if(path.charAt(0)!='/') throw new IllegalArgumentException("File path must start with /");
    if(path.contains("*")) throw new IllegalArgumentException("File path contains * character");

    if(path.charAt(path.length()-1)=='/' && path.length()>1) path = path.substring(0, path.length()-1);

    shell.run(busybox + " ls \"" + path + "\" -d -l; echo ENDOFLS");
    String buffer = getLastLine(out, "ENDOFLS");

    if(buffer.equals("ENDOFLS")){
        if(debug) Log.e("HIJACKER/RootFile", "Couldn't read shell output");
        return;
    }

    //Isolate absolute path and name
    this.name = path.substring(path.lastIndexOf('/') + 1);
    this.absolutePath = path;
    this.parentPath = absolutePath.substring(0, absolutePath.lastIndexOf('/') + 1);

    //Eliminate multiple spaces
    String before = "";
    while(!before.equals(buffer)){
        before = buffer;
        buffer = buffer.replace("  ", " ");
    }

    if(buffer.contains("No such") || buffer.startsWith("ls:")){
        this.isUnknownType = true;
        return;
    }

    exists = true;

    String temp[] = buffer.split(" ");
    //0: type & permissions, 4: size, 5,6,7: last edited date, rest is name
    if(temp[0].length()!=10){
        throw new IllegalFormatFlagsException(temp[0] + " is not how it should be\nbuffer: " + buffer + "\nbuffer before: " + before);
    }
    if(temp[0].charAt(0)=='d'){
        this.isDirectory = true;
    }else if(temp[0].charAt(0)=='-'){
        this.isFile = true;
    }else{
        this.isUnknownType = true;
    }

    try{
        this.length = Long.parseLong(temp[4]);
    }catch(NumberFormatException ignored){}
}
项目:In-the-Box-Fork    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:In-the-Box-Fork    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:cn1    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:cn1    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}
项目:freeVM    文件:IllegalFormatFlagsExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new IllegalFormatFlagsException(
            "TESTFLAGS"), exComparator);
}