Example usage for java.lang String concat

List of usage examples for java.lang String concat

Introduction

In this page you can find the example usage for java.lang String concat.

Prototype

public String concat(String str) 

Source Link

Document

Concatenates the specified string to the end of this string.

Usage

From source file:fr.natoine.model_annotation.AnnotationStatus.java

private String createCheckboxes(String _html, String _className, String _status, String _unique_id, int _cpt,
        JSONArray _choices, int _choices_length) throws JSONException {
    _html = _html.concat("<input type=hidden name=\"checkboxes_annotation_added_" + _className.toLowerCase()
            + "_" + _status + "_" + _cpt + "_" + _unique_id + "\" id=\"checkboxes_annotation_added_"
            + _className.toLowerCase() + "_" + _status + "_" + _cpt + "_" + _unique_id + "\" value=\"\" />");
    for (int j = 0; j < _choices_length; j++) {
        String _value = _choices.getString(j);
        _html = createCheckbox(_html, _className, _status, _unique_id, _value, _cpt);
    }/* ww w.ja va 2  s  . c om*/
    return _html;
}

From source file:it.geosolutions.operations.FileBrowserOperationController.java

/**
 * @param defaultBaseDir the defaultBaseDir to set
 *//*from w  w  w  .j  a va  2  s  .c  om*/
public void setDefaultBaseDir(String defaultBaseDir) {
    if (!defaultBaseDir.endsWith("/")) {
        System.out.println("[WARN] defaultBaseDir not ending with slash \"\\\", appending one");
        defaultBaseDir = defaultBaseDir.concat("/");
    }
    this.defaultBaseDir = defaultBaseDir;
}

From source file:com.pandoroid.pandora.RPC.java

/**
 * Description: This function contacts the remote server with a string
 *    type data package (could be JSON), and returns the remote server's 
 *    response in a string./*  w  w  w. j av  a  2s  .  c  o m*/
 * @throws Exception if url_params or entity_data is empty/null.
 * @throws HttpResponseException if response is not equal HttpStatus.SC_OK
 * @throws IOException if a connection to the remote server can't be made.
 */
public String call(Map<String, String> url_params, String entity_data, boolean require_secure)
        throws Exception, HttpResponseException, IOException {

    if (url_params == null || url_params.size() == 0) {
        throw new Exception("Missing URL paramaters");
    }
    if (entity_data == null) {
        throw new Exception("Missing data for HTTP entity.");
    }

    String full_url;

    if (require_secure) {
        full_url = "https://" + request_url;
    } else {
        full_url = "http://" + request_url;
    }

    HttpPost request = new HttpPost();
    if (user_agent != null) {
        request.addHeader("User-Agent", user_agent);
    }

    URI uri = new URI(full_url.concat(makeUrlParamString(url_params)));
    request.setURI(uri);
    StringEntity entity = null;

    try {
        entity = new StringEntity(entity_data);
        if (entity_type != null) {
            entity.setContentType(entity_type);
        }
    } catch (Exception e) {
        throw new Exception("Pandora RPC Http entity creation error");
    }

    request.setEntity(entity);

    //Send to the server and get our response 
    HttpResponse response = client.execute(request);
    int status_code = response.getStatusLine().getStatusCode();
    if (status_code != HttpStatus.SC_OK) {
        throw new HttpResponseException(status_code,
                "HTTP status code: " + status_code + " != " + HttpStatus.SC_OK);
    }

    //Read the response returned and turn it from a byte stream to a string.
    HttpEntity response_entity = response.getEntity();
    int BUFFER_BYTE_SIZE = 512;
    String ret_data = new String();
    byte[] bytes = new byte[BUFFER_BYTE_SIZE];

    //Check the entity type (usually 'text/plain'). Probably doesn't need
    //to be checked.
    if (response_entity.getContentType().getValue().equals(entity_type)) {
        InputStream content = response_entity.getContent();
        int bytes_read = BUFFER_BYTE_SIZE;

        //Rather than read an arbitrary amount of bytes, lets be sure to get
        //it all.
        while ((bytes_read = content.read(bytes, 0, BUFFER_BYTE_SIZE)) != -1) {
            ret_data += new String(bytes, 0, bytes_read);
        }
    } else {
        throw new Exception(
                "Improper server response entity type: " + response_entity.getContentType().getValue());
    }

    return ret_data;
}

