Example usage for java.lang Integer TYPE

List of usage examples for java.lang Integer TYPE

Introduction

In this page you can find the example usage for java.lang Integer TYPE.

Prototype

Class TYPE

To view the source code for java.lang Integer TYPE.

Click Source Link

Document

The Class instance representing the primitive type int .

Usage

From source file:Main.java

public static void main(String args[]) throws Exception {
    Class cls = Class.forName("constructor2");
    Class partypes[] = new Class[2];
    partypes[0] = Integer.TYPE;
    partypes[1] = Integer.TYPE;//from  ww w. ja v  a  2  s.com
    Constructor ct = cls.getConstructor(partypes);
    Object arglist[] = new Object[2];
    arglist[0] = new Integer(37);
    arglist[1] = new Integer(47);
    Object retobj = ct.newInstance(arglist);

}

From source file:Main.java

public static void main(String[] args) {
    Class c = boolean.class;
    c = Boolean.TYPE;//ww w .  ja  v a  2s. c o m
    c = byte.class;
    c = Byte.TYPE;
    c = char.class;
    c = Character.TYPE;
    c = short.class;
    c = Short.TYPE;
    c = int.class;
    c = Integer.TYPE;
    c = long.class;
    c = Long.TYPE;
    c = float.class;
    c = Float.TYPE;
    c = double.class;
    c = Double.TYPE;
    c = void.class;
    c = Void.TYPE;
}

From source file:org.jclouds.examples.blobstore.BlobUploaderMain.java

