Example usage for java.lang NullPointerException toString

List of usage examples for java.lang NullPointerException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.hyperic.hq.ui.taglib.display.ImageButtonDecorator.java

public String decorate(Object obj) {
    try {/* w  w w.j a va 2s .co  m*/
        HttpServletRequest req = (HttpServletRequest) context.getRequest();
        String src = req.getContextPath() + page;
        String formName = getForm();
        StringBuffer buf = new StringBuffer();

        buf.append("<input type=\"image\" ");
        buf.append("src=\"");
        buf.append(src);
        buf.append("\" ");
        buf.append("border=\"0\" onClick=\"clickSelect('");
        buf.append(formName);
        buf.append("', '");
        buf.append(getInput());
        buf.append("', '");
        buf.append(obj.toString());
        buf.append("');\">");

        return buf.toString();
    } catch (NullPointerException npe) {
        log.debug(npe.toString());
    }

    return "";
}

From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.SpringApiClientImplTest.java

/**
 * Tests constructor {@link SpringApiClientImpl#SpringApiClientImpl(String, RestTemplate)} in the case where the
 * supplied host name is invalid, because it contains an unsupported character e.g a space.
 *///from   w  w w  .j  av  a 2 s  .  c o  m
@Test
public final void testConstructInvalidHostNameNull() {
    try {
        new SpringApiClientImpl(null, new RestTemplate());
        fail("Expected an exception to be thrown.");
    } catch (NullPointerException e) {
        assertTrue("Unexepected exception message [" + e.toString() + "].",
                e.getMessage().matches(".*host name.*null.*"));
    }
}

From source file:org.hyperic.hq.ui.taglib.display.LabelDecorator.java

public String decorate(Object obj) {
    try {/*ww w . j a v a  2 s  . com*/
        String forElement = getForElement();
        String style = getStyleClass();
        String value = getValue();
        String click = getOnclick();

        if (value == null) {
            value = obj.toString();
        }

        StringBuffer buf = new StringBuffer();

        buf.append("<label for=\"");
        buf.append(forElement);
        buf.append("\" onclick=\"");
        buf.append(click);
        buf.append("\" class=\"");
        buf.append(style);
        buf.append("\">");
        buf.append(value);
        buf.append("</label>");

        return buf.toString();
    } catch (NullPointerException npe) {
        log.debug(npe.toString());
    }

    return "";
}

From source file:edu.tcu.gaduo.ihe.iti.ct_transaction.service.NTPClient.java

public Date processResponse(String host) {

    TimeInfo info = null;//from  ww  w.  jav a2  s  .c om
    try {
        NTPUDPClient client = new NTPUDPClient();
        client.setDefaultTimeout(10000);
        client.open();
        InetAddress hostAddr = InetAddress.getByName(host);
        info = client.getTime(hostAddr);
        client.close();
    } catch (NullPointerException e) {
        logger.info(e.toString());
        return null;
    } catch (IOException e) {
        logger.info(e.toString());
        e.printStackTrace();
        return null;
    }

    message = info.getMessage();
    stratum = message.getStratum(); // 
    if (stratum <= 0)
        refType = "(??)";
    else if (stratum == 1)
        refType = "(??; e.g., GPS)"; // GPS, radio clock,
    else
        refType = "(??; e.g. via NTP or SNTP)";
    // stratum should be 0..15...
    logger.info(" Stratum: " + stratum + " " + refType);

    this.setRefNtpTime(message.getReferenceTimeStamp());

    // Originate Time is time request sent by client (t1)
    this.setOrigNtpTime(message.getOriginateTimeStamp());
    // Receive Time is time request received by server (t2)
    this.setRcvNtpTime(message.getReceiveTimeStamp());
    // Transmit time is time reply sent by server (t3)
    this.setXmitNtpTime(message.getTransmitTimeStamp());
    // Destination time is time reply received by client (t4)
    long destTime = info.getReturnTime();
    this.setDestNtpTime(TimeStamp.getNtpTime(destTime));

    info.computeDetails(); // compute offset/delay if not already done
    Long offsetValue = info.getOffset();
    Long delayValue = info.getDelay();
    this.setDelay(delay = (delayValue == null) ? "N/A" : delayValue.toString());
    this.setOffset((offsetValue == null) ? "N/A" : offsetValue.toString());

    Date Date = message.getReferenceTimeStamp().getDate();
    return Date;
}