From source file:com.adobe.acs.commons.util.InfoWriterTest.java

@Test
public void testPrint_ComplexVars() throws Exception {
    final Calendar cal = Calendar.getInstance();
    cal.set(2015, Calendar.JANUARY, 1, 0, 0, 0);

    String expected = "String: hello " + "Integer: 10 " + "Long: 20 " + "Double: 30.1 " + "Boolean: true "
            + "Calendar: " + cal.getTime().toString() + " " + "Date: " + cal.getTime().toString();

    iw.message("String: {} " + "Integer: {} " + "Long: {} " + "Double: {} " + "Boolean: {} " + "Calendar: {} "
            + "Date: {}", "hello", 10, 20L, 30.1D, true, cal, cal.getTime());

    assertEquals(expected.concat(LS), iw.toString());
}

From source file:emlab.trend.HourlyCSVTimeSeries.java

@Transactional
private void readData() {

    this.persist();
    logger.warn("Trying to read CSV file: " + filename);

    String data = new String();

    // Save the data in a long String
    try {//from ww  w.jav  a  2s  . c  o m

        InputStreamReader inputStreamReader = new InputStreamReader(
                this.getClass().getResourceAsStream(filename));
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

        String line;

        while ((line = bufferedReader.readLine()) != null) {
            data = data.concat(line + ",");
        }
        bufferedReader.close();

        String[] vals = data.split(",");
        setHourlyArray(parseString(vals), 0);

    } catch (Exception e) {
        logger.error("Couldn't read CSV file: " + filename);
        e.printStackTrace();
    }

}

From source file:org.jasig.portlet.newsreader.dao.HibernateNewsStore.java

public List<PredefinedNewsConfiguration> getPredefinedNewsConfigurations(Long setId, boolean visibleOnly) {
    try {//  ww w  .j a  va  2  s . c  o m
        String query = "from NewsConfiguration config " + "where config.newsSet.id = ? and "
                + "config.class = PredefinedNewsConfiguration " + "order by newsDefinition.name";
        if (visibleOnly)
            query = query.concat(" and visibleOnly = true");

        return (List<PredefinedNewsConfiguration>) getHibernateTemplate().find(query, setId);

    } catch (HibernateException ex) {
        throw convertHibernateAccessException(ex);
    }
}

From source file:com.remdo.app.WebViewActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_web_view);

    // Get the uri from the intent
    Intent intent = getIntent();/*  www . j a  va 2  s .co  m*/
    String uriToDisplay = intent.getStringExtra("DEVICE_URL");
    String usr = intent.getStringExtra("DEVICE_USER");
    String pwd = intent.getStringExtra("DEVICE_PASSWORD");
    Integer odTypeId = intent.getIntExtra("DEVICE_ODTYPEID", -1);

    if (odTypeId == 1)//ODNetWork    
    {
        if (!uriToDisplay.contains("cgi-bin/od.cgi")) {
            uriToDisplay = uriToDisplay.concat("/cgi-bin/od.cgi");
        }

        //initialize WebView
        webView = (WebView) findViewById(R.id.webView1);
        //we should define a webview client to get user navigation inside our webview otherwise 
        //defaul behaviour will open a webbrowser on first click
        webView.setWebViewClient(new WebViewClient());

        try {

            byte[] post = EncodingUtils.getBytes("USERNAME=" + usr + "&PASSWORD=" + pwd, "BASE64");
            webView.postUrl(uriToDisplay, post);

        } catch (Exception e) {
            String message = e.getMessage();
        }
    } else//ODControl
    {
        webView = (WebView) findViewById(R.id.webView1);

        webView.setHttpAuthUsernamePassword(uriToDisplay, "/", "user@opendomo.com", "opendomo");
        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new MyWebViewClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://local.opendomo.com");

    }

}

