Example usage for java.lang InstantiationException getLocalizedMessage

List of usage examples for java.lang InstantiationException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.neuralnet.AbstractNeuralNet.java

/**
 * <p>// w ww .j  a  va2s. co  m
 * Returns a copy of this neural net
 * </p>
 * @return INeuralNet Copy of this neural net
 */
public INeuralNet copy() {

    // Resulting neural net
    AbstractNeuralNet result = null;

    try {
        result = this.getClass().newInstance();

        // Copy the input layer
        result.inputLayer = this.inputLayer.copy();

        // Copy hidden layers
        ILayer<? extends INeuron> lastCopiedLayer = result.inputLayer;
        for (LinkedLayer hl : this.hiddenLayers) {
            // Copy hidden layer
            LinkedLayer hlr = hl.copy(lastCopiedLayer);
            result.addHlayer(hlr);

            // Update last copied layer
            lastCopiedLayer = hlr;
        }

        // Copy the output layer
        result.outputLayer = this.outputLayer.copy(lastCopiedLayer);
    } catch (InstantiationException e) {
        System.out.println("Instantiation Error " + e.getLocalizedMessage());
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        System.out.println("Illegal Access Error " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    return result;
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.neuralnet.LinkedLayer.java

/**
 * <p>//w  w  w.  j av  a  2s. c o  m
 * Returns a copy of this linked layer
 * </p>
 * @param previousLayer Previous layer to which copied neurons
 *                      are going to be linked
 * @return LinkedLayer Copy of this linked layer
 */
public LinkedLayer copy(ILayer<? extends INeuron> previousLayer) {

    LinkedLayer result = null;

    try {
        // Generate new layer
        result = this.getClass().newInstance();

        // Copy properties of the layer
        result.setMinnofneurons(this.minnofneurons);
        result.setInitialmaxnofneurons(this.initialmaxnofneurons);
        result.setMaxnofneurons(this.maxnofneurons);
        result.setType(this.type);
        result.setBiased(this.biased);

        // Copy each neuron
        for (LinkedNeuron neuron : this.neurons)
            result.addNeuron(neuron.copy(previousLayer));

    } catch (InstantiationException e) {
        System.out.println("Instantiation Error " + e.getLocalizedMessage());
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        System.out.println("Illegal Access Error " + e.getLocalizedMessage());
        e.printStackTrace();
    }

    return result;
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.neuralnet.LinkedNeuron.java

/**
 * <p>//from   w ww.  j a  v a 2 s  . c o m
 * Returns a copy of this linked neuron
 * </p>
 * @param previousLayer Previous layer to which copied neuron
 *                      is going to be linked
 * @return LinkedNeuron Copy of this linked neuron
 */
public LinkedNeuron copy(ILayer<? extends INeuron> previousLayer) {
    LinkedNeuron result = null;

    try {
        // Generate new neuron
        result = this.getClass().newInstance();

        // Copy biased property
        result.setBiased(this.biased);

        // Copy weight range
        result.setWeightRange(this.weightRange);

        // Copy links of the neuron
        Link resultLinks[] = new Link[this.links.length];
        for (int i = 0; i < this.links.length; i++) {

            // Generate new link
            resultLinks[i] = new Link();

            // Set link properties
            resultLinks[i].setBroken(this.links[i].isBroken());
            if (!resultLinks[i].isBroken()) {
                resultLinks[i].setWeight(this.links[i].getWeight());

                if (this.links[i].getOrigin() == null)
                    resultLinks[i].setOrigin(null);
                else
                    resultLinks[i].setOrigin(previousLayer.getNeuron(i));
                resultLinks[i].setTarget(result);
            }
        }
        result.setLinks(resultLinks);

    } catch (InstantiationException e) {
        System.out.println("Instantiation Error " + e.getLocalizedMessage());
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        System.out.println("Illegal Access Error " + e.getLocalizedMessage());
        e.printStackTrace();
    }

    return result;
}

From source file:org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory.java

public TemplateElement getProcessor(final Node nodeElement, final CompilationContext componentBean)
        throws CompilationException {
    TemplateElement returnValue = null;//from w  ww.j  av a2  s .co m

    short nodeType = nodeElement.getNodeType();
    if (Node.CDATA_SECTION_NODE == nodeType) {
        returnValue = new CDATAElement(nodeElement, componentBean);
    } else if (Node.TEXT_NODE == nodeType) {
        returnValue = new TextElement(nodeElement, componentBean);
    } else if (Node.COMMENT_NODE == nodeType) {
        returnValue = new CommentElement(nodeElement, componentBean);
    } else if (Node.PROCESSING_INSTRUCTION_NODE == nodeType) {
        returnValue = new PIElement(nodeElement, componentBean);
    } else if (Node.ELEMENT_NODE == nodeType) {
        String className = (String) mapClasses.get(nodeElement.getNodeName());

        if (className == null) {
            className = DEFAULT_CLASS_ELEMENT_PROCESSOR;
        }

        if (!className.equals("")) {
            Class class1;
            try {
                log.debug("loading class: " + className);

                class1 = Class.forName(className);
                Object[] objects = new Object[2];
                objects[0] = nodeElement;
                objects[1] = componentBean;

                returnValue = (TemplateElement) class1.getConstructor(paramClasses).newInstance(objects);
            } catch (InstantiationException e) {
                throw new CompilationException("InstantiationException: " + e.getLocalizedMessage(), e);
            } catch (IllegalAccessException e) {
                throw new CompilationException("IllegalAccessException: " + e.getLocalizedMessage(), e);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
                throw new CompilationException("InvocationTargetException: " + e.getMessage(), e);
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                throw new CompilationException(" error loading class: " + e.getLocalizedMessage());
            }
        }
    }
    return returnValue;
}

From source file:org.deegree.commons.utils.net.DURL.java

/**
 * @param url/*from w  w w.  j a v a  2  s.c o m*/
 */
public DURL(String url) {
    String protocol = url.split(":")[0];
    Class<? extends URLStreamHandler> handler = handlers.get(protocol);
    if (handler != null) {
        try {
            this.handler = handler.newInstance();
            this.url = new URL(null, url, this.handler);
        } catch (InstantiationException e) {
            LOG.debug("URL handler '{}' could not be instantiated: '{}'", handler.getSimpleName(),
                    e.getLocalizedMessage());
            LOG.trace("Stack trace:", e);
        } catch (IllegalAccessException e) {
            LOG.debug("URL handler constructor of '{}' could not be used: '{}'", handler.getSimpleName(),
                    e.getLocalizedMessage());
            LOG.trace("Stack trace:", e);
        } catch (MalformedURLException e) {
            LOG.debug("URL '{}' could not be instantiated: '{}'", url, e.getLocalizedMessage());
            LOG.trace("Stack trace:", e);
        }
    } else {
        try {
            this.url = new URL(url);
        } catch (MalformedURLException e) {
            LOG.debug("URL '{}' could not be instantiated: '{}'", url, e.getLocalizedMessage());
            LOG.trace("Stack trace:", e);
        }
    }
}

From source file:org.lsc.beans.LscBean.java

/**
 * Clone this Bean object./*ww w  .  j  a  va 2 s .  c om*/
 * 
 * @return Object
 * @throws java.lang.CloneNotSupportedException
 */
@Override
public LscBean clone() throws CloneNotSupportedException {
    try {
        LscBean bean = (LscBean) this.getClass().newInstance();
        bean.setMainIdentifier(this.getMainIdentifier());

        for (String attributeName : this.getAttributesNames()) {
            bean.setAttribute(attributeName, this.getDatasetAsSetById(attributeName));
        }
        return bean;
    } catch (InstantiationException ex) {
        throw new CloneNotSupportedException(ex.getLocalizedMessage());
    } catch (IllegalAccessException ex) {
        throw new CloneNotSupportedException(ex.getLocalizedMessage());
    }
}

From source file:samplecode.search.EveryEntry.java

/**
 * Starts all threads, one thread per task.
 *
 * @param executorService/*from   w w  w. j ava  2  s.co m*/
 *   the service providing a thread pool in which to execute
 *   tasks.
 * @param numThreads
 *   the number of threads (and tasks since there is one task
 *   per thread).
 *
 * @return a single result code.
 */
private ResultCode startSearches(final ExecutorService executorService, final int numThreads) {
    Validator.ensureNotNull(executorService);
    ResultCode resultCode = ResultCode.SUCCESS;
    for (int t = 0; t < numThreads; ++t) {
        final String searchListenerClassname = commandLineOptions.getSearchResultListenerClassname();
        EveryEntryImpl impl;
        try {
            /*
             * Get a connection to the server and create an error listener
             * for later assignment to a task. Create the task and submit to
             * the executor service.
             */
            final LDAPConnection ldapConnection = getConnection();
            final List<ErrorListener<ResultCode>> errorListeners = SampleCodeCollectionUtils.newArrayList();
            final ErrorListener<ResultCode> l = new ResultCodeErrorListener();
            errorListeners.add(l);
            impl = new EveryEntryImpl(searchListenerClassname, commandLineOptions, ldapConnection, getErr(),
                    errorListeners);
            final Log logger = LogFactory.getLog(getClass());
            final LdapExceptionListener ldapExceptionListener = new DefaultLdapExceptionListener(logger);
            impl.addLdapExceptionListener(ldapExceptionListener);
            executorService.submit(impl);
        } catch (final LDAPException ldapException) {
            resultCode = ldapException.getResultCode();
        } catch (final InstantiationException instantiationException) {
            err(formatter.format(new LogRecord(Level.SEVERE,
                    "Cannot instantiate " + instantiationException.getLocalizedMessage())));
            resultCode = ResultCode.PARAM_ERROR;
        } catch (final IllegalAccessException e) {
            resultCode = ResultCode.OPERATIONS_ERROR;
        } catch (final ClassNotFoundException classNotFoundException) {
            err(formatter
                    .format(new LogRecord(Level.SEVERE,
                            String.format(
                                    "The class '%s' " + "specified as the search "
                                            + "result listener could not be found.",
                                    searchListenerClassname))));
            resultCode = ResultCode.PARAM_ERROR;
        }
    }
    return resultCode;
}