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:org.duracloud.snapshot.service.impl.RestoreJobExecutionListener.java

private void sendEmail(String subject, String msg, String... destinations) {
    notificationManager.sendNotification(NotificationType.EMAIL, subject, msg.toString(), destinations);

    log.info("sent email with subject=\"" + subject + "\" to " + StringUtils.join(destinations, ","));
}

From source file:cc.kave.episodes.export.StreamPartition.java

public Map<String, Integer> partition() throws ZipException, IOException {
    Map<String, Integer> mapping = Maps.newLinkedHashMap();
    EventStreamGenerator generator = new EventStreamGenerator();
    Map<Event, Integer> allEvents = getStream();

    String zipName = "";
    int partitionNo = 0;

    for (String zip : findZips()) {
        zipName = zip.toString();

        if (REPO.equalsIgnoreCase("")) {
            partitionNo++;//w w  w.ja va2  s.  co  m
            Logger.log("Partition %d", partitionNo);

            REPO = getRepoName(zipName);
        }
        if (!zipName.startsWith(REPO)) {
            mapping.put(REPO, partitionNo);
            REPO = getRepoName(zipName);
            storeStream(generator, allEvents, partitionNo);

            partitionNo++;
            Logger.log("Partition %d", partitionNo);
            generator = new EventStreamGenerator();
        }
        ReadingArchive ra = rootDir.getReadingArchive(zip);

        while (ra.hasNext()) {
            Context ctx = ra.getNext(Context.class);
            if (ctx == null) {
                continue;
            }
            generator.add(ctx);
        }
        ra.close();
    }
    Logger.log("Total number of partitions is: %d", partitionNo);
    storeStream(generator, allEvents, partitionNo);
    mapping.put(REPO, partitionNo);
    return mapping;
}

From source file:BwaSingleAlignment.java

/**
 * Code to run in each one of the mappers. This is, the alignment with the corresponding entry data
 * The entry data has to be written into the local filesystem
 *//*w  ww .j ava  2 s  .  co  m*/
@Override
public Iterator<String> call(Integer arg0, Iterator<String> arg1) throws Exception {

    LOG.info("JMAbuin:: Tmp dir: " + this.tmpDir);
    String fastqFileName1 = this.tmpDir + this.appId + "-RDD" + arg0 + "_1";

    LOG.info("JMAbuin:: Writing file: " + fastqFileName1);

    File FastqFile1 = new File(fastqFileName1);
    FileOutputStream fos1;
    BufferedWriter bw1;

    ArrayList<String> returnedValues = new ArrayList<String>();

    try {
        fos1 = new FileOutputStream(FastqFile1);
        bw1 = new BufferedWriter(new OutputStreamWriter(fos1));

        String newFastqRead;

        while (arg1.hasNext()) {
            newFastqRead = arg1.next();

            bw1.write(newFastqRead.toString());
            bw1.newLine();
        }

        bw1.close();

        //We do not need the input data anymore, as it is written in a local file
        arg1 = null;

        returnedValues = this.runAlignmentProcess(arg0, fastqFileName1, null);
        // Delete the temporary file, as is have now been copied to the
        // output directory
        FastqFile1.delete();

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        LOG.error(e.toString());
    }

    return returnedValues.iterator();
}

From source file:cc.kave.episodes.export.StreamPartition.java

private Map<Event, Integer> getStream() throws IOException {
    EventStreamGenerator generator = new EventStreamGenerator();

    for (String zip : findZips()) {
        Logger.log("Reading zip file %s", zip.toString());
        ReadingArchive ra = rootDir.getReadingArchive(zip);

        while (ra.hasNext()) {
            Context ctx = ra.getNext(Context.class);
            if (ctx == null) {
                continue;
            }// www.  j a v a 2 s . c  o  m
            generator.add(ctx);
        }
        ra.close();
    }
    List<Event> allEvents = generator.getEventStream();
    EventStream complStream = EventsFilter.filterStream(allEvents, REMFREQS);
    EventStreamIo.write(complStream, getStreamPath(), getMappingPath());

    return complStream.getMapping();
}

From source file:gov.va.vinci.leo.listener.CSVBaseListenerTest.java

@Test
/**//  ww w.j a v a2 s.  c o m
 * Test NOT escaping quotes.
 */
public void testCharSepraratorQuoteCharNewLine() throws IOException {
    File f = File.createTempFile("testCharSepraratorQuoteCharNewLine", "txt");
    TestCsvListener listener = new TestCsvListener(f, '-', '\'', "<CRLF>");
    listener.entityProcessComplete(cas, null);
    String b = FileUtils.readFileToString(f).trim();
    assertEquals("\'a\'-\'b\'-\'\"\"c\'<CRLF>", b.toString());
}

