Example usage for java.lang NullPointerException getMessage

List of usage examples for java.lang NullPointerException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:ImageTest.java

public static void main(String args[]) {
    args = new String[] { "image.json" };
    for (int a = 0; a < args.length; a++) {
        String version = "Unknown";
        try {/*from  w  ww.  j  a v  a  2 s . c  o m*/
            JSONTokener tokener = new JSONTokener(new FileInputStream(args[a]));
            JSONObject jsonSubject = new JSONObject(tokener);
            JSONObject jsonSchema = new JSONObject(
                    new JSONTokener(ImageTest.class.getResourceAsStream("schema.json")));

            Schema schema = SchemaLoader.load(jsonSchema);
            schema.validate(jsonSubject);

            System.out.println("json-schema Valid " + args[a]);
        } catch (NullPointerException e) {
            System.out.println("json-config null point error " + args[a]);
        } catch (FileNotFoundException e) {
            System.out.println("json-file file missing " + e.getMessage() + " " + args[a]);
        } catch (JSONException je) {
            System.out.println("json-parse json " + je.getMessage() + " " + args[a]);
        } catch (ValidationException ve) {
            Iterator<ValidationException> i = ve.getCausingExceptions().iterator();
            while (i.hasNext()) {
                ValidationException veel = i.next();
                System.out.println("json-schema Validation error " + veel + " " + args[a]);
            }
        }
    }
}

From source file:NumberTest.java

public static void main(String args[]) {
    args = new String[] { "number.json" };
    for (int a = 0; a < args.length; a++) {
        System.out.println(args[a]);
        String version = "Unknown";
        try {/*from  www. j a v a 2s. co m*/
            System.out.println("Starting");
            JSONTokener tokener = new JSONTokener(new FileInputStream(args[a]));
            JSONObject jsonSubject = new JSONObject(tokener);
            System.out.println(
                    jsonSubject.getJSONObject("MovieTexture").get("@startTime").getClass().getSimpleName());
            JSONObject jsonSchema = new JSONObject(
                    new JSONTokener(NumberTest.class.getResourceAsStream("numberschema.json")));

            Schema schema = SchemaLoader.load(jsonSchema);
            schema.validate(jsonSubject);
            System.out.println("Finishing");

            System.out.println("json-schema Valid " + args[a]);
        } catch (NullPointerException e) {
            System.out.println("json-config null point error " + args[a]);
        } catch (FileNotFoundException e) {
            System.out.println("json-file file missing " + e.getMessage() + " " + args[a]);
        } catch (JSONException je) {
            System.out.println("json-parse json " + je.getMessage() + " " + args[a]);
        } catch (ValidationException ve) {
            ve.printStackTrace();
            System.out.println("json-schema Validation error " + ve + " " + args[a]);
            Iterator<ValidationException> i = ve.getCausingExceptions().iterator();
            while (i.hasNext()) {
                ValidationException veel = i.next();
                System.out.println("json-schema Validation error " + veel + " " + args[a]);
            }
        }
    }
}

From source file:org.filteredpush.qc.date.DateUtils.java

/**
 * Run from the command line, arguments -f to specify a file, -m to show matches. 
 * Converts dates in a specified input file from verbatim form to format expected by dwc:eventDate.
 * /*from ww  w  . ja  v a2 s  .  c  o  m*/
 * @param args -f filename to check a file containing a list of dates, one per line, 
 *        e.g. -f src/test/resources/example_dates.csv
 *    -m to show matched dates and their interpretations otherwise lists non-matched lines.  
 *    -a to show all lines, matched or not with their interpretations.
 */
