當前位置: 首頁>>代碼示例>>Java>>正文


Java Casts類代碼示例

本文整理匯總了Java中nl.basjes.parse.core.Casts的典型用法代碼示例。如果您正苦於以下問題:Java Casts類的具體用法?Java Casts怎麽用?Java Casts使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Casts類屬於nl.basjes.parse.core包,在下文中一共展示了Casts類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
public void run() throws NoSuchMethodException, MissingDissectorsException, InvalidDissectorException {
    HttpdLoglineParser<MyRecord> parser = new HttpdLoglineParser<>(MyRecord.class, logFormat);

    List<String> allPossiblePaths = parser.getPossiblePaths();
    parser.addParseTarget(MyRecord.class.getMethod("setter", String.class, String.class), allPossiblePaths);

    System.out.println("class MyRecord {\n");

    for (String field : parser.getPossiblePaths()) {
        for (Casts cast : parser.getCasts(field)) {
            System.out.println("    @Field{\"" + field + "\"}\n" +
                    "    public void setter(String name, " + castToJavaType(cast) + " value) {\n" +
                    "        System.out.println(\"SETTER CALLED FOR \\\"\" + name + \"\\\" = \\\"\" + value + \"\\\"\");\n" +
                    "    }\n");
        }
    }
    System.out.println("}\n");
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:19,代碼來源:PojoGenerator.java

示例2: prepareForDissect

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public EnumSet<Casts> prepareForDissect(final String inputname, final String outputname) {
    String name = extractFieldName(inputname, outputname);
    if ("epoch".equals(name)) {
        wantTime = true;
        return Casts.STRING_OR_LONG;
    }
    if ("ip".equals(name)) {
        wantIp = true;
        return Casts.STRING_OR_LONG;
    }
    if ("processid".equals(name)) {
        wantProcessId = true;
        return Casts.STRING_OR_LONG;
    }
    if ("counter".equals(name)) {
        wantCounter = true;
        return Casts.STRING_OR_LONG;
    }
    if ("threadindex".equals(name)) {
        wantThreadIndex = true;
        return Casts.STRING_OR_LONG;
    }
    return null;
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:26,代碼來源:ModUniqueIdDissector.java

示例3: addField

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
/**
 * This record will be used with a single parser. For each field that is to be parsed a setter will be called. It
 * registers a setter method for each field being parsed. It also builds the data writers to hold the data beings
 * parsed.
 *
 * @param parser
 * @param mapWriter
 * @param type
 * @param parserFieldName
 * @param drillFieldName
 * @throws NoSuchMethodException
 */
public void addField(final Parser<HttpdLogRecord> parser, final MapWriter mapWriter, final EnumSet<Casts> type, final String parserFieldName, final String drillFieldName) throws NoSuchMethodException {
  final boolean hasWildcard = parserFieldName.endsWith(HttpdParser.PARSER_WILDCARD);

  /**
   * This is a dynamic way to map the setter for each specified field type. <br/>
   * e.g. a TIME.STAMP may map to a LONG while a referrer may map to a STRING
   */
  if (hasWildcard) {
    final String cleanName = parserFieldName.substring(0, parserFieldName.length() - HttpdParser.PARSER_WILDCARD.length());
    LOG.debug("Adding WILDCARD parse target: {} as {}, with field name: {}", parserFieldName, cleanName, drillFieldName);
    parser.addParseTarget(this.getClass().getMethod("setWildcard", String.class, String.class), parserFieldName);
    parser.addParseTarget(this.getClass().getMethod("setWildcard", String.class, Double.class), parserFieldName);
    parser.addParseTarget(this.getClass().getMethod("setWildcard", String.class, Long.class), parserFieldName);
    wildcards.put(cleanName, mapWriter.map(drillFieldName));
  }
  else if (type.contains(Casts.DOUBLE)) {
    LOG.debug("Adding DOUBLE parse target: {}, with field name: {}", parserFieldName, drillFieldName);
    parser.addParseTarget(this.getClass().getMethod("set", String.class, Double.class), parserFieldName);
    doubles.put(parserFieldName, mapWriter.float8(drillFieldName));
  }
  else if (type.contains(Casts.LONG)) {
    LOG.debug("Adding LONG parse target: {}, with field name: {}", parserFieldName, drillFieldName);
    parser.addParseTarget(this.getClass().getMethod("set", String.class, Long.class), parserFieldName);
    longs.put(parserFieldName, mapWriter.bigInt(drillFieldName));
  }
  else {
    LOG.debug("Adding STRING parse target: {}, with field name: {}", parserFieldName, drillFieldName);
    parser.addParseTarget(this.getClass().getMethod("set", String.class, String.class), parserFieldName);
    strings.put(parserFieldName, mapWriter.varChar(drillFieldName));
  }
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:44,代碼來源:HttpdLogRecord.java

示例4: castToJavaType

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
private String castToJavaType(Casts casts) {
    switch (casts) {
        case STRING:
            return "String";
        case LONG:
            return "Long";
        case DOUBLE:
            return "Double";
        default:
            return null;
    }
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:13,代碼來源:PojoGenerator.java

示例5: prepareForDissect

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public EnumSet<Casts> prepareForDissect(String inputname, String outputname) {
    if (dissectors.size() == 0) {
        return null;
    }

    EnumSet<Casts> result = EnumSet.noneOf(Casts.class); // Start empty
    for (Dissector dissector : dissectors) {
        result.addAll(dissector.prepareForDissect(inputname, outputname));
    }
    return result;
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:13,代碼來源:HttpdLogFormatDissector.java

示例6: createFirstAndLastTokenParsers

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
private List<TokenParser> createFirstAndLastTokenParsers(
    final String nLogFormatToken,
    final String nValueName,
    final String nValueType,
    final EnumSet<Casts> nCasts,
    final String nRegex) {
    return createFirstAndLastTokenParsers(nLogFormatToken, nValueName, nValueType, nCasts, nRegex, 0);
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:9,代碼來源:ApacheHttpdLogFormatDissector.java

示例7: prepareForDissect

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public EnumSet<Casts> prepareForDissect(final String inputname, final String outputname) {
    String name = extractFieldName(inputname, outputname);
    switch (name) {
        case "value":   return Casts.STRING_ONLY;
        case "expires": return Casts.STRING_OR_LONG;
        case "path":    return Casts.STRING_ONLY;
        case "domain":  return Casts.STRING_ONLY;
        case "comment": return Casts.STRING_ONLY;
        default:        return Casts.STRING_ONLY;
    }
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:13,代碼來源:ResponseSetCookieDissector.java

示例8: NamedTokenParser

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
public NamedTokenParser(
        final String nLogFormatToken,
        final String nValueName,
        final String nValueType,
        final EnumSet<Casts> nCasts,
        final String nRegex) {
    this(nLogFormatToken, nValueName, nValueType, nCasts, nRegex, 0);
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:9,代碼來源:NamedTokenParser.java

示例9: NotImplementedTokenParser

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
public NotImplementedTokenParser(final String nLogFormatToken, final String fieldPrefix, final String regEx, int nPrio) {
    super(nLogFormatToken,
        fieldPrefix + "_" + nLogFormatToken.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9_]", "_"),
        "NOT_IMPLEMENTED",
        Casts.STRING_ONLY,
        regEx,
        nPrio);
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:9,代碼來源:TokenFormatDissector.java

示例10: prepareForDissect

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public EnumSet<Casts> prepareForDissect(final String inputName, final String outputName) {
    requestedFields.add(outputName);
    for (Token token: logFormatTokens) {
        for (TokenOutputField tokenOutputField: token.getOutputFields()) {
            if (outputName.equals(tokenOutputField.getName())) {
                tokenOutputField.wasUsed();
                return tokenOutputField.getCasts();
            }
        }
    }
    return Casts.STRING_ONLY;
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:14,代碼來源:TokenFormatDissector.java

示例11: TokenParser

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
public TokenParser(final String nLogFormatToken,
        final String nValueName,
        final String nValueType,
        final EnumSet<Casts> nCasts,
        final String nRegex) {
    this(nLogFormatToken, nValueName, nValueType, nCasts, nRegex, 10);
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:8,代碼來源:TokenParser.java

示例12: ParameterizedTokenParser

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
public ParameterizedTokenParser(
        final String nLogFormatToken,
        final String nValueName,
        final String nValueType,
        final EnumSet<Casts> nCasts,
        final String nRegex,
        final int prio,
        final Dissector customDissector) {
    super(nLogFormatToken, nValueName, nValueType, nCasts, nRegex, prio, customDissector);

    // Compile the regular expression
    pattern = Pattern.compile(getLogFormatToken());
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:14,代碼來源:ParameterizedTokenParser.java

示例13: addOutputField

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public TokenParser addOutputField(String type, String name, EnumSet<Casts> casts) {
    if (getOutputFields().isEmpty()) {
        return super.addOutputField(type, name, casts);
    }
    throw new UnsupportedOperationException("A ParameterizedTokenParser only supports ONE outputfield.");
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:8,代碼來源:ParameterizedTokenParser.java

示例14: prepareForDissect

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public EnumSet<Casts> prepareForDissect(String inputname, String outputname) {
    String name = extractFieldName(inputname, outputname);
    if ("width".equals(name)) {
        wantWidth = true;
        return Casts.STRING_OR_LONG;
    }
    if ("height".equals(name)) {
        wantHeight = true;
        return Casts.STRING_OR_LONG;
    }
    return null;
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:14,代碼來源:ScreenResolutionDissector.java

示例15: prepareForDissect

import nl.basjes.parse.core.Casts; //導入依賴的package包/類
@Override
public EnumSet<Casts> prepareForDissect(final String inputname, final String outputname) {
    String name = extractFieldName(inputname, outputname);
    if ("protocol".equals(name)) {
        wantProtocol = true;
        return Casts.STRING_ONLY;
    }
    if ("userinfo".equals(name)) {
        wantUserinfo = true;
        return Casts.STRING_ONLY;
    }
    if ("host".equals(name)) {
        wantHost = true;
        return Casts.STRING_ONLY;
    }
    if ("port".equals(name)) {
        wantPort = true;
        return Casts.STRING_OR_LONG;
    }
    if ("path".equals(name)) {
        wantPath = true;
        return Casts.STRING_ONLY;
    }
    if ("query".equals(name)) {
        wantQuery = true;
        return Casts.STRING_ONLY;
    }
    if ("ref".equals(name)) {
        wantRef = true;
        return Casts.STRING_ONLY;
    }
    return null;
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:34,代碼來源:HttpUriDissector.java


注:本文中的nl.basjes.parse.core.Casts類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。