Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public LafManager getLafManager() {
    if (lafManager == null) {
        try {/*from  w ww. j a  v a2s  . com*/
            String lafName = Messages.getMetaString("LafManager");
            lafManager = (LafManager) Class.forName(lafName)
                    .getConstructor(new Class[] { GraphicManager.class }).newInstance(new Object[] { this });
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //lafManager=new LafManager(this);
    }
    return lafManager;
}

From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java

public String GetInternetData(String sHost, String sPort, String sURL) {
    String sRet = "";
    String sNewURL = "";
    HttpClient httpClient = new DefaultHttpClient();
    try {//from   w w  w .j  a  va  2 s . c  om
        sNewURL = "http://" + sHost + ((sPort.length() > 0) ? (":" + sPort) : "") + sURL;

        HttpGet request = new HttpGet(sNewURL);
        HttpResponse response = httpClient.execute(request);
        int status = response.getStatusLine().getStatusCode();
        // we assume that the response body contains the error message
        if (status != HttpStatus.SC_OK) {
            ByteArrayOutputStream ostream = new ByteArrayOutputStream();
            response.getEntity().writeTo(ostream);
            Log.e("HTTP CLIENT", ostream.toString());
        } else {
            InputStream content = response.getEntity().getContent();
            byte[] data = new byte[2048];
            int nRead = content.read(data);
            sRet = new String(data, 0, nRead);
            content.close(); // this will also close the connection
        }
    } catch (IllegalArgumentException e) {
        sRet = e.getLocalizedMessage();
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        sRet = e.getLocalizedMessage();
        e.printStackTrace();
    } catch (IOException e) {
        sRet = e.getLocalizedMessage();
        e.printStackTrace();
    }

    return (sRet);
}

From source file:de.tu_dortmund.ub.hb_ng.SolRDF.java

private String doResourceRequest(String graph, String uri, String format, boolean isAuthorized)
        throws LinkedDataStorageException {

    this.logger.info("doResourceRequest: graph=" + graph);
    this.logger.info("doResourceRequest: uri=" + uri);
    this.logger.info("doResourceRequest: format=" + format);
    this.logger.info("doResourceRequest: isAuthorized=" + isAuthorized);

    if (graph == null || graph.equals("")) {

        graph = this.config.getProperty("storage.graph.default");
    }//  ww w. j  a v  a 2 s .  co m
    this.logger.info("doResourceRequest: graph=" + graph);

    String result = null;

    try {

        // query resource in de.tu_dortmund.ub.hb_ng.data.SolRDF
        String selectQuery = "SELECT ?p ?o ?c WHERE { GRAPH ?c { <" + uri + "> ?p ?o } }"; // TODO config

        String resultString = this.sparqlQuery(null, URLEncoder.encode(selectQuery, "UTF-8"), "xml",
                isAuthorized);

        // postprocessing
        SPARQLResultsXMLParser xmlRes = new SPARQLResultsXMLParser();
        TupleQueryResultBuilder build = new TupleQueryResultBuilder();
        xmlRes.setTupleQueryResultHandler(build);

        ByteArrayInputStream is = new ByteArrayInputStream(resultString.getBytes("UTF-8"));
        xmlRes.parse(is);

        TupleQueryResult tupleRes = build.getQueryResult();
        List<String> bindingNames = tupleRes.getBindingNames();

        ArrayList<Statement> statements = new ArrayList<Statement>();
        ValueFactory valueFactory = ValueFactoryImpl.getInstance();

        while (tupleRes.hasNext()) {

            BindingSet bindingSet = tupleRes.next();

            String predicate = bindingSet.getValue(bindingNames.get(0)).stringValue();
            String object = bindingSet.getValue(bindingNames.get(1)).stringValue();
            String context = bindingSet.getValue(bindingNames.get(2)).stringValue();

            // isAuthorized > public + nonpublic
            if (isAuthorized && context.contains(this.config.getProperty("storage.graph.main"))
                    || context.contains(graph)) {

                try {
                    statements.add(valueFactory.createStatement(valueFactory.createURI(uri),
                            valueFactory.createURI(predicate), valueFactory.createURI(object),
                            valueFactory.createURI(context)));
                } catch (IllegalArgumentException e) {
                    statements.add(valueFactory.createStatement(valueFactory.createURI(uri),
                            valueFactory.createURI(predicate), valueFactory.createLiteral(object),
                            valueFactory.createURI(context)));
                }
            }
            // !isAuthorized > public
            if (!isAuthorized && context.endsWith(this.config.getProperty("storage.graph.main") + "-public")
                    || context.endsWith(graph + "-public")) {

                try {
                    statements.add(valueFactory.createStatement(valueFactory.createURI(uri),
                            valueFactory.createURI(predicate), valueFactory.createURI(object),
                            valueFactory.createURI(context)));
                } catch (IllegalArgumentException e) {
                    statements.add(valueFactory.createStatement(valueFactory.createURI(uri),
                            valueFactory.createURI(predicate), valueFactory.createLiteral(object),
                            valueFactory.createURI(context)));
                }
            }
        }

        if (statements.size() == 0) {

            result = null;
        } else {

            RDFFormat formatString;
            switch (format) {

            case "html": {

                formatString = RDFFormat.RDFXML;
                break;
            }
            case "rdf.xml": {

                formatString = RDFFormat.RDFXML;
                break;
            }
            case "rdf.ttl": {

                formatString = RDFFormat.TURTLE;
                break;
            }
            case "json": {

                formatString = RDFFormat.JSONLD;
                break;
            }
            case "nquads": {

                formatString = RDFFormat.NQUADS;
                break;
            }
            default: {

                formatString = RDFFormat.NQUADS;
            }
            }

            StringWriter stringWriter = new StringWriter();
            RDFWriter writer = Rio.createWriter(formatString, stringWriter);
            writer.startRDF();
            for (Statement statement : statements) {
                writer.handleStatement(statement);
            }
            writer.endRDF();

            result = stringWriter.toString();
        }
    } catch (Exception e) {

        e.printStackTrace();
        this.logger.error("[" + this.getClass().getName() + "] " + new Date()
                + " - ERROR: Requesting Linked Media Framework: " + uri + " - " + e.getMessage());
        throw new LinkedDataStorageException(e.getMessage(), e.getCause());
    }

    return result;
}

From source file:axiom.servlet.AbstractServletClient.java

/**
 * Handle a request./*from  ww w  .  ja v  a  2s . c o m*/
 *
 * @param request ...
 * @param response ...
 *
 * @throws ServletException ...
 * @throws IOException ...
 */
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    final String httpMethod = request.getMethod();
    if (!"POST".equalsIgnoreCase(httpMethod) && !"GET".equalsIgnoreCase(httpMethod)) {
        sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "HTTP Method " + httpMethod + " not supported.");
        return;
    }

    RequestTrans reqtrans = new RequestTrans(request, response, getPathInfo(request));

    try {
        // get the character encoding
        String encoding = request.getCharacterEncoding();

        if (encoding == null) {
            // no encoding from request, use the application's charset
            encoding = getApplication().getCharset();
        }

        // read and set http parameters
        parseParameters(request, reqtrans, encoding);

        List uploads = null;
        ServletRequestContext reqcx = new ServletRequestContext(request);

        if (ServletFileUpload.isMultipartContent(reqcx)) {
            // get session for upload progress monitoring
            UploadStatus uploadStatus = getApplication().getUploadStatus(reqtrans);
            try {
                uploads = parseUploads(reqcx, reqtrans, uploadStatus, encoding);
            } catch (Exception upx) {
                System.err.println("Error in file upload: " + upx);
                if (uploadSoftfail) {
                    String msg = upx.getMessage();
                    if (msg == null || msg.length() == 0) {
                        msg = upx.toString();
                    }
                    reqtrans.set("axiom_upload_error", msg);
                } else if (upx instanceof FileUploadBase.SizeLimitExceededException) {
                    sendError(response, HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE,
                            "File upload size exceeds limit of " + uploadLimit + "kB");
                    return;
                } else {
                    sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                            "Error in file upload: " + upx);
                    return;
                }
            }
        }

        parseCookies(request, reqtrans, encoding);

        // do standard HTTP variables
        String host = request.getHeader("Host");

        if (host != null) {
            host = host.toLowerCase();
            reqtrans.set("http_host", host);
        }

        String referer = request.getHeader("Referer");

        if (referer != null) {
            reqtrans.set("http_referer", referer);
        }

        try {
            long ifModifiedSince = request.getDateHeader("If-Modified-Since");

            if (ifModifiedSince > -1) {
                reqtrans.setIfModifiedSince(ifModifiedSince);
            }
        } catch (IllegalArgumentException ignore) {
        }

        String ifNoneMatch = request.getHeader("If-None-Match");

        if (ifNoneMatch != null) {
            reqtrans.setETags(ifNoneMatch);
        }

        String remotehost = request.getRemoteAddr();

        if (remotehost != null) {
            reqtrans.set("http_remotehost", remotehost);
        }

        // get the cookie domain to use for this response, if any.
        String resCookieDomain = cookieDomain;

        if (resCookieDomain != null) {
            // check if cookieDomain is valid for this response.
            // (note: cookieDomain is guaranteed to be lower case)
            // check for x-forwarded-for header, fix for bug 443
            String proxiedHost = request.getHeader("x-forwarded-host");
            if (proxiedHost != null) {
                if (proxiedHost.toLowerCase().indexOf(cookieDomain) == -1) {
                    resCookieDomain = null;
                }
            } else if ((host != null) && host.toLowerCase().indexOf(cookieDomain) == -1) {
                resCookieDomain = null;
            }
        }

        // check if session cookie is present and valid, creating it if not.
        checkSessionCookie(request, response, reqtrans, resCookieDomain);

        String browser = request.getHeader("User-Agent");

        if (browser != null) {
            reqtrans.set("http_browser", browser);
        }

        String language = request.getHeader("Accept-Language");

        if (language != null) {
            reqtrans.set("http_language", language);
        }

        String authorization = request.getHeader("authorization");

        if (authorization != null) {
            reqtrans.set("authorization", authorization);
        }

        ResponseTrans restrans = getApplication().execute(reqtrans);

        // if the response was already written and committed by the application
        // we can skip this part and return
        if (response.isCommitted()) {
            return;
        }

        // set cookies
        if (restrans.countCookies() > 0) {
            CookieTrans[] resCookies = restrans.getCookies();

            for (int i = 0; i < resCookies.length; i++)
                try {
                    Cookie c = resCookies[i].getCookie("/", resCookieDomain);

                    response.addCookie(c);
                } catch (Exception ignore) {
                    ignore.printStackTrace();
                }
        }

        // write response
        writeResponse(request, response, reqtrans, restrans);

    } catch (Exception x) {
        try {
            if (debug) {
                sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Server error: " + x);
                x.printStackTrace();
            } else {
                sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "The server encountered an error while processing your request. "
                                + "Please check back later.");
            }

            log("Exception in execute: " + x);
        } catch (IOException io_e) {
            log("Exception in sendError: " + io_e);
        }
    }
}