public static void main(String[] args) throws IOException {

    OptionParser parser = new OptionParser();
    parser.accepts("directory").withRequiredArg().required().ofType(String.class);
    parser.accepts("provider").withRequiredArg().required().ofType(String.class);
    parser.accepts("username").withRequiredArg().required().ofType(String.class);
    parser.accepts("password").withRequiredArg().required().ofType(String.class);
    parser.accepts("region").withRequiredArg().required().ofType(String.class);
    parser.accepts("threads").withRequiredArg().ofType(Integer.TYPE).describedAs("number of parallel threads");
    OptionSet options = null;//from   w  w w .  ja v a2 s.  c o m

    try {
        options = parser.parse(args);
    } catch (OptionException e) {
        System.out.println(e.getLocalizedMessage());
        parser.printHelpOn(System.out);
        return;
    }

    if (options.has("threads")) {
        numThreads = Integer.valueOf((String) options.valueOf("numThreads"));
    }

    File rootDir = new File((String) options.valueOf("directory"));
    Collection<File> files = FileUtils.listFiles(rootDir, CanReadFileFilter.CAN_READ, TrueFileFilter.TRUE);
    totalBytes = FileUtils.sizeOfDirectory(rootDir);

    System.out.println("Uploading " + rootDir.getName() + " " + totalBytes / FileUtils.ONE_MB + "MB");

    ExecutorService executor = Executors.newFixedThreadPool(numThreads);

    for (File f : files) {
        BlobUploader b = new BlobUploader((String) options.valueOf("username"),
                (String) options.valueOf("password"), (String) options.valueOf("provider"),
                (String) options.valueOf("region"), f);
        executor.execute(b);
    }
    executor.shutdown();

    try {
        executor.awaitTermination(1, TimeUnit.DAYS);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:TmlCommandLine.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    long time = System.nanoTime();

    options = new Options();

    // Repository
    options.addOption(OptionBuilder.withDescription(
            "Full path of the repository folder, where TML will retrieve (or insert) documents. (e.g. /home/user/lucene).")
            .hasArg().withArgName("folder").isRequired().create("repo"));

    // Verbosity// www. jav a 2  s  .co  m
    options.addOption(
            OptionBuilder.withDescription("Verbose output in the console (it goes verbose to the log file).")
                    .hasArg(false).isRequired(false).create("v"));

    // Operation on corpus
    options.addOption(OptionBuilder.hasArg(false).withDescription("Performs an operation on a corpus.")
            .isRequired(false).create("O"));

    // The list of operations
    options.addOption(OptionBuilder.withDescription(
            "The list of operations you want to execute on the corpus. (e.g. PassageDistances,PassageSimilarity .")
            .hasArgs().withValueSeparator(',').withArgName("list").isRequired(false).withLongOpt("operations")
            .create());

    // The file to store the results
    options.addOption(OptionBuilder.withDescription("Folder where to store the results. (e.g. results/run01/).")
            .hasArg().withArgName("folder").isRequired(false).withLongOpt("oresults").create());

    // The corpus on which operate
    options.addOption(OptionBuilder.withDescription(
            "Lucene query that defines the corpus to operate with. (e.g. \"type:sentence AND reference:Document01\").")
            .hasArg().withArgName("query").isRequired(false).withLongOpt("ocorpus").create());

    // The corpus on which operate
    options.addOption(OptionBuilder.withDescription(
            "Use all documents in repository as single document corpora, it can be sentence or paragraph based. (e.g. sentence).")
            .hasArgs().withArgName("type").isRequired(false).withLongOpt("oalldocs").create());

    // The properties file for the corpus
    options.addOption(OptionBuilder.withDescription("Properties file with the corpus parameters (optional).")
            .hasArg().withArgName("parameter file").isRequired(false).withLongOpt("ocpar").create());

    // Background knowledge corpus
    options.addOption(OptionBuilder.withDescription(
            "Lucene query that defines a background knowledge on which the corpus will be projected. (e.g. \"type:sentences AND reference:Document*\").")
            .hasArg().withArgName("query").isRequired(false).withLongOpt("obk").create());

    // Background knowledge parameters
    options.addOption(OptionBuilder.withDescription(
            "Properties file with the background knowledge corpus parameters, if not set it will use the same as the corpus.")
            .hasArg().withArgName("parameter file").isRequired(false).withLongOpt("obkpar").create());

    // Term selection
    String criteria = "";
    for (TermSelection tsel : TermSelection.values()) {
        criteria += "," + tsel.name();
    }
    criteria = criteria.substring(1);
    options.addOption(OptionBuilder.hasArgs().withArgName("name")
            .withDescription("Name of the Term selection criteria (" + criteria + ").").isRequired(false)
            .withValueSeparator(',').withLongOpt("otsel").create());

    //   Term selection threshold
    options.addOption(OptionBuilder.hasArgs().withArgName("number")
            .withDescription("Threshold for the tsel criteria option.").withType(Integer.TYPE).isRequired(false)
            .withValueSeparator(',').withLongOpt("otselth").create());

    //   Dimensionality reduction
    criteria = "";
    for (DimensionalityReduction dim : DimensionalityReduction.values()) {
        criteria += "," + dim.name();
    }
    criteria = criteria.substring(1);
    options.addOption(OptionBuilder.hasArgs().withArgName("list")
            .withDescription("Name of the Dimensionality Reduction criteria. (e.g. " + criteria + ").")
            .isRequired(false).withValueSeparator(',').withLongOpt("odim").create());

    //   Dimensionality reduction threshold
    options.addOption(OptionBuilder.hasArgs().withArgName("list")
            .withDescription("Threshold for the dim options. (e.g. 0,1,2).").isRequired(false)
            .withValueSeparator(',').withLongOpt("odimth").create());

    //   Local weight
    criteria = "";
    for (LocalWeight weight : LocalWeight.values()) {
        criteria += "," + weight.name();
    }
    criteria = criteria.substring(1);
    options.addOption(OptionBuilder.hasArgs().withArgName("list")
            .withDescription("Name of the Local Weight to apply. (e.g." + criteria + ").").isRequired(false)
            .withValueSeparator(',').withLongOpt("otwl").create());

    //   Global weight
    criteria = "";
    for (GlobalWeight weight : GlobalWeight.values()) {
        criteria += "," + weight.name();
    }
    criteria = criteria.substring(1);
    options.addOption(OptionBuilder.hasArgs().withArgName("list")
            .withDescription("Name of the Global Weight to apply. (e.g. " + criteria + ").").isRequired(false)
            .withValueSeparator(',').withLongOpt("otwg").create());

    //   Use Lanczos
    options.addOption(OptionBuilder.hasArg(false).withDescription("Use Lanczos for SVD decomposition.")
            .isRequired(false).withLongOpt("olanczos").create());

    // Inserting documents in repository
    options.addOption(OptionBuilder.hasArg(false).withDescription("Insert documents into repository.")
            .isRequired(false).create("I"));

    // Max documents to insert
    options.addOption(OptionBuilder.hasArg().withArgName("number")
            .withDescription("Maximum number of documents to index or use in an operation.")
            .withType(Integer.TYPE).isRequired(false).withLongOpt("imaxdocs").create());

    // Clean repository
    options.addOption(
            OptionBuilder.hasArg(false).withDescription("Empties the repository before inserting new ones.")
                    .isRequired(false).withLongOpt("iclean").create());

    // Use annotator
    options.addOption(OptionBuilder.hasArgs()
            .withDescription(
                    "List of annotators to use when inserting the documents. (e.g. PennTreeAnnotator).")
            .isRequired(false).withValueSeparator(',').withLongOpt("iannotators").create());

    // Documents folder
    options.addOption(OptionBuilder.hasArg().withArgName("folder")
            .withDescription("The folder that contains the documens to insert.").isRequired(false)
            .withLongOpt("idocs").create());

    // Initializing the line parser
    CommandLineParser parser = new PosixParser();
    try {
        line = parser.parse(options, args);
    } catch (ParseException e) {
        printHelp(options);
        return;
    }

    // Validate that either inserting or an operation are given
    if (!line.hasOption("I") && !line.hasOption("O")) {
        System.out.println("One of the options -I or -O must be present.");
        printHelp(options);
        return;
    }

    repositoryFolder = line.getOptionValue("repo");

    try {
        if (line.hasOption("I")) {
            indexing();
        } else if (line.hasOption("O")) {
            operation();
        }
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        printHelp(options);
        return;
    }

    System.out.println("TML finished successfully in " + (System.nanoTime() - time) * 10E-9 + " seconds.");
    return;
}

From source file:Main.java

public static Class<?> wrapperType(Class<?> paramClass) {
    if (paramClass == Integer.TYPE)
        return Integer.class;
    if (paramClass == Long.TYPE)
        return Long.class;
    if (paramClass == Boolean.TYPE)
        return Boolean.class;
    if (paramClass == Double.TYPE)
        return Double.class;
    if (paramClass == Float.TYPE)
        return Float.class;
    if (paramClass == Byte.TYPE)
        return Byte.class;
    if (paramClass == Short.TYPE)
        return Short.class;
    if (paramClass == Character.TYPE)
        return Character.class;
    throw new IllegalArgumentException("Class " + paramClass.getName() + " is not a primitive type");
}

From source file:Main.java

private static Class<?> getRealClass(Object o) {
    Class<?> clazz = null;/*from   w  w w. jav  a2  s  .  c  o  m*/
    if (o instanceof Integer) {
        clazz = Integer.TYPE;
    } else if (o instanceof Float) {
        clazz = Float.TYPE;
    } else {
        clazz = o.getClass();
    }
    return clazz;
}

From source file:Main.java

public static void keep_setInt(Field field, Object obj, Cursor cursor, int i) {
    try {//  w w w  .jav a  2  s  . c o  m
        if (field.getType().equals(Integer.TYPE))
            field.setInt(obj, cursor.getInt(i));
        else
            field.set(obj, Integer.valueOf(cursor.getInt(i)));
    } catch (Exception exception) {
        exception.printStackTrace();
    }
}

From source file:Main.java

/**
 * Helper method used to get default value for wrappers used for primitive types
 * (0 for Integer etc)//from   w ww.  j ava2 s.  co m
 */
public static Object defaultValue(Class<?> cls) {
    if (cls == Integer.TYPE) {
        return Integer.valueOf(0);
    }
    if (cls == Long.TYPE) {
        return Long.valueOf(0L);
    }
    if (cls == Boolean.TYPE) {
        return Boolean.FALSE;
    }
    if (cls == Double.TYPE) {
        return Double.valueOf(0.0);
    }
    if (cls == Float.TYPE) {
        return Float.valueOf(0.0f);
    }
    if (cls == Byte.TYPE) {
        return Byte.valueOf((byte) 0);
    }
    if (cls == Short.TYPE) {
        return Short.valueOf((short) 0);
    }
    if (cls == Character.TYPE) {
        return '\0';
    }
    throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
}

From source file:Main.java

/**
 * Helper method for finding wrapper type for given primitive type (why isn't
 * there one in JDK?)/*from w w  w  . j av a  2  s . c o m*/
 */
public static Class<?> wrapperType(Class<?> primitiveType) {
    if (primitiveType == Integer.TYPE) {
        return Integer.class;
    }
    if (primitiveType == Long.TYPE) {
        return Long.class;
    }
    if (primitiveType == Boolean.TYPE) {
        return Boolean.class;
    }
    if (primitiveType == Double.TYPE) {
        return Double.class;
    }
    if (primitiveType == Float.TYPE) {
        return Float.class;
    }
    if (primitiveType == Byte.TYPE) {
        return Byte.class;
    }
    if (primitiveType == Short.TYPE) {
        return Short.class;
    }
    if (primitiveType == Character.TYPE) {
        return Character.class;
    }
    throw new IllegalArgumentException("Class " + primitiveType.getName() + " is not a primitive type");
}

From source file:Main.java

public static Class<?> findClass(String className) throws ClassNotFoundException {
    // [JACKSON-597]: support primitive types (and void)
    if (className.indexOf('.') < 0) {
        if ("int".equals(className))
            return Integer.TYPE;
        if ("long".equals(className))
            return Long.TYPE;
        if ("float".equals(className))
            return Float.TYPE;
        if ("double".equals(className))
            return Double.TYPE;
        if ("boolean".equals(className))
            return Boolean.TYPE;
        if ("byte".equals(className))
            return Byte.TYPE;
        if ("char".equals(className))
            return Character.TYPE;
        if ("short".equals(className))
            return Short.TYPE;
        if ("void".equals(className))
            return Void.TYPE;
    }/*from  w  ww.j  a  va2s  . c o m*/
    // Two-phase lookup: first using context ClassLoader; then default
    Throwable prob = null;
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    if (loader != null) {
        try {
            return Class.forName(className, true, loader);
        } catch (Exception e) {
            prob = getRootCause(e);
        }
    }
    try {
        return Class.forName(className);
    } catch (Exception e) {
        if (prob == null) {
            prob = getRootCause(e);
        }
    }
    if (prob instanceof RuntimeException) {
        throw (RuntimeException) prob;
    }
    throw new ClassNotFoundException(prob.getMessage(), prob);
}