Example usage for java.lang InstantiationException getMessage

List of usage examples for java.lang InstantiationException getMessage

Introduction

In this page you can find the example usage for java.lang InstantiationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.fengduo.bee.commons.core.lang.ArrayUtils.java

public static void main(String[] args) {
    String[] s = { "zxc", null, "msunmss", "" };
    s = ArrayUtils.replaceNullElement(s, new IHandle<String>() {

        @Override//  w  ww  . j a  v a  2  s . c  o m
        public boolean isNull(String obj) {
            return obj == null || StringUtils.isEmpty((String) obj);
        }

        @Override
        public String init(Class<String> clazz) {
            if (clazz.equals(String.class)) {
                return (String) new String("wu");
            }
            try {
                return clazz.newInstance();
            } catch (InstantiationException e) {
                System.out.println(e.getMessage());
            } catch (IllegalAccessException e) {
                System.out.println(e.getMessage());
            }
            System.out.println("replaceNullElement: init error");
            return null;
        }
    });
    System.out.println(StringUtils.join(s, ";"));

    String[] a = removeBlankElement(new String[] { "1", null, "2", "", "3" });
    for (int i = 0, j = a.length; i < j; i++) {
        System.out.println(a[i]);
    }

    String[] t = null;
    System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL"));
    System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL"));
    System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL"));
    System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL"));
    System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL"));
    t = new String[] { "1", null, "2", "", "3" };
    System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL"));
    System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL"));
    System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL"));
    System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL"));
    System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL"));
}

From source file:com.mmj.app.common.core.lang.ArrayUtils.java

public static void main(String[] args) {
    String[] s = { "zxc", null, "", "" };
    s = ArrayUtils.replaceNullElement(s, new IHandle<String>() {

        @Override//  w  w  w.ja va  2s .  c o  m
        public boolean isNull(String obj) {
            return obj == null || StringUtils.isEmpty((String) obj);
        }

        @Override
        public String init(Class<String> clazz) {
            if (clazz.equals(String.class)) {
                return (String) new String("wu");
            }
            try {
                return clazz.newInstance();
            } catch (InstantiationException e) {
                System.out.println(e.getMessage());
            } catch (IllegalAccessException e) {
                System.out.println(e.getMessage());
            }
            System.out.println("replaceNullElement: init error");
            return null;
        }
    });
    System.out.println(StringUtils.join(s, ";"));

    String[] a = removeBlankElement(new String[] { "1", null, "2", "", "3" });
    for (int i = 0, j = a.length; i < j; i++) {
        System.out.println(a[i]);
    }

    String[] t = null;
    System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL"));
    System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL"));
    System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL"));
    System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL"));
    System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL"));
    t = new String[] { "1", null, "2", "", "3" };
    System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL"));
    System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL"));
    System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL"));
    System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL"));
    System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL"));
}

From source file:com.zb.app.common.core.lang.ArrayUtils.java

public static void main(String[] args) {
    String[] s = { "zxc", null, "zuobian", "" };
    s = ArrayUtils.replaceNullElement(s, new IHandle<String>() {

        @Override// w w  w .  ja  v  a 2s  .c o m
        public boolean isNull(String obj) {
            return obj == null || StringUtils.isEmpty((String) obj);
        }

        @Override
        public String init(Class<String> clazz) {
            if (clazz.equals(String.class)) {
                return (String) new String("wu");
            }
            try {
                return clazz.newInstance();
            } catch (InstantiationException e) {
                System.out.println(e.getMessage());
            } catch (IllegalAccessException e) {
                System.out.println(e.getMessage());
            }
            System.out.println("replaceNullElement: init error");
            return null;
        }
    });
    System.out.println(StringUtils.join(s, ";"));

    String[] a = removeBlankElement(new String[] { "1", null, "2", "", "3" });
    for (int i = 0, j = a.length; i < j; i++) {
        System.out.println(a[i]);
    }

    String[] t = null;
    System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL"));
    System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL"));
    System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL"));
    System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL"));
    System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL"));
    t = new String[] { "1", null, "2", "", "3" };
    System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL"));
    System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL"));
    System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL"));
    System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL"));
    System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL"));
    System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL"));
}