From source file:edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.sav.SAVFileReader.java

public TabularDataIngest read(BufferedInputStream stream, File dataFile) throws IOException {
    dbgLog.info("SAVFileReader: read() start");

    if (dataFile != null) {
        throw new IOException("this plugin does not support external raw data files");
    }//from   w ww  .ja v a  2s .co  m

    /* 
     * this "try" block is for catching unknown/unexpected exceptions 
     * thrown anywhere in the ingest code:
     */
    try {
        /* ingest happens here ... */

        // the following methods are now executed, in this order:

        // decodeHeader -- this method doesn't read any [meta]data and 
        //    doesn't initialize any values; its only purpose is to 
        //    make sure that the file is indeed an SPSS/SAV file. 
        // 
        // decodeRecordType1 -- there's always one RT1 record; it is 
        //    always 176 byte long. it contains the very basic metadata
        //    about the data file. most notably, the number of observations
        //    and the number of OBS (8 byte values) per observation.
        //
        // decodeRecordType2 -- there are multiple RT2 records. there's 
        //    one RT2 for every OBS (8 byte value); i.e. one per variable,
        //    or more per every String variable split into multiple OBS
        //    segments. this one is a 400 line method, that may benefit 
        //    from being split into smaller methods.
        //
        // decodeRecordType3and4 -- these sections come in pairs, each
        //    pair dedicated to one set of variable labels. 
        // decodeRecordType6,
        //
        // decodeRecordType7 -- this RT contains some extended 
        //    metadata for the data file. (including the information 
        //    about the extended variables, i.e. variables longer than
        //    255 bytes split into 255 byte fragments that are stored 
        //    in the data file as independent variables). 
        //
        // decodeRecordType999 -- this RT does not contain any data; 
        //    its sole function is to indicate that the metadata portion 
        //    of the data file is over and the data section follows. 
        // 
        // decodeRecordTypeData -- this method decodes the data section 
        //    of the file. Inside this method, 2 distinct methods are 
        //    called to process compressed or uncompressed data, depending
        //    on which method is used in this data file. 

        String methodCurrentlyExecuted = null;

        try {
            methodCurrentlyExecuted = "decodeHeader";
            dbgLog.fine("***** SAVFileReader: executing method decodeHeader");
            decodeHeader(stream);

            methodCurrentlyExecuted = "decodeRecordType1";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordType1");
            decodeRecordType1(stream);

            methodCurrentlyExecuted = "decodeRecordType2";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordType1");
            decodeRecordType2(stream);

            methodCurrentlyExecuted = "decodeRecordType3and4";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordType3and4");
            decodeRecordType3and4(stream);

            methodCurrentlyExecuted = "decodeRecordType6";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordType6");
            decodeRecordType6(stream);

            methodCurrentlyExecuted = "decodeRecordType7";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordType7");
            decodeRecordType7(stream);

            methodCurrentlyExecuted = "decodeRecordType999";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordType999");
            decodeRecordType999(stream);

            methodCurrentlyExecuted = "decodeRecordTypeData";
            dbgLog.fine("***** SAVFileReader: executing method decodeRecordTypeData");
            decodeRecordTypeData(stream);

        } catch (IllegalArgumentException e) {
            //Throwable cause = e.getCause();
            dbgLog.fine("***** SAVFileReader: ATTENTION: IllegalArgumentException thrown while executing "
                    + methodCurrentlyExecuted);
            e.printStackTrace();
            throw new IOException(
                    "IllegalArgumentException in method " + methodCurrentlyExecuted + ": " + e.getMessage());
        } catch (IOException e) {
            dbgLog.fine("***** SAVFileReader: ATTENTION: IOException thrown while executing "
                    + methodCurrentlyExecuted);
            e.printStackTrace();
            throw new IOException("IO Exception in method " + methodCurrentlyExecuted + ": " + e.getMessage());
        }

        /* 
         * Final variable type assignments;
         * TODO: (maybe?) 
         * Instead of doing it here, perhaps all the type assignments need to 
         * be done on DataVariable objects directly;  without relying on 
         * maps and lists here... -- L.A. 4.0 beta (?)
         */

        for (int indx = 0; indx < variableTypelList.size(); indx++) {
            String varName = dataTable.getDataVariables().get(indx).getName();
            int simpleType = 0;
            if (variableTypelList.get(indx) != null) {
                simpleType = variableTypelList.get(indx).intValue();
            }

            if (simpleType <= 0) {
                // We need to make one last type adjustment:
                // Dates and Times will be stored as character values in the 
                // dataverse tab files; even though they are not typed as 
                // strings at this point:
                // TODO: 
                // Make sure the date/time format is properly preserved!
                // (see the setFormatCategory below... but double-check!)
                // -- L.A. 4.0 alpha
                String variableFormatType = variableFormatTypeList[indx];
                if (variableFormatType != null) {
                    if (variableFormatType.equals("time") || variableFormatType.equals("date")) {
                        simpleType = 1;

                        String formatCategory = formatCategoryTable.get(varName);

                        if (formatCategory != null) {
                            if (dateFormatList[indx] != null) {
                                dbgLog.fine("setting format category to " + formatCategory);
                                dataTable.getDataVariables().get(indx).setFormatCategory(formatCategory);
                                dbgLog.fine("setting formatschemaname to " + dateFormatList[indx]);
                                dataTable.getDataVariables().get(indx).setFormat(dateFormatList[indx]);
                            }
                        }
                    } else if (variableFormatType.equals("other")) {
                        dbgLog.fine("Variable of format type \"other\"; type adjustment may be needed");
                        dbgLog.fine("SPSS print format: "
                                + printFormatTable.get(dataTable.getDataVariables().get(indx).getName()));

                        if (printFormatTable.get(dataTable.getDataVariables().get(indx).getName())
                                .equals("WKDAY")
                                || printFormatTable.get(dataTable.getDataVariables().get(indx).getName())
                                        .equals("MONTH")) {
                            // week day or month; 
                            // These are not treated as time/date values (meaning, we 
                            // don't define time/date formats for them; there's likely 
                            // no valid ISO time/date format for just a month or a day 
                            // of week). However, the
                            // values will be stored in the TAB files as strings, 
                            // and not as numerics - as they were stored in the 
                            // SAV file. So we need to adjust the type here.
                            // -- L.A. 

                            simpleType = 1;
                        }
                    }
                }
            }

            // OK, we can now assign the types: 

            if (simpleType > 0) {
                // String: 
                dataTable.getDataVariables().get(indx).setTypeCharacter();
                dataTable.getDataVariables().get(indx).setIntervalDiscrete();
            } else {
                // Numeric: 
                dataTable.getDataVariables().get(indx).setTypeNumeric();
                // discrete or continuous?
                // "decimal variables" become dataverse data variables of interval type "continuous":

                if (decimalVariableSet.contains(indx)) {
                    dataTable.getDataVariables().get(indx).setIntervalContinuous();
                } else {
                    dataTable.getDataVariables().get(indx).setIntervalDiscrete();
                }

            }

            // TODO: take care of the SPSS "shortToLongVariableNameTable"
            // mapping before returning the ingested data object. -- 4.0 alpha
            // (done, below - but verify!)

            if (shortToLongVariableNameTable.containsKey(varName)) {
                String longName = shortToLongVariableNameTable.get(varName);
                if (longName != null && !longName.equals("")) {
                    dataTable.getDataVariables().get(indx).setName(longName);
                }
            }

        }

        ingesteddata.setDataTable(dataTable);
    } catch (Exception ex) {
        dbgLog.fine("***** SAVFileReader: ATTENTION: unknown exception thrown.");
        ex.printStackTrace();
        String failureMessage = "Unknown exception in SPSS/SAV reader";
        if (ex.getMessage() != null) {
            failureMessage = failureMessage.concat(": " + ex.getMessage());
        } else {
            failureMessage = failureMessage.concat("; no further information is available.");
        }
        throw new IOException(failureMessage);
    }
    dbgLog.info("SAVFileReader: read() end");
    return ingesteddata;
}

