当前位置: 首页>>代码示例>>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;未经允许,请勿转载。