From source file:com.panet.imeta.core.xml.XMLHandler.java

/**
 * Load a file into an XML document/*from   w w w. j av a 2s  .co m*/
 * 
 * @param filename
 *            The filename to load into a document
 * @param systemId
 *            Provide a base for resolving relative URIs.
 * @param ignoreEntities
 *            Ignores external entities and returns an empty dummy.
 * @param namespaceAware
 *            support XML namespaces.
 * @return the Document if all went well, null if an error occured!
 */
public static final Document loadXMLFile(FileObject fileObject, String systemID, boolean ignoreEntities,
        boolean namespaceAware) throws KettleXMLException {
    DocumentBuilderFactory dbf;
    DocumentBuilder db;
    Document doc;

    try {
        // Check and open XML document
        dbf = DocumentBuilderFactory.newInstance();
        dbf.setIgnoringComments(true);
        dbf.setNamespaceAware(namespaceAware);
        db = dbf.newDocumentBuilder();
        // even dbf.setValidating(false) will the parser NOT prevent from
        // checking the existance of the DTD
        // thus we need to give the BaseURI (systemID) below to have a
        // chance to get it
        // or return empty dummy documents for all external entities
        // (sources)
        if (ignoreEntities)
            db.setEntityResolver(new DTDIgnoringEntityResolver());
        InputStream inputStream = null;
        try {
            if (Const.isEmpty(systemID)) {
                // Normal parsing
                //
                inputStream = KettleVFS.getInputStream(fileObject);
                doc = db.parse(inputStream);
            } else {
                // Do extra verifications
                //
                String systemIDwithEndingSlash = systemID.trim();
                // make sure we have an ending slash, otherwise the last
                // part will be ignored
                if (!systemIDwithEndingSlash.endsWith("/") && !systemIDwithEndingSlash.endsWith("\\")) {
                    systemIDwithEndingSlash = systemIDwithEndingSlash.concat("/");
                }
                inputStream = KettleVFS.getInputStream(fileObject);
                doc = db.parse(inputStream, systemIDwithEndingSlash);
            }
        } catch (FileNotFoundException ef) {
            throw new KettleXMLException(ef);
        } finally {
            if (inputStream != null)
                inputStream.close();
        }

        return doc;
    } catch (Exception e) {
        throw new KettleXMLException("Error reading information from file", e);
    }
}

From source file:org.jasig.portlet.newsreader.dao.HibernateNewsStore.java

public List<UserDefinedNewsConfiguration> getUserDefinedNewsConfigurations(Long setId, boolean visibleOnly) {
    try {// w  w  w  . j  av  a 2s. com

        String query = "from NewsConfiguration config where " + "config.newsSet.id = ? and "
                + "config.class = UserDefinedNewsConfiguration " + "order by newsDefinition.name";
        if (visibleOnly)
            query = query.concat(" and visibleOnly = true");

        return (List<UserDefinedNewsConfiguration>) getHibernateTemplate().find(query, setId);

    } catch (HibernateException ex) {
        throw convertHibernateAccessException(ex);
    }
}

From source file:org.sakaiproject.component.app.messageforums.RankManagerImpl.java

/**
 * Apparently, the ContentResource object gives a url, but it doesn't escape any special characters. So, need to do some
 * escaping just for the name portion of the url. So, find the string "attachment" and escape anything after it.
 *///  www.  j  a  v  a2 s .  com
private String resourceUrlEscaping(String url) {
    int attIndex = url.indexOf("attachment");
    String leftOfAttachment = url.substring(0, attIndex);
    String rightOfAttachment = url.substring(attIndex);

    String finalUrl = leftOfAttachment.concat(Validator.escapeUrl(rightOfAttachment));
    return finalUrl;
}