From source file:org.hyperic.hq.ui.taglib.display.CheckBoxDecorator.java

public String decorate(Object obj) {
    try {/*from   ww w .j a v a 2 s  .co  m*/
        String name = getName();
        String elementId = getElementId();
        String value = getValue();
        String label = getLabel();
        String suppress = getSuppress();
        String click = getOnclick();
        String style = getStyleClass();

        if (elementId == null) {
            elementId = "";
        }

        if (value == null) {
            value = obj.toString();
        }

        if (value.equals(suppress)) {
            return "";
        }

        StringBuffer buf = new StringBuffer();

        if (label != null) {
            buf.append("<label>");
        }

        buf.append("<input type=\"checkbox\" onclick=\"");
        buf.append(click);
        buf.append("\" class=\"");
        buf.append(style);
        buf.append("\" id=\"");
        buf.append(elementId);
        buf.append("\" name=\"");
        buf.append(name);
        buf.append("\" value=\"");
        buf.append(value);
        buf.append("\"");
        buf.append(">");

        if (label != null) {
            buf.append(label).append("</label>");
        }

        return buf.toString();
    } catch (NullPointerException npe) {
        log.debug(npe.toString());
    }

    return "";
}

From source file:org.red5.webapps.admin.Application.java

/**
 * Get all the scopes//  ww w  .  j a  va2 s .co m
 * 
 * @param scopeName
 * @return HashMap containing all the scopes
 */
public HashMap<Integer, String> getScopes(String scopeName) {
    IScope root = ScopeUtils.findRoot(scope);
    IScope scopeObj = root.getScope(scopeName);
    scopes = new HashMap<Integer, String>();
    try {
        getRooms(scopeObj, 0);
    } catch (NullPointerException npe) {
        log.debug(npe.toString());
    }
    log.debug("Scopes: {}", scopes);
    return scopes;
}

From source file:sos.net.SOSFTPS.java

public void connect(String ftpHost, int ftpPort1) throws SocketException, IOException {
    initProxy();//  w  ww.ja v a 2s  .c  om
    if (isConnected() == false) {
        this.setSocketFactory(new SOSSSLSocketFactory(getProxyHost(), getProxyPort(), getSecurityProtocol()));
        //         this.setSocketFactory(new SOSSSLSocketFactory());
        try {
            super.connect(ftpHost, ftpPort1);
        } catch (NullPointerException e) {
            throw new SocketException(
                    "Connect failed! Probably HTTP proxy in use or the entered ftps port is invalid: "
                            + e.toString());
        } catch (Exception e) {
            e.printStackTrace();
            throw new SocketException("Connect failed, reason: " + e.toString());
        }
        this.sendCommand("PBSZ 0");
        this.sendCommand("PROT P");
        this.enterLocalPassiveMode();
    }
}

From source file:org.red5.webapps.admin.Application.java

/**
 * Get all the scopes/*  w ww . j  a  va  2 s  .co  m*/
 * 
 * @param root
 *            the scope to from
 * @param depth
 *            scope depth
 */
public void getRooms(IScope root, int depth) {
    Set<String> names = root.getScopeNames();
    String indent = "";
    for (int i = 0; i < depth; i++) {
        indent += " ";
    }
    for (String name : names) {
        try {
            IScope parent = root.getScope(name);
            // parent
            getRooms(parent, depth + 1);
            scopes.put(scope_id, indent + name);
            scope_id++;
            log.debug("Found scope: {}", name);
        } catch (NullPointerException npe) {
            log.debug(npe.toString());
        }
    }
}

