org.apache.logging.log4j.util.Strings#EMPTY源码实例Demo

下面列出了org.apache.logging.log4j.util.Strings#EMPTY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: logging-log4j2   文件: FileAppenderTest.java
private void verifyFile(final int count) throws Exception {
    // String expected = "[\\w]* \\[\\s*\\] INFO TestLogger - Test$";
    final String expected = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} \\[[^\\]]*\\] INFO TestLogger - Test";
    final Pattern pattern = Pattern.compile(expected);
    int lines = 0;
    try (final BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(FILE_NAME)))) {
        String str = Strings.EMPTY;
        while (is.ready()) {
            str = is.readLine();
            // System.out.println(str);
            ++lines;
            final Matcher matcher = pattern.matcher(str);
            assertTrue("Unexpected data: " + str, matcher.matches());
        }
    }
    Assert.assertEquals(count, lines);
}
 
源代码2 项目: hugegraph   文件: PostgresqlSerializer.java
@Override
public BackendEntry writeIndex(HugeIndex index) {
    TableBackendEntry entry = newBackendEntry(index);
    /*
     * When field-values is null and elementIds size is 0, it is
     * meaningful for deletion of index data in secondary/range index.
     */
    if (index.fieldValues() == null && index.elementIds().size() == 0) {
        entry.column(HugeKeys.INDEX_LABEL_ID, index.indexLabel().longId());
    } else {
        Object value = index.fieldValues();
        if (value != null && "\u0000".equals(value)) {
            value = Strings.EMPTY;
        }
        entry.column(HugeKeys.FIELD_VALUES, value);
        entry.column(HugeKeys.INDEX_LABEL_ID, index.indexLabel().longId());
        entry.column(HugeKeys.ELEMENT_IDS,
                     IdUtil.writeStoredString(index.elementId()));
        entry.column(HugeKeys.EXPIRED_TIME, index.expiredTime());
        entry.subId(index.elementId());
    }
    return entry;
}
 
源代码3 项目: hmftools   文件: SomaticRefContextEnrichment.java
@NotNull
static Pair<Integer, String> relativePositionAndRef(@NotNull final IndexedFastaSequenceFile reference, @NotNull final VariantContext variant) {
    final int refLength = variant.getReference().getBaseString().length();
    @Nullable
    final SAMSequenceRecord samSequenceRecord = reference.getSequenceDictionary().getSequence(variant.getContig());
    if (samSequenceRecord == null) {
        LOGGER.warn("Unable to locate contig {} in ref genome", variant.getContig());
        return new Pair<>(-1, Strings.EMPTY);
    }

    final int chromosomeLength = samSequenceRecord.getSequenceLength();
    long positionBeforeEvent = variant.getStart();

    long start = Math.max(positionBeforeEvent - 100, 1);
    long end = Math.min(positionBeforeEvent + refLength + 100 - 1, chromosomeLength - 1);
    int relativePosition = (int) (positionBeforeEvent - start);
    final String sequence;
    if (start < chromosomeLength && end < chromosomeLength) {
        sequence = reference.getSubsequenceAt(variant.getContig(), start, end).getBaseString();
    } else {
        sequence = Strings.EMPTY;
        LOGGER.warn("Requested base sequence outside of chromosome region!");
    }
    return new Pair<>(relativePosition, sequence);
}
 
源代码4 项目: logging-log4j2   文件: LoggerConfig.java
/**
 * Factory method to create a LoggerConfig.
 *
 * @param additivity true if additive, false otherwise.
 * @param level The Level to be associated with the Logger.
 * @param loggerName The name of the Logger.
 * @param includeLocation whether location should be passed downstream
 * @param refs An array of Appender names.
 * @param properties Properties to pass to the Logger.
 * @param config The Configuration.
 * @param filter A Filter.
 * @return A new LoggerConfig.
 * @since 2.6
 */
@PluginFactory
public static LoggerConfig createLogger(
     // @formatter:off
    @PluginAttribute(defaultBoolean = true) final boolean additivity,
    @PluginAttribute final Level level,
    @Required(message = "Loggers cannot be configured without a name") @PluginAttribute("name") final String loggerName,
    @PluginAttribute final String includeLocation,
    @PluginElement final AppenderRef[] refs,
    @PluginElement final Property[] properties,
    @PluginConfiguration final Configuration config,
    @PluginElement final Filter filter
    // @formatter:on
) {
    final String name = loggerName.equals(ROOT) ? Strings.EMPTY : loggerName;
    return new LoggerConfig(name, Arrays.asList(refs), filter, level, additivity, properties, config,
        includeLocation(includeLocation, config));
}
 
源代码5 项目: logging-log4j2   文件: AbstractJacksonLayout.java
/**
 * Formats a {@link org.apache.logging.log4j.core.LogEvent}.
 *
 * @param event
 *            The LogEvent.
 * @return The XML representation of the LogEvent.
 */
