org.apache.tools.ant.types.EnumeratedAttribute Java Examples

The following examples show how to use org.apache.tools.ant.types.EnumeratedAttribute. 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: BridgeImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public String[] getEnumeratedValues(Class<?> c) {
    if (EnumeratedAttribute.class.isAssignableFrom(c)) {
        try {
            return ((EnumeratedAttribute)c.newInstance()).getValues();
        } catch (Exception e) {
            AntModule.err.notify(ErrorManager.INFORMATIONAL, e);
        }
    } else if (Enum.class.isAssignableFrom(c)) { // Ant 1.7.0 (#41058)
        try {
            Enum<?>[] vals = (Enum<?>[]) c.getMethod("values").invoke(null);
            String[] names = new String[vals.length];
            for (int i = 0; i < vals.length; i++) {
                names[i] = vals[i].name();
            }
            return names;
        } catch (Exception x) {
            Exceptions.printStackTrace(x);
        }
    }
    return null;
}
 
Example #2
Source File: AntExecTest.java    From metadata with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    SQLExec sqlExec = new SQLExec();

    //设置数据库参数
    sqlExec.setDriver("com.mysql.jdbc.Driver");
    sqlExec.setUrl("jdbc:mysql://127.0.0.1:3306/doc?useUnicode=true&characterEncoding=UTF-8&useOldAlias");
    sqlExec.setUserid("root");
    sqlExec.setPassword("123456");

    //要执行的脚本
    sqlExec.setSrc(new File("D:\\CODE\\metadata\\metadata-test\\src\\main\\resources\\sql\\mysql\\init.sql"));

    //如果有出错的语句继续执行.
    sqlExec.setOnerror((SQLExec.OnError) (EnumeratedAttribute.getInstance(SQLExec.OnError.class, "continue")));
    sqlExec.setPrint(true);
    sqlExec.setProject(new Project()); // 要指定这个属性,不然会出错
    sqlExec.execute();
}
 
Example #3
Source File: AntExecTest.java    From metadata with Apache License 2.0 6 votes vote down vote up
@Test
public void sqlServerTest() {
    SQLExec sqlExec = new SQLExec();

    //设置数据库参数
    sqlExec.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    sqlExec.setUrl("jdbc:sqlserver://localhost:1433;DatabaseName=test");
    sqlExec.setUserid("sa");
    sqlExec.setPassword("hydb001*");

    //要执行的脚本
    sqlExec.setSrc(new File("D:\\CODE\\metadata\\metadata-core\\src\\main\\resources\\coreSqlServer.sql"));

    //如果有出错的语句继续执行.
    sqlExec.setOnerror((SQLExec.OnError) (EnumeratedAttribute.getInstance(SQLExec.OnError.class, "abort")));
    sqlExec.setPrint(true);
    sqlExec.setProject(new Project()); // 要指定这个属性,不然会出错
    sqlExec.execute();
}
 
Example #4
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example #5
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example #6
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example #7
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example #8
Source File: SqlExecUtil.java    From metadata with Apache License 2.0 5 votes vote down vote up
/**
 * 执行
 *
 * @param jdbcVo      数据库连接信息
 * @param inputStream 待执行的脚本信息
 */
public static void execute(JdbcVo jdbcVo, InputStream inputStream) throws Exception {
    //1. 读取 inputStream
    byte[] bytes = readStream(inputStream);

    //2. 创建临时文件
    File tempFile = File.createTempFile("tempSql", ".sql");
    Files.write(tempFile.toPath(), bytes);

    //3. 执行 SQL 脚本
    SQLExec sqlExec = new SQLExec();

    //设置数据库参数
    sqlExec.setDriver(jdbcVo.getDriverClassName());
    sqlExec.setUrl(jdbcVo.getUrl());
    sqlExec.setUserid(jdbcVo.getUsername());
    sqlExec.setPassword(jdbcVo.getPassword());

    //要执行的脚本
    sqlExec.setSrc(tempFile);

    //如果有出错的语句继续执行.
    sqlExec.setOnerror((SQLExec.OnError) (EnumeratedAttribute.getInstance(SQLExec.OnError.class, "continue")));
    sqlExec.setPrint(true);
    // 要指定这个属性,不然会出错
    sqlExec.setProject(new Project());
    sqlExec.execute();

    //4. 删除文件
    if(tempFile.exists()) {
        boolean isDelete = tempFile.delete();
        LOGGER.info("Temp file delete result: " + isDelete);
    }
}
 
Example #9
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example #10
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example #11
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example #12
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}