From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.sav.SAVFileReader.java

/**
 * Read the given SPSS SAV-format file via a <code>BufferedInputStream</code>
 * object.  This method calls an appropriate method associated with the given 
 * field header by reflection.//from   ww  w.ja  va 2  s.co  m
 * 
 * @param stream a <code>BufferedInputStream</code>.
 * @return an <code>SDIOData</code> object
 * @throws java.io.IOException if an reading error occurs.
 */
@Override
public SDIOData read(BufferedInputStream stream, File dataFile) throws IOException {

    dbgLog.fine("***** SAVFileReader: read() start *****");

    if (dataFile != null) {
        throw new IOException("this plugin does not support external raw data files");
    }

    // the following methods are now executed, in this order:

    // decodeHeader -- this method doesn't read any [meta]data and 
    //    doesn't initialize any values; its only purpose is to 
    //    make sure that the file is indeed an SPSS/SAV file. 
    // 
    // decodeRecordType1 -- there's always one RT1 record; it is 
    //    always 176 byte long. it contains the very basic metadata
    //    about the data file. most notably, the number of observations
    //    and the number of OBS (8 byte values) per observation.
    //
    // decodeRecordType2 -- there are multiple RT2 records. there's 
    //    one RT2 for every OBS (8 byte value); i.e. one per variable,
    //    or more per every String variable split into multiple OBS
    //    segments. this one is a 400 line method, that may benefit 
    //    from being split into smaller methods.
    //
    // decodeRecordType3and4 -- these sections come in pairs, each
    //    pair dedicated to one set of variable labels. 
    // decodeRecordType6,
    //
    // decodeRecordType7 -- this RT contains some extended 
    //    metadata for the data file. (including the information 
    //    about the extended variables, i.e. variables longer than
    //    255 bytes split into 255 byte fragments that are stored 
    //    in the data file as independent variables). 
    //
    // decodeRecordType999 -- this RT does not contain any data; 
    //    its sole function is to indicate that the metadata portion 
    //    of the data file is over and the data section follows. 
    // 
    // decodeRecordTypeData -- this method decodes the data section 
    //    of the file. Inside this method, 2 distinct methods are 
    //    called to process compressed or uncompressed data, depending
    //    on which method is used in this data file. 

    String methodCurrentlyExecuted = null;

    try {
        methodCurrentlyExecuted = "decodeHeader";
        dbgLog.fine("***** SAVFileReader: executing method decodeHeader");
        decodeHeader(stream);

        methodCurrentlyExecuted = "decodeRecordType1";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType1");
        decodeRecordType1(stream);

        methodCurrentlyExecuted = "decodeRecordType2";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType1");
        decodeRecordType2(stream);

        methodCurrentlyExecuted = "decodeRecordType3and4";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType3and4");
        decodeRecordType3and4(stream);

        methodCurrentlyExecuted = "decodeRecordType6";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType6");
        decodeRecordType6(stream);

        methodCurrentlyExecuted = "decodeRecordType7";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType7");
        decodeRecordType7(stream);

        methodCurrentlyExecuted = "decodeRecordType999";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType999");
        decodeRecordType999(stream);

        methodCurrentlyExecuted = "decodeRecordTypeData";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordTypeData");
        decodeRecordTypeData(stream);

    } catch (IllegalArgumentException e) {
        //Throwable cause = e.getCause();
        dbgLog.fine("***** SAVFileReader: ATTENTION: IllegalArgumentException thrown while executing "
                + methodCurrentlyExecuted);
        e.printStackTrace();
        throw new IllegalArgumentException("in method " + methodCurrentlyExecuted + ": " + e.getMessage());
    } catch (IOException e) {
        dbgLog.fine("***** SAVFileReader: ATTENTION: IOException thrown while executing "
                + methodCurrentlyExecuted);
        e.printStackTrace();
        throw new IOException("in method " + methodCurrentlyExecuted + ": " + e.getMessage());
    }

    /* Final correction of the "variable type list" values: 
     * The date/time values are stored as character strings by the DVN, 
     * so the type information needs to be adjusted accordingly:
     *          -- L.A., v3.6 
     */
    int[] variableTypeMinimal = ArrayUtils
            .toPrimitive(variableTypelList.toArray(new Integer[variableTypelList.size()]));

    for (int indx = 0; indx < variableTypelList.size(); indx++) {
        int simpleType = 0;
        if (variableTypelList.get(indx) != null) {
            simpleType = variableTypelList.get(indx).intValue();
        }

        if (simpleType <= 0) {
            // NOT marked as a numeric at this point;
            // but is it a date/time/etc.?
            String variableFormatType = variableFormatTypeList[indx];
            if (variableFormatType != null
                    && (variableFormatType.equals("time") || variableFormatType.equals("date"))) {
                variableTypeMinimal[indx] = 1;
            }
        }
    }

    smd.setVariableTypeMinimal(variableTypeMinimal);

    if (sdiodata == null) {
        sdiodata = new SDIOData(smd, savDataSection);
    }
    dbgLog.fine("***** SAVFileReader: read() end *****");
    return sdiodata;

}

