Java Code Examples for org.apache.logging.log4j.util.Strings#EMPTY
The following examples show how to use
org.apache.logging.log4j.util.Strings#EMPTY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileAppenderTest.java From logging-log4j2 with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: PostgresqlSerializer.java From hugegraph with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: SomaticRefContextEnrichment.java From hmftools with GNU General Public License v3.0 | 6 votes |
@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); }
Example 4
Source File: LoggerConfig.java From logging-log4j2 with Apache License 2.0 | 6 votes |
/** * 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)); }
Example 5
Source File: IndexedBasesTest.java From hmftools with GNU General Public License v3.0 | 5 votes |
@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)); }
Example 6
Source File: AbstractJacksonLayout.java From logging-log4j2 with Apache License 2.0 | 5 votes |
/** * 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; } }
Example 7
Source File: ReadContextCounterTest.java From hmftools with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 8
Source File: LoggerConfig.java From logging-log4j2 with Apache License 2.0 | 5 votes |
/** * 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); }
Example 9
Source File: SnpEffAnnotationFactory.java From hmftools with GNU General Public License v3.0 | 5 votes |
@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; } }
Example 10
Source File: Level.java From logging-log4j2 with Apache License 2.0 | 5 votes |
/** * 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; } }
Example 11
Source File: ProtectActionability.java From hmftools with GNU General Public License v3.0 | 5 votes |
@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; }
Example 12
Source File: AbstractJacksonLayout.java From summerframework with Apache License 2.0 | 5 votes |
@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; } }
Example 13
Source File: LoggerContextAdmin.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@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; }
Example 14
Source File: OperationLogAspect.java From we-cmdb with Apache License 2.0 | 5 votes |
private String getRequestUrl(){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); if(request == null){ return Strings.EMPTY; } return request.getRequestURL().toString(); }
Example 15
Source File: SampleReport.java From hmftools with GNU General Public License v3.0 | 4 votes |
@NotNull @Value.Derived public String primaryTumorLocationString() { PatientTumorLocation type = patientTumorLocation(); return type != null ? type.primaryTumorLocation() : Strings.EMPTY; }
Example 16
Source File: GelfLayout.java From logging-log4j2 with Apache License 2.0 | 4 votes |
private static CharSequence toNullSafeString(final CharSequence s) { return s == null ? Strings.EMPTY : s; }
Example 17
Source File: SmtpRequest.java From logging-log4j2 with Apache License 2.0 | 4 votes |
/** * 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; }
Example 18
Source File: ThreadDumpMessage.java From logging-log4j2 with Apache License 2.0 | 4 votes |
private ThreadDumpMessage(final String formattedMsg, final String title) { this.formattedMessage = formattedMsg; this.title = title == null ? Strings.EMPTY : title; }