From source file:org.kuali.rice.krworkshop.RoutingAttributeSplitNode.java

protected String getDocumentId(RouteContext context) {
    final String documentID = context.getNodeInstance().getDocumentId();
    return documentID != null ? documentID.toString() : null;
}

From source file:org.openxdata.server.engine.OpenXDataLoggingEngineImpl.java

/**
 * Builds a {@link Diagnosis} from given <tt>Log File</tt> output.
 * /*from w  ww  .  j  a v a2  s . com*/
 * @param logFileOutput <tt>Log File</tt> output to diagnose.
 * @return Instance of {@link Diagnosis}.
 */
private Diagnosis buildDiagnosisFromHTMLFileOutput(String logFileOutput) {

    Diagnosis diagnosis = new Diagnosis();
    String logFileStream = logFileOutput.toString();

    if (logFileStream != null) {

        // Retrieve Latest Error.
        String latestError = LoggingEngineUtil.getLatestError(logFileOutput);

        // Determine Risk Level.
        ErrorRiskLevel riskLevel = LoggingEngineUtil.determineErrorRiskLevel(logFileOutput);

        // Determine Diagnosed status.
        DiagnosedStatus status = LoggingEngineUtil.determineDiagnosedStatus(logFileOutput);

        int errorCount = Log4jHtmlParser.getErrorCount(logFileOutput);

        // Set Diagnosis properties.
        diagnosis.setRiskLevel(riskLevel);
        diagnosis.setDiagnosedStatus(status);
        diagnosis.setLatestError(latestError);
        diagnosis.setLogFileStream(logFileOutput);
        diagnosis.setErrorCount(errorCount);
    }

    return diagnosis;
}

From source file:com.des.paperbase.ManageData.java

public JSONObject getJsonFromString(String input) throws ParseException {
    return (JSONObject) new JSONParser().parse(input.toString());
}

From source file:com.edgenius.wiki.render.handler.ImageHandler.java

public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values)
        throws RenderHandlerException {

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Build ImageModel object, then render it
    String source = values.get(ImageFilter.SRC);
    values.remove(ImageFilter.SRC);

    ImageModel img = new ImageModel();
    if (!source.toLowerCase().startsWith("http://") && !source.toLowerCase().startsWith("https://")) {
        //ok, this normal image render rather than draft preview etc(can see draft images), then remove all draft status attachments from list
        if (renderContext.getPageVisibleAttachments() == null && atts != null) {
            for (Iterator<FileNode> iter = atts.iterator(); iter.hasNext();) {
                FileNode node = iter.next();
                if (node.getStatus() > 0)
                    iter.remove();/*  www  . j  av a  2  s  .c o m*/
            }
        }

        if (atts == null || atts.size() == 0) {
            throw new RenderHandlerException(
                    "Image can not render because image repository can not find any attachment.");
        }

        img.filename = source;
        //try to find the image from repository
        for (FileNode node : atts) {
            if (StringUtils.equalsIgnoreCase(node.getFilename(), source)) {
                //found attachment
                img.url = renderContext.buildDownloadURL(node.getFilename(), node.getNodeUuid(), false);
                break;
            }
        }
    } else {
        img.url = source;
    }

    if (img.url == null) {
        log.info("Unable parse out external image url or unavailable image attachment from " + source);
        throw new RenderHandlerException(
                messageService.getMessage("render.image.not.found", new String[] { source }));
    }
    List<RenderPiece> pieces = new ArrayList<RenderPiece>();
    //does not keep align as they are not standard <img> tag attributes
    img.align = values.remove(NameConstants.ALIGN);
    img.width = values.remove(NameConstants.WIDTH);
    img.height = values.remove(NameConstants.HEIGHT);
    img.title = values.remove(NameConstants.TITLE);
    img.attributes = values;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // render ImageModel
    String imgBuf = img.toRichAjaxTag();

    pieces.add(new TextModel(imgBuf.toString()));
    return pieces;

}

From source file:com.logsniffer.fields.filter.support.SeverityMappingFilter.java

@Override
protected SeverityLevel transform(final String sourceValue) {
    if (_levels == null) {
        resetInternalLevels();//from w w w. ja va 2  s.com
    }
    String strSource = sourceValue.toString().trim();
    if (ignoreCase) {
        strSource = strSource.toLowerCase();
    }
    final SeverityLevel mapping = _levels.get(strSource);
    return mapping;
}