public static void main(String[] args) {
    try {
        File datesFile = null;
        try {
            URL datesURI = DateUtils.class.getResource("/example_dates.csv");
            datesFile = new File(datesURI.toURI());
        } catch (NullPointerException e) {
            logger.debug(e.getMessage());
        } catch (URISyntaxException e) {
            logger.error(e.getMessage());
        }
        if (args != null && args.length > 0 && args[0] != null && args[0].toLowerCase().equals("-f")) {
            if (args[1] != null) {
                datesFile = new File(args[1]);
            }
        }
        boolean standardIn = false;
        if (datesFile == null) {
            if (args != null && args.length > 0 && args[0] != null && args[0].toLowerCase().equals("-i")) {
                standardIn = true;
            } else if (args != null && args.length > 1 && args[0] != null
                    && args[0].toLowerCase().equals("-v")) {
                StringBuffer verbatim = new StringBuffer(); // support presence of absence of quotes
                for (int i = 1; i < args.length; i++) {
                    verbatim.append(args[i]).append(" ");
                }
                EventResult result = DateUtils.extractDateFromVerbatimER(verbatim.toString().trim());
                String retval = result.getResult();
                if (retval == null) {
                    retval = "";
                }
                System.out.println(retval);
                System.exit(0);
                ;
            } else {
                System.out.println("Check a file consisting of verbatim dates, one date per line.");
                System.out.println("Specify a file to check with: -f filename");
                System.out.println("Add no additional options to see only non-matched lines.");
                System.out.println("Show only matching lines with -m");
                System.out.println("Show both matching and non-matching lines with -a");
                System.out.println("Read one line from standard input with: -i");
                System.out.println(
                        "Interpret one date with: -v \"{date}\", e.g. -v \"Feb, 2012\", no other parameters. ");
                System.exit(1);
            }
        }
        boolean showMatches = false;
        boolean showAll = false;
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-m")) {
                showMatches = true;
            }
            if (args[i].equals("-a")) {
                showAll = true;
            }
        }
        BufferedReader reader = null;
        if (standardIn) {
            reader = new BufferedReader(new InputStreamReader(System.in));
        } else {
            reader = new BufferedReader(new FileReader(datesFile));
        }
        String line = null;
        int unmatched = 0;
        int matched = 0;
        boolean done = false;
        while (!done && (line = reader.readLine()) != null) {
            EventResult result = DateUtils.extractDateFromVerbatimER(line.trim());
            if (result == null || result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
                if (!showMatches && !showAll) {
                    System.out.println(line);
                }
                if (showAll) {
                    System.out.println(line + "\t" + result.getResultState());
                }
                unmatched++;
            } else {
                matched++;
                if (standardIn) {
                    System.out.println(result.getResult());
                } else {
                    if (showMatches || showAll) {
                        System.out.println(line + "\t" + result.getResultState() + "\t" + result.getResult());
                    }
                }
            }
            if (standardIn) {
                done = true; // only read one line of text in this mode.
            }
        }
        reader.close();
        if (!standardIn) {
            System.out.println("Unmatched lines: " + unmatched);
            System.out.println("Matched lines: " + matched);
        }
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage());
        System.out.println(e.getMessage());
    } catch (IOException e) {
        logger.error(e.getMessage());
        ;
        System.out.println(e.getMessage());

    }

}

From source file:Main.java

/**
 * This method returns the owner document of a particular node.
 * This method is necessary because it <I>always</I> returns a
 * {@link Document}. {@link Node#getOwnerDocument} returns <CODE>null</CODE>
 * if the {@link Node} is a {@link Document}.
 *
 * @param node// w ww. j a  v a  2 s  .c  o m
 * @return the owner document of the node
 */
public static Document getOwnerDocument(Node node) {
    if (node.getNodeType() == Node.DOCUMENT_NODE) {
        return (Document) node;
    }
    try {
        return node.getOwnerDocument();
    } catch (NullPointerException npe) {
        throw new NullPointerException(npe.getMessage());
    }
}

From source file:org.owasp.goatdroid.gui.emulator.Emulator.java

static public String getAppPath(JTree jTree, boolean useViewResource, String appName, String typeDirectory) {

    String directoryPath;// w  w w.  ja  v a2s . c  om
    if (useViewResource)
        directoryPath = ResourceTreeBuilder.getCurrentNodeParent(jTree) + getSlash() + "android_app";
    else
        directoryPath = ResourceTreeBuilder.buildAPKPath(appName);
    File directory = new File(directoryPath);

    try {
        File[] entries = directory.listFiles();
        // Go over entries
        for (File entry : entries) {
            if (entry.isFile() && entry.toString().endsWith(".apk")) {
                return entry.toString();
            }
        }
    } catch (NullPointerException e) {
        e.getMessage();
    }
    // If we get here, we lost
    return "";
}

From source file:com.github.markusbernhardt.nexus.plugins.jqassistant.backend.scanner.Util.java

public static Gav toGav(Coordinates coordinates) {
    try {/*ww  w  .ja  v a  2 s . c  o  m*/
        return new Gav(coordinates.getGroup(), coordinates.getName(), coordinates.getVersion(),
                coordinates.getClassifier(), coordinates.getType(), null, null, null, false, null, false, null);
    } catch (NullPointerException e) {
        System.out.println(e.getMessage());
        throw e;
    }
}

From source file:fr.paris.lutece.plugins.rss.service.RssGeneratorService.java

/**
 * Deletes the pushrss file in the directory
 *
 * @param strRssFileName The name of the RSS file
 * @param strPluginName The plugin's name
 *///  w  w  w  .  ja  va2 s  .  c om
public static void deleteFileRss(String strRssFileName, String strPluginName) {
    try {
        // Define pushRss directory
        String strFileRss = AppPathService.getPath(RssGeneratorService.PROPERTY_RSS_STORAGE_FOLDER_PATH, "")
                + strRssFileName;

        // Delete the file if file exists
        if (new File(strFileRss).exists()) {
            File file = new File(strFileRss);
            file.delete();
        }
    } catch (NullPointerException e) {
        AppLogService.error(e.getMessage(), e);
    }
}

