@Override public void initialize(Arguments args) throws DirectiveParseException { toLower = true; if (args.contains("case")) { Identifier identifier = args.value("case"); String casing = identifier.value(); if (casing.equalsIgnoreCase("upper") || casing.equalsIgnoreCase("uppercase")) { toLower = false; } } }
@Override public void initialize(Arguments args) throws DirectiveParseException { source = args.value("source"); if (args.contains("target")) { target = args.value("target"); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); if (args.contains("timezone")) { this.timezone = TimeZone.getTimeZone(((Text) args.value("timezone")).value()); } else { this.timezone = TimeZone.getTimeZone("UTC"); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); if (args.contains("sheet")) { this.sheet = ((Text) args.value("sheet")).value(); } else { this.sheet = "0"; } if (args.contains("first-row-as-header")) { this.firstRowAsHeader = ((Boolean) args.value("first-row-as-header").value()); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.source = args.value("source"); this.destination = args.value("destination"); if (args.contains("force")) { force = (boolean) args.value("force").value(); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { condition = ((Expression) args.value("condition")).value(); try { el.compile(condition); } catch (ELException e) { throw new DirectiveParseException( String.format("Invalid condition '%s'.", condition) ); } if (args.contains("metric")) { metric = ((Identifier) args.value("metric")).value(); } if (args.contains("message")) { message = ((Text) args.value("message")).value(); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { condition = ((Expression) args.value("condition")).value(); try { el.compile(condition); } catch (ELException e) { throw new DirectiveParseException( String.format("Invalid condition '%s'.", condition) ); } if (args.contains("metric")) { metric = ((Identifier) args.value("metric")).value(); } if (args.contains("message")) { message = ((Text) args.value("message")).value(); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.col = ((ColumnName) args.value("column")).value(); List<LazyNumber> numbers = ((NumericList) args.value("width")).value(); this.widths = new int[numbers.size()]; int idx = 0; int sum = 0; while (idx < numbers.size()) { this.widths[idx] = numbers.get(idx).intValue(); sum += this.widths[idx]; idx = idx + 1; } this.recordLength = sum; if(args.contains("padding")) { this.padding = ((Text) args.value("padding")).value(); } else { this.padding = null; } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.col = ((ColumnName) args.value("column")).value(); if (args.contains("depth")) { this.depth = ((Numeric) args.value("depth")).value().intValue(); } else { this.depth = Integer.MAX_VALUE; } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); if (args.contains("depth")) { this.depth = ((Numeric) args.value("depth")).value().intValue(); } else { this.depth = Integer.MAX_VALUE; } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); this.timeUnit = TimeUnit.MILLISECONDS; if (args.contains("timeunit")) { String unitValue = ((Text) args.value("timeunit")).value(); this.timeUnit = getTimeUnit(unitValue); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.source = ((ColumnName) args.value("source")).value(); this.destination = ((ColumnName) args.value("destination")).value(); if (args.contains("locale")) { this.locale = ((Text) args.value("locale")).value(); } else { this.locale = "en_US"; } this.lcl = LocaleUtils.toLocale(locale); this.format = NumberFormat.getCurrencyInstance(lcl); }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); this.schemaId = ((Identifier) args.value("schema-id")).value(); this.type = ((Identifier) args.value("encode-type")).value(); if (!"json".equalsIgnoreCase(type) && !"binary".equalsIgnoreCase(type)) { throw new DirectiveParseException( String.format("Parsing AVRO can be either of type 'json' or 'binary'") ); } if(args.contains("version")) { this.version = ((Numeric) args.value("version")).value().intValue(); } else { this.version = -1; } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.source = ((ColumnName) args.value("source")).value(); this.destination = ((ColumnName) args.value("destination")).value(); if (args.contains("locale")) { this.locale = ((Text) args.value("locale")).value(); } else { this.locale = "en_US"; } this.lcl = LocaleUtils.toLocale(locale); this.fmt = NumberFormat.getCurrencyInstance(lcl); ((DecimalFormat)this.fmt).setParseBigDecimal(true); }
@Override public void initialize(Arguments args) throws DirectiveParseException { columnArg = args.value("col"); char delimiter = ','; if (args.contains("delimiter")) { delimiterArg = args.value("delimiter"); delimiter = delimiterArg.value().charAt(0); if (delimiterArg.value().startsWith("\\")) { String unescapedStr = StringEscapeUtils.unescapeJava(delimiterArg.value()); if (unescapedStr == null) { throw new DirectiveParseException("Invalid delimiter for CSV Parser: " + delimiterArg.value()); } delimiter = unescapedStr.charAt(0); } } this.format = CSVFormat.DEFAULT.withDelimiter(delimiter); this.format.withIgnoreEmptyLines(true) .withAllowMissingColumnNames(true) .withIgnoreSurroundingSpaces(true) .withRecordSeparator('\n'); this.hasHeader = false; if(args.contains("header")) { headerArg = args.value("header"); this.hasHeader = headerArg.value(); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { column = ((ColumnName) args.value("column")).value(); delimiter = ((Text) args.value("delimiter")).value(); if (args.contains("limit")) { Numeric numeric = args.value("limit"); limit = numeric.value().intValue(); } else { limit = Integer.MAX_VALUE; } }
@Override public void initialize(Arguments args) throws DirectiveParseException { isTrue = true; if (args.contains("type")) { isTrue = ((Bool) args.value("type")).value(); } condition = ((Expression) args.value("condition")).value(); try { el.compile(condition); } catch (ELException e) { throw new DirectiveParseException(e.getMessage()); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); Text algorithm = args.value("algorithm"); if (!MessageHash.isValid(algorithm.value())) { throw new DirectiveParseException( String.format("Algorithm '%s' specified in directive '%s' at line %d is not supported", algorithm, NAME, args.line()) ); } try { this.digest = MessageDigest.getInstance(algorithm.value()); } catch (NoSuchAlgorithmException e) { throw new DirectiveParseException( String.format("Unable to find algorithm specified '%s' in directive '%s' at line %d.", algorithm, NAME, args.line()) ); } this.encode = false; if(args.contains("encode")) { this.encode = ((Bool) args.value("encode")).value(); } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); this.schemaId = ((Identifier) args.value("schema-id")).value(); this.recordName = ((Text) args.value("record-name")).value(); if(args.contains("version")) { this.version = ((Numeric) args.value("version")).value().intValue(); } else { this.version = -1; } }
@Override public void initialize(Arguments args) throws DirectiveParseException { this.column = ((ColumnName) args.value("column")).value(); if (args.contains("depth")) { this.depth = ((Numeric) args.value("depth")).value().intValue(); } else { this.depth = Integer.MAX_VALUE; } context = new DefaultHapiContext(); context.setValidationContext(new NoValidation()); ModelClassFactory modelClassFactory = new GenericModelClassFactory(); parser = new PipeParser(modelClassFactory); parser.getParserConfiguration().setAllowUnknownVersions(true); }