@Override
public String toSerializable(final LogEvent event) {
    try (final StringBuilderWriter writer = new StringBuilderWriter()) {
        toSerializable(event, writer);
        return writer.toString();
    } catch (final IOException e) {
        // Should this be an ISE or IAE?
        LOGGER.error(e);
        return Strings.EMPTY;
    }
}
 
源代码6 项目: we-cmdb   文件: OperationLogAspect.java
private String getRequestUrl(){
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
    if(request == null){
        return Strings.EMPTY;
    }

    return request.getRequestURL().toString();
}
 
源代码7 项目: logging-log4j2   文件: LoggerContextAdmin.java
@Override
public String getConfigLocationUri() {
    if (loggerContext.getConfigLocation() != null) {
        return String.valueOf(loggerContext.getConfigLocation());
    }
    if (getConfigName() != null) {
        return String.valueOf(new File(getConfigName()).toURI());
    }
    return Strings.EMPTY;
}
 
源代码8 项目: summerframework   文件: AbstractJacksonLayout.java
@Override
public String toSerializable(final LogEvent event) {
    final StringBuilderWriter writer = new StringBuilderWriter();
    try {
        toSerializable(event, writer);
        return writer.toString();
    } catch (final IOException e) {
        LOGGER.error(e);
        return Strings.EMPTY;
    }
}
 
源代码9 项目: hmftools   文件: ProtectActionability.java
@NotNull
private static String extractPatientTumorLocation(@NotNull String tumorLocationCsv, @NotNull String sampleId) throws IOException {
    PatientTumorLocation tumorLocation = extractTumorLocation(tumorLocationCsv, sampleId);

    String patientPrimaryTumorLocation = Strings.EMPTY;
    if (tumorLocation != null) {
        patientPrimaryTumorLocation = tumorLocation.primaryTumorLocation();
    }

    LOGGER.info(" Retrieved tumor location '{}' for sample {}", patientPrimaryTumorLocation, sampleId);

    return patientPrimaryTumorLocation;
}
 
源代码10 项目: logging-log4j2   文件: Level.java
/**
 * Custom deserialization of Level.
 *
 * @param s serialization stream.
 * @throws IOException            if IO exception.
 * @throws ClassNotFoundException if class not found.
 */
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    level = s.readInt();
    syslogEquivalent = s.readInt();
    levelStr = s.readUTF();
    if (levelStr == null) {
        levelStr = Strings.EMPTY;
    }
}
 
源代码11 项目: hmftools   文件: ReadContextCounterTest.java
@NotNull
public static ReadContext readContext(int refPosition, int readIndex, int leftCentreIndex, int rightCentreIndex, String bases,
        String microhomology) {
    return new ReadContext(Strings.EMPTY,
            refPosition,
            readIndex,
            leftCentreIndex,
            rightCentreIndex,
            0,
            bases.getBytes(),
            microhomology);
}
 
源代码12 项目: hmftools   文件: SnpEffAnnotationFactory.java
@NotNull
private static String[] enforceMinLength(@NotNull String[] parts, int minSize) {
    if (parts.length > minSize) {
        return parts;
    } else {
        final String[] values = new String[minSize];
        for (int i = 0; i < minSize; i++) {
            values[i] = i < parts.length ? parts[i] : Strings.EMPTY;
        }
        System.arraycopy(parts, 0, values, 0, parts.length);

        return values;
    }
}
 
源代码13 项目: logging-log4j2   文件: LoggerConfig.java
/**
 * Default constructor.
 */
public LoggerConfig() {
    this.logEventFactory = LOG_EVENT_FACTORY;
    this.level = Level.ERROR;
    this.name = Strings.EMPTY;
    this.properties = null;
    this.propertiesRequireLookup = false;
    this.config = null;
    this.reliabilityStrategy = new DefaultReliabilityStrategy(this);
}
 
源代码14 项目: hmftools   文件: ReadContextCounterTest.java
@Test
public void testDeleteInRightSoftClip() {
    final IndexedBases refBases = new IndexedBases(553, 0, "TGTTTC".getBytes());
    final VariantHotspot hotspot = ImmutableVariantHotspotImpl.builder().chromosome("1").ref("GT").alt("G").position(554).build();
    final ReadContext readContext = new ReadContext(Strings.EMPTY, 554, 1, 0, 4, 0, "TGTTC".getBytes(), Strings.EMPTY);
    final ReadContextCounter victim = new ReadContextCounter(SAMPLE, hotspot, readContext, RECALIBRATION, TIER, MAX_COVERAGE, 0, true);

    final SAMRecord record = buildSamRecord(553, "2M3S", "TGTTC", "#####");
    victim.accept(record, CONFIG, 1);

    assertEquals(1, victim.depth());
    assertEquals(1, victim.altSupport());
}
 
