Example usage for java.lang String toString

List of usage examples for java.lang String toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

This object (which is already a string!) is itself returned.

Usage

From source file:com.clican.pluto.fsm.engine.state.TaskStateImpl.java

/**
 * ??//from w ww  .  j  av a  2  s .com
 * 
 * @param state
 * @param event
 * @return
 */
protected List<Task> assignTasks(State state, Event event) {
    List<Task> tasks = new ArrayList<Task>();
    Calendar current = Calendar.getInstance();
    Session session = state.getSession();
    Set<Variable> variableSet = session.getVariableSet();
    Map<String, Object> vars = new HashMap<String, Object>();
    for (Variable var : variableSet) {
        vars.put(var.getName(), var.getValue());
    }
    variableSet = event.getVariableSet();
    for (Variable var : variableSet) {
        vars.put(var.getName(), var.getValue());
    }
    String assigneesValue = (String) MVEL.eval(assignees, vars);
    String[] assignees = assigneesValue.split(",");
    String taskNameValue;
    if (StringUtils.isEmpty(taskName)) {
        taskNameValue = getName();
    } else {
        taskNameValue = (String) MVEL.eval(taskName, vars);
    }
    String taskTypeValue;
    if (StringUtils.isEmpty(taskType)) {
        taskTypeValue = getName();
    } else {
        taskTypeValue = (String) MVEL.eval(taskType, vars);
    }
    for (String assignee : assignees) {
        Task task = newTask(state, assignee.toString(), current.getTime(), taskNameValue, taskTypeValue);
        tasks.add(task);
    }
    if (tasks.size() == 0) {
        throw new RuntimeException("There is no task assigned");
    }
    return tasks;
}

From source file:de.mpg.escidoc.services.transformation.Util.java

/**
 * queries the framework with the given request
 * @param request//  www .  jav a2s  .  com
 * @return XML document returned by the framework
 * @throws Exception
 */
public static Document queryFramework(String request) throws Exception {
    final String FRAMEWORK_PROPERTY = "escidoc.framework_access.framework.url";
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryImpl.newInstance();
    DocumentBuilder documentBuilder;
    String url = null;
    String frameworkUrl = null;
    Document document = null;
    try {
        frameworkUrl = PropertyReader.getProperty(FRAMEWORK_PROPERTY);
        url = frameworkUrl + request;

        if (logger.isDebugEnabled())
            logger.debug("queryFramework: (" + url.toString() + ")");

        documentBuilderFactory.setNamespaceAware(true);
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        document = documentBuilder.newDocument();

        HttpClient client = new HttpClient();
        GetMethod getMethod = new GetMethod(url);
        int statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            InputStream input = getMethod.getResponseBodyAsStream();
            document = documentBuilder.parse(input);
        } else {
            throw new RuntimeException("Error requesting <" + url + ">");
        }
    } catch (IOException e) {
        logger.error("IOException when getting Property <" + FRAMEWORK_PROPERTY + ">\n"
                + "Or reading document from URL <" + url, e);
        throw e;
    } catch (URISyntaxException e) {
        logger.error("Invalid URL when getting Property: <" + FRAMEWORK_PROPERTY + ">", e);
        throw e;
    } catch (ParserConfigurationException e) {
        logger.error("Parser configuration error", e);
        throw e;
    } catch (SAXException e) {
        logger.error("Could not parse returned XML", e);
        throw e;
    }

    return document;
}

From source file:gate.corpora.twitter.Tweet.java

/**
 * Used by the JSONTWeetFormat; the DocumentContent contains only the main text;
 * the annotation feature map contains all the other JSON data, recursively.
 *///from ww  w.  j av a2 s  . c  o  m
private Tweet(JsonNode json) {
    string = "";
    Iterator<String> keys = json.fieldNames();
    FeatureMap features = Factory.newFeatureMap();
    annotations = new HashSet<PreAnnotation>();

    while (keys.hasNext()) {
        String key = keys.next();

        if (key.equals(TweetUtils.DEFAULT_TEXT_ATTRIBUTE)) {
            string = StringEscapeUtils.unescapeHtml(json.get(key).asText());
        } else {
            features.put(key.toString(), TweetUtils.process(json.get(key)));
        }
    }

    annotations.add(new PreAnnotation(0L, string.length(), TweetUtils.TWEET_ANNOTATION_TYPE, features));
}