From source file:com.log4ic.compressor.servlet.CompressionServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    if (!initialized) {
        String cacheDir;//from w w w . ja  va 2s.c o  m
        CacheType cacheType = null;
        Integer cacheCount = null;
        boolean autoClean = true;
        int cleanHourAgo = 4;
        int lowHit = 3;
        if (config != null) {
            //?
            cacheDir = config.getInitParameter("cacheDir");
            if (StringUtils.isNotBlank(cacheDir)) {
                if (cacheDir.startsWith("{contextPath}")) {
                    cacheDir = getRootAbsolutePath(config.getServletContext())
                            + cacheDir.replace("{contextPath}", "");
                }
                cacheDir = FileUtils.appendSeparator(cacheDir);
            } else {
                cacheDir = getRootAbsolutePath(config.getServletContext()) + "static/compressed/";
            }
            //
            String cacheTypeStr = config.getInitParameter("cacheType");
            if (StringUtils.isNotBlank(cacheTypeStr)) {
                try {
                    cacheType = CacheType.valueOf(cacheTypeStr.toUpperCase());
                } catch (IllegalArgumentException e) {
                }
            }
            if ("none".equals(cacheTypeStr)) {
                cacheType = null;
            }
            //
            String cacheCountStr = config.getInitParameter("cacheCount");
            if (StringUtils.isNotBlank(cacheCountStr)) {
                try {
                    cacheCount = Integer.parseInt(cacheCountStr);
                } catch (Exception e) {
                }
            }
            if (cacheCount == null) {
                cacheCount = 5000;
            }

            String autoCleanStr = config.getInitParameter("autoClean");

            if (StringUtils.isNotBlank(autoCleanStr)) {
                try {
                    autoClean = Boolean.parseBoolean(autoCleanStr);
                } catch (Exception e) {
                }
            }

            String fileDomain = config.getInitParameter("fileDomain");

            if (StringUtils.isNotBlank(fileDomain)) {
                CompressionServlet.fileDomain = fileDomain;
            }

            Class cacheManagerClass = null;
            String cacheManagerClassStr = config.getInitParameter("cacheManager");
            if (StringUtils.isNotBlank(cacheManagerClassStr)) {
                try {
                    cacheManagerClass = CompressionServlet.class.getClassLoader()
                            .loadClass(cacheManagerClassStr);
                } catch (ClassNotFoundException e) {
                    logger.error("??!", e);
                }
            } else {
                cacheManagerClass = SimpleCacheManager.class;
            }

            if (autoClean) {
                String cleanIntervalStr = config.getInitParameter("cleanInterval");
                long cleanInterval = 1000 * 60 * 60 * 5L;
                if (StringUtils.isNotBlank(cleanIntervalStr)) {
                    try {
                        cleanInterval = Long.parseLong(cleanIntervalStr);
                    } catch (Exception e) {
                    }
                }
                String lowHitStr = config.getInitParameter("cleanLowHit");

                if (StringUtils.isNotBlank(lowHitStr)) {
                    try {
                        lowHit = Integer.parseInt(autoCleanStr);
                    } catch (Exception e) {
                    }
                }
                String cleanHourAgoStr = config.getInitParameter("cleanHourAgo");

                if (StringUtils.isNotBlank(cleanHourAgoStr)) {
                    try {
                        cleanHourAgo = Integer.parseInt(cleanHourAgoStr);
                    } catch (Exception e) {
                    }
                }
                if (cacheType != null) {
                    try {
                        Constructor constructor = cacheManagerClass.getConstructor(CacheType.class, int.class,
                                int.class, int.class, long.class, String.class);
                        cacheManager = (CacheManager) constructor.newInstance(cacheType, cacheCount, lowHit,
                                cleanHourAgo, cleanInterval, cacheDir);
                    } catch (NoSuchMethodException e) {
                        logger.error("??", e);
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (InstantiationException e) {
                        logger.error("??", e);
                    } catch (IllegalAccessException e) {
                        logger.error("??", e);
                    } catch (Exception e) {
                        logger.error("??", e);
                    }
                }
            } else {
                if (cacheType != null) {
                    try {
                        Constructor constructor = cacheManagerClass.getConstructor(CacheType.class, int.class,
                                String.class);
                        cacheManager = (CacheManager) constructor.newInstance(cacheType, cacheCount, cacheDir);
                    } catch (NoSuchMethodException e) {
                        logger.error("??", e);
                    } catch (InvocationTargetException e) {
                        logger.error("??", e);
                    } catch (InstantiationException e) {
                        logger.error("??", e);
                    } catch (IllegalAccessException e) {
                        logger.error("??", e);
                    } catch (Exception e) {
                        logger.error("??", e);
                    }
                }
            }
        }
        initialized = true;
    }
}

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