From source file:se.lu.nateko.edca.svc.GetMap.java

/**
 * Method that calls a geospatial server using a GetMap request and,
 * if successful, stores the resulting InputStream in a reusable version.
 * @return   Returns true if successful, otherwise false.
 *//*from w  ww . jav  a 2  s. c om*/
protected int getMapRequest() {
    //      Log.d(TAG, "getMapRequest() called");

    /* Check if any layers should be requested. If not, cancel the GetMap request. */
    String layers = fetchLayerNames();
    if (layers.contentEquals(""))
        return RESULT_NOLAYERS;

    /* Try to form an URI from the supplied ServerConnection info and the list of
     * layers set to display in the local SQLite database. */
    String uriString = "";
    try {
        uriString = mServerConnection.getAddress() + "/wms?service=wms&version=1.1.0&request=GetMap&layers="
                + layers + "&bbox=" + Utilities.latLngBoundsToString(mBounds) + "&styles=" + "&transparent=true"
                + "&srs=epsg:3857" + "&format=image/png" + "&width=" + String.valueOf(mWidth) + "&height="
                + String.valueOf(mHeight);
        mServerURI = new URI(uriString);
    } catch (NullPointerException e) {
        Log.e(TAG, e.toString());
        return RESULT_FAILURE;
    } catch (URISyntaxException e) {
        Log.e(TAG, e.toString() + ": " + uriString);
        return RESULT_FAILURE;
    }

    /* Execute the HTTP request. */
    HttpGet httpGetMethod = new HttpGet(mServerURI);
    HttpResponse response;
    try {
        final HttpParams httpParameters = mHttpClient.getParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, TIME_OUT * 1000);
        HttpConnectionParams.setSoTimeout(httpParameters, TIME_OUT * 1000);

        response = mHttpClient.execute(httpGetMethod);
        Log.i(TAG, "getMap request made to database: " + httpGetMethod.getURI().toString());

        InputStream imageStream = response.getEntity().getContent();
        try {
            //             Log.v(TAG, "Saving response as a Bitmap.");
            setImage(BitmapFactory.decodeStream(imageStream)); // Save the HttpResponse as a Bitmap image to be displayed.            
        } finally {
            imageStream.close();
        }

        return RESULT_SUCCESS;

    } catch (MalformedURLException e) {
        Log.e(TAG, e.toString());
        return RESULT_FAILURE;
    } catch (IOException e) {
        Log.e(TAG, e.toString());
        return RESULT_FAILURE;
    }
}

From source file:WriteDoubleUsingSockets.java

public void init() {
    Date d = new Date();
    // Get the portnumber and servername and allow to be called from a
    // java main program also
    try {/*from   www .jav a  2s .  c  om*/
        String param;
        param = getParameter("PortNumber");
        if (param != null)
            PortNumber = Integer.parseInt(param);
        param = getParameter("ServerName");
        if (param != null)
            ServerName = param;
    } catch (NullPointerException e) { // Must be called from a main ignore
    }
    try {
        Socket skt = new Socket(ServerName, PortNumber);
        os = new DataOutputStream(skt.getOutputStream());
    } catch (Exception e) {
        Label l = new Label(e.toString());
        add(l);
        System.out.println(e);
        return;
    }
    try {
        s = new ObjectOutputStream(os);
    } catch (Exception e) {
        System.out.println(e);
        System.out.println("Unable to open stream as an object stream");
    }
    try {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 25; i++) {
            s.writeObject(new Double(i));
        }
        os.close();
        long endTime = System.currentTimeMillis() - startTime;
        Label l = new Label(
                "Writing 25 doubles server took: " + new Long(endTime).toString() + " milliseconds.");
        add(l);
        System.out.println("Object written");
    } catch (Exception e) {
        System.out.println(e);
        System.out.println("Unable to write Objects");
    }
}