源代码15 项目: hmftools   文件: IndexedBasesTest.java
@Test
public void testPhasedMNV() {
    ReadContext victim1 = new ReadContext(Strings.EMPTY, 1000, 4, 4, 4, 4, "GATCTTGAT".getBytes(), Strings.EMPTY);
    ReadContext victim2 = new ReadContext(Strings.EMPTY, 1001, 5, 5, 5, 4, "GATCTTGATC".getBytes(), Strings.EMPTY);

    assertTrue(victim1.phased(-1, victim2));
    assertTrue(victim2.phased(1, victim1));
}
 
源代码16 项目: logging-log4j2   文件: ThreadDumpMessage.java
private ThreadDumpMessage(final String formattedMsg, final String title) {
    this.formattedMessage = formattedMsg;
    this.title = title == null ? Strings.EMPTY : title;
}
 
源代码17 项目: hmftools   文件: SampleReport.java
@NotNull
@Value.Derived
public String primaryTumorLocationString() {
    PatientTumorLocation type = patientTumorLocation();
    return type != null ? type.primaryTumorLocation() : Strings.EMPTY;
}
 
源代码18 项目: logging-log4j2   文件: GelfLayout.java
private static CharSequence toNullSafeString(final CharSequence s) {
    return s == null ? Strings.EMPTY : s;
}
 
源代码19 项目: hmftools   文件: MicrohomologyContext.java
@Override
public String toString() {
    return length > 0 ? new String(bases, homologyIndex(), length) : Strings.EMPTY;
}
 
源代码20 项目: logging-log4j2   文件: SmtpRequest.java
/**
 * Execute the SMTP request returning a response. This method models the state transition table for the SMTP server.
 *
 * @return reponse to the request
 */
public SmtpResponse execute() {
    SmtpResponse response = null;
    if (action.isStateless()) {
        if (SmtpActionType.EXPN == action || SmtpActionType.VRFY == action) {
            response = new SmtpResponse(252, "Not supported", this.state);
        } else if (SmtpActionType.HELP == action) {
            response = new SmtpResponse(211, "No help available", this.state);
        } else if (SmtpActionType.NOOP == action) {
            response = new SmtpResponse(250, "OK", this.state);
        } else if (SmtpActionType.VRFY == action) {
            response = new SmtpResponse(252, "Not supported", this.state);
        } else if (SmtpActionType.RSET == action) {
            response = new SmtpResponse(250, "OK", SmtpState.GREET);
        } else {
            response = new SmtpResponse(500, "Command not recognized", this.state);
        }
    } else { // Stateful commands
        if (SmtpActionType.CONNECT == action) {
            if (SmtpState.CONNECT == state) {
                response = new SmtpResponse(220, "localhost Dumbster SMTP service ready", SmtpState.GREET);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.EHLO == action) {
            if (SmtpState.GREET == state) {
                response = new SmtpResponse(250, "OK", SmtpState.MAIL);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.MAIL == action) {
            if (SmtpState.MAIL == state || SmtpState.QUIT == state) {
                response = new SmtpResponse(250, "OK", SmtpState.RCPT);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.RCPT == action) {
            if (SmtpState.RCPT == state) {
                response = new SmtpResponse(250, "OK", this.state);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.DATA == action) {
            if (SmtpState.RCPT == state) {
                response = new SmtpResponse(354, "Start mail input; end with <CRLF>.<CRLF>", SmtpState.DATA_HDR);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.UNRECOG == action) {
            if (SmtpState.DATA_HDR == state || SmtpState.DATA_BODY == state) {
                response = new SmtpResponse(-1, Strings.EMPTY, this.state);
            } else {
                response = new SmtpResponse(500, "Command not recognized", this.state);
            }
        } else if (SmtpActionType.DATA_END == action) {
            if (SmtpState.DATA_HDR == state || SmtpState.DATA_BODY == state) {
                response = new SmtpResponse(250, "OK", SmtpState.QUIT);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.BLANK_LINE == action) {
            if (SmtpState.DATA_HDR == state) {
                response = new SmtpResponse(-1, Strings.EMPTY, SmtpState.DATA_BODY);
            } else if (SmtpState.DATA_BODY == state) {
                response = new SmtpResponse(-1, Strings.EMPTY, this.state);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else if (SmtpActionType.QUIT == action) {
            if (SmtpState.QUIT == state) {
                response = new SmtpResponse(221, "localhost Dumbster service closing transmission channel",
                    SmtpState.CONNECT);
            } else {
                response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
            }
        } else {
            response = new SmtpResponse(500, "Command not recognized", this.state);
        }
    }
    return response;
}