From source file:net.jradius.server.Main.java

public static void main(String[] args) {
    if (args.length != 1) {
        showUsage();//from w w w  . j ava  2s  .co m
        System.exit(1);
    }

    /**
     * CADBiS daemon run
     * --->
     */
    if (JRadiusConfigurator.getInstance().getProperty("cadbis_daemon").equals("enabled"))
        CADBiS.getInstance().start();
    /**
     * <--- eof CADBiS
     */

    String configFilePath = args[0];

    try {
        File file = new File(configFilePath);
        Configuration.initialize(file);
        JRadiusServer server = new JRadiusServer();
        server.start();
    } catch (FileNotFoundException e) {
        System.err.println("Error: The configuration file '" + configFilePath + "' does not exist.");
    } catch (ConfigurationException e1) {
        System.err.println("Error: The configuration file could not be read,"
                + " because the file contains an error: " + e1.getMessage());
        showStackTrace(e1);
    } catch (SecurityException e2) {
        System.err.println("Error: The configuration file could not be read,"
                + " because a security error occurred: " + e2.getMessage());
        showStackTrace(e2);
    } catch (IllegalArgumentException e3) {
        System.err.println("Error: The configuration file could not be read,"
                + " because an illegal argument error occurred: " + e3.getMessage());
        showStackTrace(e3);
    } catch (ClassNotFoundException e4) {
        System.err.println("Error: The configuration file could not be read,"
                + " because a class specified in the configuration file could not be found: "
                + e4.getMessage());
        showStackTrace(e4);
    } catch (NoSuchMethodException e5) {
        System.err.println("Error: The configuration file could not be read,"
                + " because a method does not exist in a class specified in the configuration file: "
                + e5.getMessage());
        showStackTrace(e5);
    } catch (InstantiationException e6) {
        System.err.println("Error: The configuration file could not be read,"
                + " because an object specified in the configuration file could not be instantiated: "
                + e6.getMessage());
        showStackTrace(e6);
    } catch (IllegalAccessException e7) {
        System.err.println("Error: The configuration file could not be read,"
                + " because an illegal access error occurred: " + e7.getMessage());
        showStackTrace(e7);
    } catch (InvocationTargetException e8) {
        System.err.println("Error: The configuration file could not be read,"
                + " because an invocation target exception was thrown: " + e8.getMessage());
        showStackTrace(e8);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return;
}

From source file:nlp.wikiforia.App.java

/**
 * Application entrypoint/*from  www .j  a v  a2s . c o  m*/
 * @param args input arguments
 */
public static void main(String[] args) {
    Logger logger = LoggerFactory.getLogger(App.class);

    logger.info("Wikiforia v1.2.1 by Marcus Klang");

    Options options = new Options();
    options.addOption(index);
    options.addOption(pages);
    options.addOption(threads);
    options.addOption(batch);
    options.addOption(output);
    options.addOption(lang);
    options.addOption(hadoop);
    options.addOption(gzip);
    options.addOption(testDecompression);
    options.addOption(filterNs);
    options.addOption(outputFormatOption);

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmdline = parser.parse(options, args);

        File indexPath = null, pagesPath, outputPath;
        int batchsize = 100;
        int numThreads = Runtime.getRuntime().availableProcessors();
        String outputFormat = OUTPUT_FORMAT_DEFAULT;

        //Read batch size
        if (cmdline.hasOption(batch.getOpt())) {
            batchsize = Integer.parseInt(cmdline.getOptionValue(batch.getOpt()));
        }

        //Read num threads
        if (cmdline.hasOption(threads.getOpt())) {
            numThreads = Integer.parseInt(cmdline.getOptionValue(threads.getOpt()));
        }

        //Output format
        if (cmdline.hasOption(outputFormatOption.getOpt())) {
            outputFormat = cmdline.getOptionValue(outputFormatOption.getOpt());
        }

        //Read required paths
        pagesPath = new File(cmdline.getOptionValue(pages.getOpt()));
        outputPath = new File(cmdline.getOptionValue(output.getOpt()));

        //Create output directories if they do not exist
        if (!outputPath.getAbsoluteFile().getParentFile().getAbsoluteFile().exists()) {
            if (!outputPath.getParentFile().getAbsoluteFile().mkdirs()) {
                throw new IOError(new IOException(
                        "Failed to create directories for " + outputPath.getParentFile().getAbsolutePath()));
            }
        }

        //To to automatically select an index file if it does not exits
        if (!cmdline.hasOption(index.getOpt())) {
            //try to automatically identify if there is an index file
            if (pagesPath.getAbsolutePath().toLowerCase().endsWith("-multistream.xml.bz2")) {
                int pos = pagesPath.getAbsolutePath().lastIndexOf("-multistream.xml.bz2");
                indexPath = new File(
                        pagesPath.getAbsolutePath().substring(0, pos) + "-multistream-index.txt.bz2");
                if (!indexPath.exists())
                    indexPath = null;
            }
        } else {
            indexPath = new File(cmdline.getOptionValue(index.getOpt()));
        }

        //Validation
        if (!pagesPath.exists()) {
            logger.error("pages with absolute filepath {} could not be found.", pagesPath.getAbsolutePath());
            return;
        }

        if (indexPath != null && !indexPath.exists()) {
            logger.error("Could not find index file {}.", indexPath.getAbsolutePath());
            logger.error("Skipping index and continuing with singlestream parsing (no threaded decompression)");
            indexPath = null;
        }

        String langId;
        if (cmdline.hasOption(lang.getOpt())) {
            langId = cmdline.getOptionValue(lang.getOpt());
        } else {
            Pattern langmatcher = Pattern.compile("([a-z]{2})wiki-");
            Matcher matcher = langmatcher.matcher(pagesPath.getName());
            if (matcher.find()) {
                langId = matcher.group(1).toLowerCase();
            } else {
                logger.error("Could not find a suitable language, will default to English");
                langId = "en";
            }
        }

        ArrayList<Filter<WikipediaPage>> filters = new ArrayList<Filter<WikipediaPage>>();
        if (cmdline.hasOption(filterNs.getOpt())) {
            String optionValue = cmdline.getOptionValue(filterNs.getOpt());
            final TreeSet<Integer> ns = new TreeSet<Integer>();
            for (String s : optionValue.split(",")) {
                ns.add(Integer.parseInt(s));
            }

            if (ns.size() > 0) {
                filters.add(new Filter<WikipediaPage>() {
                    @Override
                    protected boolean accept(WikipediaPage item) {
                        return ns.contains(item.getNamespace());
                    }

                    @Override
                    public String toString() {
                        return String.format("Namespace filter { namespaces: %s }", StringUtils.join(ns, ","));
                    }
                });
            }
        }

        TemplateConfig config;
        Class<? extends TemplateConfig> configClazz = LangFactory.get(langId);
        if (configClazz != null) {
            try {
                config = configClazz.newInstance();
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        } else {
            config = new EnglishConfig();
            logger.error(
                    "language {} is not yet supported and will be defaulted to a English setting for Sweble.",
                    langId);
            langId = "en";
        }

        if (cmdline.hasOption(hadoop.getOpt())) {
            if (outputPath.exists()) {
                logger.error("The target location already exists, please remove before using the tool!");
                System.exit(1);
            } else {
                int splitsize = 64000000;
                if (cmdline.hasOption(App.splitsize.getOpt())) {
                    splitsize = Integer.parseInt(cmdline.getOptionValue(App.splitsize.getOpt()));
                }

                hadoopConvert(config, indexPath, pagesPath, outputPath, numThreads, batchsize, splitsize,
                        cmdline.hasOption(gzip.getOpt()), filters);
            }
        } else {
            if (cmdline.hasOption(testDecompression.getOpt())) {
                test(config, indexPath, pagesPath, numThreads, batchsize);
            } else {
                convert(config, indexPath, pagesPath, outputPath, numThreads, batchsize, filters, outputFormat);
            }
        }

    } catch (ParseException e) {
        System.out.println(e.getMessage());
        HelpFormatter writer = new HelpFormatter();
        writer.printHelp("wikiforia", options);
    }
}

From source file:org.openiam.idm.srvc.auth.context.AuthContextFactory.java

public static AuthenticationContext createContext(String className) throws ClassNotFoundException {
    Class cls = Class.forName(className);
    try {/*from  w w w  . ja  va2 s.  c om*/
        return (AuthenticationContext) cls.newInstance();
    } catch (IllegalAccessException ia) {
        log.error(ia.getMessage(), ia);

    } catch (InstantiationException ie) {
        log.error(ie.getMessage(), ie);
    }
    return null;

}

From source file:org.openiam.idm.srvc.auth.spi.LoginModuleFactory.java

public static LoginModule createModule(String className) throws ClassNotFoundException {
    Class cls = Class.forName(className);
    try {// w w  w.j a  v a  2  s. c om
        return (LoginModule) cls.newInstance();
    } catch (IllegalAccessException ia) {
        log.error(ia.getMessage(), ia);

    } catch (InstantiationException ie) {
        log.error(ie.getMessage(), ie);
    }
    return null;

}

From source file:org.openiam.script.ScriptFactory.java

public static ScriptIntegration createModule(String className) throws ClassNotFoundException {
    Class cls = Class.forName(className);
    try {/*from ww  w.  jav a 2  s. c  o m*/
        return (ScriptIntegration) cls.newInstance();
    } catch (IllegalAccessException ia) {
        log.error(ia.getMessage(), ia);

    } catch (InstantiationException ie) {
        log.error(ie.getMessage(), ie);
    }
    return null;

}

From source file:org.josso.ComponentKeeperFactory.java

public static ComponentKeeperFactory getInstance() {

    if (System.getProperty(COMPONENT_KEEKPER_FACTORY) != null)
        factoryClass = System.getProperty(COMPONENT_KEEKPER_FACTORY);

    try {//from  w ww.  ja  v a2  s .c om
        return (ComponentKeeperFactory) Class.forName(factoryClass).newInstance();

    } catch (InstantiationException e) {
        logger.error(e.getMessage(), e);
        throw new FactoryConfigurationError(e);

    } catch (IllegalAccessException e) {
        logger.error(e.getMessage(), e);
        throw new FactoryConfigurationError(e);

    } catch (ClassNotFoundException e) {
        logger.warn("Class not found : " + factoryClass);
        throw new FactoryConfigurationError(e);
    }

}

From source file:org.josso.agent.config.ComponentKeeperFactory.java

public static ComponentKeeperFactory getInstance() {

    if (System.getProperty(COMPONENT_KEEKPER_FACTORY) != null)
        factoryClass = System.getProperty(COMPONENT_KEEKPER_FACTORY);

    try {// w ww  .java2  s .c  o  m
        ComponentKeeperFactory f = (ComponentKeeperFactory) Class.forName(factoryClass).newInstance();
        return new SpringComponentKeeperFactoryImpl();

    } catch (InstantiationException e) {
        logger.error(e.getMessage(), e);
        throw new FactoryConfigurationError(e);

    } catch (IllegalAccessException e) {
        logger.error(e.getMessage(), e);
        throw new FactoryConfigurationError(e);

    } catch (ClassNotFoundException e) {
        logger.warn("Class not found : " + factoryClass);
        throw new FactoryConfigurationError(e);
    }

}