@Override
protected void onDestroy() {
    super.onDestroy();

    // attempt to unregister, however we can safely ignore the
    // "IllegalArgumentException: Receiver not registered" called when
    // some hardware experiences a race condition here.
    try {//from www . ja v a 2  s. co m
        unregisterReceiver(mPushRegReceiver);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
    try {
        unregisterReceiver(mMsgIncomingReceiver);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
    try {
        unregisterReceiver(mMsgOutgoingReceiver);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }

    // make sure we are cleared out...
    if (this.isFinishing())
        reInitForExit();
}

From source file:com.pianobakery.complsa.MainGui.java

public void matchTerm() {

    if (!StringUtils.isNumeric(noOfSearchResultsText.getText())) {

        JOptionPane.showMessageDialog(null, "Enter Number of Search Results");
        return;/*from w ww.ja v a2 s.  c  o  m*/

    }

    //bar.setProgressBarIndeterminate(true);

    if (termSearchResModel.getRowCount() != 0) {
        termSearchResModel.setRowCount(0);
    }

    File termvectorfile = getSelectedSearchModelFiles()[0];
    File docvectorfile = getSelectedSearchModelFiles()[1];
    logger.debug("termfile: " + termvectorfile);
    logger.debug("docfile: " + docvectorfile);

    /*String theContents = null;
            
    if (selDocRadioButton.isSelected() && !searchFileString.isEmpty()) {
        theContents = searchFileString;
            
    } else if (selTextRadioButton.isSelected()) {
        theContents = searchTextArea.getText();
            
            
    }
    */
    File theIndexFileFolder = new File(wDir + File.separator + SemanticParser.getLucIndexParentDirName()
            + File.separator + trainCorp.get(selectTrainCorp.getSelectedItem()).getName().toString());
    //List<String> theWords = Utilities.getWords(theContents);

    //logger.debug("Numeric?: " + StringUtils.isNumeric(noOfSearchResultsText.getText()));

    int row = docSearchResTable.convertRowIndexToModel(docSearchResTable.getSelectedRow());
    logger.debug("The Matchterm row: " + row);
    DocSearchModel theModel = (DocSearchModel) docSearchResTable.getModel();
    File theFile = theModel.getDocFile(row).getFile();
    logger.debug("The Matchterm File: " + theFile.toString());

    ArrayList<String> arguments = new ArrayList<String>();
    arguments.add("-luceneindexpath");
    arguments.add(theIndexFileFolder.toString());
    arguments.add("-numsearchresults");
    arguments.add(noOfSearchResultsText.getText());
    arguments.add("-queryvectorfile");
    arguments.add(docvectorfile.toString());
    arguments.add("-searchvectorfile");
    arguments.add(termvectorfile.toString());
    arguments.add("-matchcase");
    arguments.add(theFile.toString());

    //arguments.add("-vectortype");
    //arguments.add("-dimension");
    //arguments.add("-seedlength");
    //arguments.add("-minfrequency");
    //arguments.add("-maxnonalphabetchars");
    //arguments.add("-termweight");
    //arguments.add(termweight);
    //arguments.add("-docindexing");
    //arguments.add("incremental");
    //arguments.add("-trainingcycles");
    //arguments.add(Integer.toString(amTraining));
    //arguments.add("-termtermvectorsfile");
    //arguments.add(termtermvectorfile.toString());

    //arguments.add(searchTextArea.getText().toString());

    /*for (String aWord : theWords) {
        arguments.add(aWord);
    }*/

    String[] args = new String[arguments.size()];
    args = arguments.toArray(args);

    for (String aarg : args) {
        logger.debug("The Args: " + aarg);
    }

    List<SearchResult> theResult;
    FlagConfig flagConfig;
    try {
        flagConfig = FlagConfig.getFlagConfig(args);
        theResult = Search.runSearch(flagConfig);
    } catch (IllegalArgumentException e) {
        //System.err.println(usageMessage);
        throw e;
    }

    try {
        Search.main(args);
    } catch (IOException e) {
        e.printStackTrace();
    }

    theResult = Search.runSearch(flagConfig);
    logger.debug("The Match Result: " + theResult.size());

    if (theResult.size() > 0) {
        logger.info("Search output follows ...\n");
        for (SearchResult result : theResult) {

            System.out.println(result.toSimpleString());
            logger.debug("ObjectVector: " + result.getObjectVector().getObject().toString());
            logger.debug("Score: " + result.getScore());
            logger.debug("toString: " + result.toString());
            double percent = result.getScore() * 100;
            String theScore = new DecimalFormat("#.###").format(percent);

            termSearchResModel
                    .addRow(new Object[] { theScore, result.getObjectVector().getObject().toString() });
        }

    } else {
        termSearchResModel.addRow(new Object[] { null, "No Search Results..." });
    }

}