From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLURIDereferencer.java

private InputStream findDataInputStream(String uri) throws IOException {
    String entryName;/*from   w w  w  .  j  a  v  a  2s . c o m*/
    if (uri.startsWith("/")) {
        entryName = uri.substring(1); // remove '/'
    } else {
        entryName = uri.toString();
    }
    if (-1 != entryName.indexOf("?")) {
        entryName = entryName.substring(0, entryName.indexOf("?"));
    }
    LOG.debug("ZIP entry name: " + entryName);

    InputStream ooxmlInputStream;
    if (null != this.ooxmlDocument) {
        ooxmlInputStream = new ByteArrayInputStream(this.ooxmlDocument);
    } else {
        ooxmlInputStream = this.ooxmlUrl.openStream();
    }
    ZipArchiveInputStream ooxmlZipInputStream = new ZipArchiveInputStream(ooxmlInputStream, "UTF8", true, true);
    ZipEntry zipEntry;
    while (null != (zipEntry = ooxmlZipInputStream.getNextZipEntry())) {
        if (zipEntry.getName().equals(entryName)) {
            return ooxmlZipInputStream;
        }
    }
    return null;
}

From source file:br.com.ifpb.bdnc.projeto.geo.servlets.CadastraImagem.java

private Image mountImage(HttpServletRequest request) {
    Image image = new Image();
    image.setCoord(new Coordenate());
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if (isMultipart) {
        ServletFileUpload upload = new ServletFileUpload();
        try {/*from  w ww.  ja  v a  2  s . co  m*/
            FileItemIterator itr = upload.getItemIterator(request);
            while (itr.hasNext()) {
                FileItemStream item = itr.next();
                if (item.isFormField()) {
                    InputStream in = item.openStream();
                    byte[] b = new byte[in.available()];
                    in.read(b);
                    if (item.getFieldName().equals("description")) {
                        image.setDescription(new String(b));
                    } else if (item.getFieldName().equals("authors")) {
                        image.setAuthors(new String(b));
                    } else if (item.getFieldName().equals("end")) {
                        image.setDate(
                                LocalDate.parse(new String(b), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                    } else if (item.getFieldName().equals("latitude")) {
                        image.getCoord().setLat(new String(b));
                    } else if (item.getFieldName().equals("longitude")) {
                        image.getCoord().setLng(new String(b));
                    } else if (item.getFieldName().equals("heading")) {
                        image.getCoord().setHeading(new String(b));
                    } else if (item.getFieldName().equals("pitch")) {
                        image.getCoord().setPitch(new String(b));
                    } else if (item.getFieldName().equals("zoom")) {
                        image.getCoord().setZoom(new String(b));
                    }
                } else {
                    if (!item.getName().equals("")) {
                        MultipartData md = new MultipartData();
                        String folder = "historicImages";
                        md.setFolder(folder);
                        String path = request.getServletContext().getRealPath("/");
                        System.out.println(path);
                        String nameToSave = "pubImage" + Calendar.getInstance().getTimeInMillis()
                                + item.getName();
                        image.setImagePath(folder + "/" + nameToSave);
                        md.saveImage(path, item, nameToSave);
                        String imageMinPath = folder + "/" + "min" + nameToSave;
                        RedimencionadorImagem.resize(path, folder + "/" + nameToSave,
                                path + "/" + imageMinPath.toString(), IMAGE_MIN_WIDTH, IMAGE_MIM_HEIGHT);
                        image.setMinImagePath(imageMinPath);
                    }
                }
            }
        } catch (FileUploadException | IOException ex) {
            System.out.println("Erro ao manipular dados");
        }
    }
    return image;
}

From source file:com.fluidops.iwb.ui.configuration.SparqlEditor.java

/**
 * In case the entered query does not contain the '??' variable
 * the user is redirected to the search results page in a new tab,
 * otherwise an error message in a popup window is displayed.
 * // w w w. j a  va 2s.c  o m
 */
private void showPreview() {

    if (query.contains("??")) {
        FDialog.showMessage(getPage(), "Info",
                "The preview of results for this query is not possible: reference to the current resource encountered ('??').",
                "Ok");
        return;
    }

    String location = EndpointImpl.api().getRequestMapper().getContextPath() + "/sparql" + "?query=" + query
            + "&format=auto&infer=false";

    String tokenBase = com.fluidops.iwb.util.Config.getConfig().getServletSecurityKey() + query;
    String securityToken = null;
    try {
        securityToken = SHA512.encrypt(tokenBase);
        location += "&st=" + URLEncoder.encode(securityToken.toString(), "UTF-8");
        addClientUpdate(new FClientUpdate("window.open('" + location + "', '_blank');"));

    } catch (Exception e) {
        logger.debug("Error while preparing preview of SPARQL query:" + e.getMessage(), e);
        throw new IllegalStateException("Error while preparing preview of SPARQL query: " + e.getMessage(), e);
    }
}

From source file:com.openmeap.http.HttpRequestExecuterImpl.java

protected List<NameValuePair> createNameValuePairs(Map<String, Object> params) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(params.size());
    for (Map.Entry<String, Object> entry : params.entrySet()) {

        if (entry.getValue() instanceof List) {

            List<String> values = (List<String>) entry.getValue();
            for (String value : values) {

                nameValuePairs.add(new BasicNameValuePair(entry.getKey() + "[]", value.toString()));
            }//  w w  w  .  j a  v a  2s .  c o  m
        } else {

            nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
        }
    }
    return nameValuePairs;
}

From source file:es.eucm.rage.realtime.states.elasticsearch.EsMapState.java

private String toSingleKey(List<Object> key) {
    String result = "";
    for (Object o : key) {
        result += o;/*from w  ww .ja  v a  2  s  .  co  m*/
    }
    return result.toString();
}

From source file:edu.wustl.xipHost.avt2ext.AVTUtil.java

public static SearchResult convertToSearchResult(Object object, SearchResult initialSearchResult,
        Object selectedObject) {//from ww w  . ja va  2 s .co m
    SearchResult resultAD = null;
    if (initialSearchResult == null) {
        resultAD = new SearchResult("AD Database");
    } else {
        resultAD = initialSearchResult;
    }
    Patient patientFromAD = null;
    Study studyFromAD = null;
    Series seriesFromAD = null;
    Item itemFromAD = null;
    List<?> listOfObjects = (List<?>) object;
    Iterator<?> iter = listOfObjects.iterator();
    while (iter.hasNext()) {
        java.lang.Object obj = iter.next();
        if (obj == null) {
            logger.warn("Object recieved as a result of query is null");
            continue;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
        //selectedObject == null means it is a first query in a progressive query process 
        if (selectedObject == null) {
            if (obj instanceof com.siemens.scr.avt.ad.dicom.Patient) {
                com.siemens.scr.avt.ad.dicom.Patient patientAD = com.siemens.scr.avt.ad.dicom.Patient.class
                        .cast(obj);
                String patientName = patientAD.getPatientName();
                if (patientName == null) {
                    patientName = "";
                }
                String patientID = patientAD.getPatientID();
                if (patientID == null) {
                    patientID = "";
                }
                Date patientADBirthDate = patientAD.getPatientBirthDate();
                Calendar patientBirthDate = Calendar.getInstance();
                String strPatientBirthDate = null;
                if (patientADBirthDate != null) {
                    patientBirthDate.setTime(patientADBirthDate);
                    strPatientBirthDate = sdf.format(patientBirthDate.getTime());
                    if (strPatientBirthDate == null) {
                        strPatientBirthDate = "";
                    }
                } else {
                    strPatientBirthDate = "";
                }
                if (resultAD.contains(patientID) == false) {
                    patientFromAD = new Patient(patientName, patientID, strPatientBirthDate);
                    resultAD.addPatient(patientFromAD);
                }
            } else {

            }
        } else if (selectedObject instanceof Patient) {
            patientFromAD = Patient.class.cast(selectedObject);
            com.siemens.scr.avt.ad.dicom.GeneralStudy studyAD = com.siemens.scr.avt.ad.dicom.GeneralStudy.class
                    .cast(obj);
            Date studyDateTime = studyAD.getStudyDateTime();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(studyDateTime);
            String studyDate = null;
            if (calendar != null) {
                studyDate = sdf.format(calendar.getTime());
                if (studyDate == null) {
                    studyDate = "";
                }
            } else {
                studyDate = "";
            }
            String studyID = studyAD.getStudyID();
            if (studyID == null) {
                studyID = "";
            }
            String studyDesc = studyAD.getStudyDescription();
            if (studyDesc == null) {
                studyDesc = "";
            }
            String studyInstanceUID = studyAD.getStudyInstanceUID();
            if (studyInstanceUID == null) {
                studyInstanceUID = "";
            }
            studyFromAD = new Study(studyDate, studyID, studyDesc, studyInstanceUID);
            if (patientFromAD.contains(studyInstanceUID) == false) {
                studyFromAD = new Study(studyDate, studyID, studyDesc, studyInstanceUID);
                patientFromAD.addStudy(studyFromAD);
            }
            Timestamp lastUpdated = new Timestamp(Calendar.getInstance().getTime().getTime());
            patientFromAD.setLastUpdated(lastUpdated);
        } else if (selectedObject instanceof Study) {
            studyFromAD = Study.class.cast(selectedObject);
            com.siemens.scr.avt.ad.dicom.GeneralSeries seriesAD = com.siemens.scr.avt.ad.dicom.GeneralSeries.class
                    .cast(obj);
            String seriesNumber = seriesAD.getSeriesNumber();
            if (seriesNumber == null) {
                seriesNumber = "";
            }
            String modality = seriesAD.getModality();
            if (modality == null) {
                modality = "";
            }
            String seriesDesc = seriesAD.getSeriesDescription();
            if (seriesDesc == null) {
                seriesDesc = "";
            }
            String seriesInstanceUID = seriesAD.getSeriesInstanceUID();
            if (seriesInstanceUID == null) {
                seriesInstanceUID = "";
            }
            if (studyFromAD.contains(seriesInstanceUID) == false) {
                seriesFromAD = new Series(seriesNumber.toString(), modality, seriesDesc, seriesInstanceUID);
                studyFromAD.addSeries(seriesFromAD);
            }
            Timestamp lastUpdated = new Timestamp(Calendar.getInstance().getTime().getTime());
            studyFromAD.setLastUpdated(lastUpdated);
        } else if (selectedObject instanceof Series) {
            seriesFromAD = Series.class.cast(selectedObject);
            if (obj instanceof com.siemens.scr.avt.ad.dicom.GeneralImage) {
                com.siemens.scr.avt.ad.dicom.GeneralImage itemAD = com.siemens.scr.avt.ad.dicom.GeneralImage.class
                        .cast(obj);
                String itemSOPInstanceUID = itemAD.getSOPInstanceUID();
                if (itemSOPInstanceUID == null) {
                    itemSOPInstanceUID = "";
                }
                if (seriesFromAD.containsItem(itemSOPInstanceUID) == false) {
                    itemFromAD = new ImageItem(itemSOPInstanceUID);
                }
            } else if (obj instanceof String) {
                String imageAnnotationType = "";
                String dateTime = "";
                String authorName = "";
                String aimUID = String.class.cast(obj);
                itemFromAD = new AIMItem(imageAnnotationType, dateTime, authorName, aimUID);
            }
            seriesFromAD.addItem(itemFromAD);
            Timestamp lastUpdated = new Timestamp(Calendar.getInstance().getTime().getTime());
            seriesFromAD.setLastUpdated(lastUpdated);
        }
    }
    Util.searchResultToLog(resultAD);
    return resultAD;
}

From source file:mercury.core.Deferred.java

public void callDeferredWithJSON(final String method, String parameter) {
    runLater(() -> {/* w w w  . j  av a  2s.c  om*/
        timer.start();
        deferred.call(method, toJSON(parameter));
        timer.elapsed("deferred." + method + "(" + parameter.toString() + ")");
    });
}