From source file:org.apache.xml.security.algorithms.SignatureAlgorithm.java

/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of 
 * {@link SignatureAlgorithmSpi}/*from   ww  w  .j  a  v a2 s  .  c  o  m*/
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException 
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
        throws AlgorithmAlreadyRegisteredException, ClassNotFoundException, XMLSignatureException {
    if (log.isDebugEnabled()) {
        log.debug("Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    try {
        Class<? extends SignatureAlgorithmSpi> clazz = (Class<? extends SignatureAlgorithmSpi>) ClassLoaderUtils
                .loadClass(implementingClass, SignatureAlgorithm.class);
        algorithmHash.put(algorithmURI, clazz);
    } catch (NullPointerException ex) {
        Object exArgs[] = { algorithmURI, ex.getMessage() };
        throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs, ex);
    }
}

From source file:finale.year.stage.main.Inscription.java

public static void updateStatus(final String message) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override//from  www .  j a  v  a 2 s. co  m
        public void run() {

            try {
                errorStatusBar.setText("");
                errorStatusBar.setForeground(Color.red);
                errorStatusBar.setText(message);

            } catch (NullPointerException e) {
                System.out.println(e.getMessage());
                return;
            }
        }

    });

}

From source file:com.celamanzi.liferay.portlets.rails286.Rails286PortletFunctions.java

/** Processes the request path.
 * Replaces variables with runtime user/portlet values.
 *
 * DEPRECATED since version 0.12.//from   w  ww. j av  a 2  s.c om
 * The correct way to pass this information is via cookie.
 */
protected static String decipherPath(String path, PortletRequest request) {
    String deprecationMsg = "DEPRECATION WARNING: You are using a deprecated method for passing Liferay UID/GID values to Rails in URL. This data is now passed in a session cookie. Please do not use :uid or :gid in your routes.";

    if (path == null) {
        log.debug("Path is null, cannot extract variables");
        return path;
    }

    //ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);

    log.debug("Deciphering portlet directive variables from path: " + path);
    String[] pathParameters = { "%UID%", "%GID%" };
    Pattern pattern = null;
    Matcher matcher = null;

    //   log.debug("Compiled for Liferay version "+LIFERAY_VERSION[0]);

    for (int i = 0; i < pathParameters.length; i++) {
        String var = pathParameters[i];
        pattern = Pattern.compile(var);
        matcher = pattern.matcher(path);

        try {
            if (matcher.find()) {

                /*
                 * UID - User ID
                 */
                if (var.equals("%UID%")) {
                    log.warn(deprecationMsg);
                    log.debug("Matched variable: " + var);
                    String uid = null;

                    try {
                        //Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);

                        // Liferay 5.2 +
                        /* comment out version checking, since conditional compiling may not be nice. */
                        /*if (isMinimumLiferayVersionMet(new int[] {5,2})) { */
                        uid = new Long(com.liferay.portal.util.PortalUtil.getUserId(request)).toString();
                    } catch (NullPointerException e) {
                        log.error(e.getMessage());
                        uid = "0";
                    }
                    log.debug("Liferay UID: " + uid);
                    path = path.replaceAll(var, uid);
                }

                /*
                 * GID - Group ID
                 */
                if (var.equals("%GID%")) {
                    log.warn(deprecationMsg);
                    log.debug("Matched variable: " + var);
                    String gid = null;

                    try {

                        long scopeGroupId = 0;
                        try {
                            scopeGroupId = com.liferay.portal.util.PortalUtil.getScopeGroupId(request);
                            /*
                             exception com.liferay.portal.kernel.exception.PortalException is never thrown in body of corresponding try statement
                             exception com.liferay.portal.kernel.exception.SystemException is never thrown in body of corresponding try statement
                            } catch (PortalException e) {
                               log.error("decipherPath: " + e.getMessage());
                            } catch (SystemException e) {
                               log.error("decipherPath: " + e.getMessage());
                            }
                            */
                        } catch (Exception e) {
                            log.error("decipherPath: " + e.getMessage());
                        }

                        // Liferay 5 +
                        /*if (isMinimumLiferayVersionMet(new int[] {5})) { */
                        gid = new Long(scopeGroupId).toString();
                    } catch (NullPointerException e) {
                        log.error(e.getMessage());
                        gid = "0";
                    }
                    log.debug("Liferay portlet GID: " + gid);
                    path = path.replaceAll(var, gid);
                }
            }

        } catch (NullPointerException e) {
            log.error(e.getMessage());
        }
    } // end iterate

    //After replaced the runtime variables we need to clear the unused Rails wildcards
    path = clearRailsWildcards(path);

    log.debug("New path: " + path);
    return path;
}