List of usage examples for java.text SimpleDateFormat toLocalizedPattern
public String toLocalizedPattern()
From source file:it.attocchi.jsf2.PageBase.java
public String getCurrentLocaleDatePattern() { SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, getCurrentLocale());/*from ww w . j av a2 s . c o m*/ return format.toLocalizedPattern(); }
From source file:org.apache.cordova.core.Globalization.java
private JSONObject getDatePattern(JSONArray options) throws GlobalizationError { JSONObject obj = new JSONObject(); try {/*w w w . j av a 2s. c om*/ SimpleDateFormat fmtDate = (SimpleDateFormat) android.text.format.DateFormat .getDateFormat(this.cordova.getActivity()); //default user preference for date SimpleDateFormat fmtTime = (SimpleDateFormat) android.text.format.DateFormat .getTimeFormat(this.cordova.getActivity()); //default user preference for time String fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); //default SHORT date/time format. ex. dd/MM/yyyy h:mm a //get Date value + options (if available) if (options.getJSONObject(0).has(OPTIONS)) { //options were included JSONObject innerOptions = options.getJSONObject(0).getJSONObject(OPTIONS); //get formatLength option if (!innerOptions.isNull(FORMATLENGTH)) { String fmtOpt = innerOptions.getString(FORMATLENGTH); if (fmtOpt.equalsIgnoreCase(MEDIUM)) {//medium fmtDate = (SimpleDateFormat) android.text.format.DateFormat .getMediumDateFormat(this.cordova.getActivity()); } else if (fmtOpt.equalsIgnoreCase(LONG) || fmtOpt.equalsIgnoreCase(FULL)) { //long/full fmtDate = (SimpleDateFormat) android.text.format.DateFormat .getLongDateFormat(this.cordova.getActivity()); } } //return pattern type fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); if (!innerOptions.isNull(SELECTOR)) { String selOpt = innerOptions.getString(SELECTOR); if (selOpt.equalsIgnoreCase(DATE)) { fmt = fmtDate.toLocalizedPattern(); } else if (selOpt.equalsIgnoreCase(TIME)) { fmt = fmtTime.toLocalizedPattern(); } } } //TimeZone from users device //TimeZone tz = Calendar.getInstance(Locale.getDefault()).getTimeZone(); //substitute method TimeZone tz = TimeZone.getTimeZone(Time.getCurrentTimezone()); obj.put("pattern", fmt); obj.put("timezone", tz.getDisplayName(tz.inDaylightTime(Calendar.getInstance().getTime()), TimeZone.SHORT)); obj.put("utc_offset", tz.getRawOffset() / 1000); obj.put("dst_offset", tz.getDSTSavings() / 1000); return obj; } catch (Exception ge) { throw new GlobalizationError(GlobalizationError.PATTERN_ERROR); } }
From source file:org.apache.cordova.Globalization.java
private JSONObject getDatePattern(JSONArray options) throws GlobalizationError { JSONObject obj = new JSONObject(); try {/* ww w . j a va2 s. c o m*/ SimpleDateFormat fmtDate = (SimpleDateFormat) android.text.format.DateFormat .getDateFormat(this.cordova.getActivity()); //default user preference for date SimpleDateFormat fmtTime = (SimpleDateFormat) android.text.format.DateFormat .getTimeFormat(this.cordova.getActivity()); //default user preference for time String fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); //default SHORT date/time format. ex. dd/MM/yyyy h:mm a //get Date value + options (if available) boolean test = options.getJSONObject(0).has(OPTIONS); if (options.getJSONObject(0).has(OPTIONS)) { //options were included JSONObject innerOptions = options.getJSONObject(0).getJSONObject(OPTIONS); //get formatLength option if (!innerOptions.isNull(FORMATLENGTH)) { String fmtOpt = innerOptions.getString(FORMATLENGTH); if (fmtOpt.equalsIgnoreCase(MEDIUM)) {//medium fmtDate = (SimpleDateFormat) android.text.format.DateFormat .getMediumDateFormat(this.cordova.getActivity()); } else if (fmtOpt.equalsIgnoreCase(LONG) || fmtOpt.equalsIgnoreCase(FULL)) { //long/full fmtDate = (SimpleDateFormat) android.text.format.DateFormat .getLongDateFormat(this.cordova.getActivity()); } } //return pattern type fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); if (!innerOptions.isNull(SELECTOR)) { String selOpt = innerOptions.getString(SELECTOR); if (selOpt.equalsIgnoreCase(DATE)) { fmt = fmtDate.toLocalizedPattern(); } else if (selOpt.equalsIgnoreCase(TIME)) { fmt = fmtTime.toLocalizedPattern(); } } } //TimeZone from users device //TimeZone tz = Calendar.getInstance(Locale.getDefault()).getTimeZone(); //substitute method TimeZone tz = TimeZone.getTimeZone(Time.getCurrentTimezone()); obj.put("pattern", fmt); obj.put("timezone", tz.getDisplayName(tz.inDaylightTime(Calendar.getInstance().getTime()), TimeZone.SHORT)); obj.put("utc_offset", tz.getRawOffset() / 1000); obj.put("dst_offset", tz.getDSTSavings() / 1000); return obj; } catch (Exception ge) { throw new GlobalizationError(GlobalizationError.PATTERN_ERROR); } }
From source file:org.syncope.console.pages.ApprovalModalPage.java
public ApprovalModalPage(final PageReference callerPageRef, final ModalWindow window, final WorkflowFormTO formTO) { super();/*from ww w . jav a2 s . com*/ IModel<List<WorkflowFormPropertyTO>> formProps = new LoadableDetachableModel<List<WorkflowFormPropertyTO>>() { private static final long serialVersionUID = 3169142472626817508L; @Override protected List<WorkflowFormPropertyTO> load() { return formTO.getProperties(); } }; final ListView<WorkflowFormPropertyTO> propView = new ListView<WorkflowFormPropertyTO>("propView", formProps) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(final ListItem<WorkflowFormPropertyTO> item) { final WorkflowFormPropertyTO prop = item.getModelObject(); Label label = new Label("key", prop.getName() == null ? prop.getId() : prop.getName()); item.add(label); FieldPanel field = null; switch (prop.getType()) { case Boolean: field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), new Model(Boolean.valueOf(prop.getValue())), true) .setChoices(Arrays.asList(new String[] { "Yes", "No" })); break; case Date: SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern()) ? new SimpleDateFormat(prop.getDatePattern()) : new SimpleDateFormat(); Date parsedDate = null; if (StringUtils.isNotBlank(prop.getValue())) { try { parsedDate = df.parse(prop.getValue()); } catch (ParseException e) { LOG.error("Unparsable date: {}", prop.getValue(), e); } } field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(), new Model(parsedDate), true, df.toLocalizedPattern()); break; case Enum: MapChoiceRenderer<String, String> enumCR = new MapChoiceRenderer<String, String>( prop.getEnumValues()); field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), new Model(prop.getValue()), true).setChoiceRenderer(enumCR).setChoices(new Model() { private static final long serialVersionUID = -858521070366432018L; @Override public Serializable getObject() { return new ArrayList(prop.getEnumValues().keySet()); } }); break; case Long: field = new AjaxNumberFieldPanel("value", label.getDefaultModelObjectAsString(), new Model(Long.valueOf(prop.getValue())), Long.class, true); break; case String: default: field = new AjaxTextFieldPanel("value", PARENT_PATH, new Model(prop.getValue()), true); break; } field.setReadOnly(!prop.isWritable()); if (prop.isRequired()) { field.addRequiredLabel(); } item.add(field); } }; final AjaxButton submit = new IndicatingAjaxButton("apply", new Model(getString("submit"))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { Map<String, WorkflowFormPropertyTO> props = formTO.getPropertiesAsMap(); for (int i = 0; i < propView.size(); i++) { ListItem<WorkflowFormPropertyTO> item = (ListItem<WorkflowFormPropertyTO>) propView.get(i); String input = ((FieldPanel) item.get("value")).getField().getInput(); if (!props.containsKey(item.getModelObject().getId())) { props.put(item.getModelObject().getId(), new WorkflowFormPropertyTO()); } if (item.getModelObject().isWritable()) { switch (item.getModelObject().getType()) { case Boolean: props.get(item.getModelObject().getId()).setValue(String.valueOf(input.equals("0"))); break; case Date: case Enum: case String: case Long: default: props.get(item.getModelObject().getId()).setValue(input); break; } } } formTO.setProperties(props.values()); try { restClient.submitForm(formTO); ((Todo) callerPageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientCompositeErrorException e) { error(getString("error") + ":" + e.getMessage()); LOG.error("While submitting form {}", formTO, e); target.add(feedbackPanel); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { target.add(feedbackPanel); } }; Form form = new Form("form"); form.add(propView); form.add(submit); MetaDataRoleAuthorizationStrategy.authorize(form, ENABLE, xmlRolesReader.getAllAllowedRoles("Approval", "submit")); add(form); }
From source file:org.apache.syncope.console.pages.ApprovalModalPage.java
public ApprovalModalPage(final PageReference pageRef, final ModalWindow window, final WorkflowFormTO formTO) { super();/*w w w . j a v a 2 s .c o m*/ IModel<List<WorkflowFormPropertyTO>> formProps = new LoadableDetachableModel<List<WorkflowFormPropertyTO>>() { private static final long serialVersionUID = 3169142472626817508L; @Override protected List<WorkflowFormPropertyTO> load() { return formTO.getProperties(); } }; final ListView<WorkflowFormPropertyTO> propView = new AltListView<WorkflowFormPropertyTO>("propView", formProps) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<WorkflowFormPropertyTO> item) { final WorkflowFormPropertyTO prop = item.getModelObject(); Label label = new Label("key", prop.getName() == null ? prop.getId() : prop.getName()); item.add(label); FieldPanel field; switch (prop.getType()) { case Boolean: field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), new Model<Boolean>(Boolean.valueOf(prop.getValue()))) .setChoices(Arrays.asList(new String[] { "Yes", "No" })); break; case Date: SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern()) ? new SimpleDateFormat(prop.getDatePattern()) : new SimpleDateFormat(); Date parsedDate = null; if (StringUtils.isNotBlank(prop.getValue())) { try { parsedDate = df.parse(prop.getValue()); } catch (ParseException e) { LOG.error("Unparsable date: {}", prop.getValue(), e); } } field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(), new Model<Date>(parsedDate), df.toLocalizedPattern()); break; case Enum: MapChoiceRenderer<String, String> enumCR = new MapChoiceRenderer<String, String>( prop.getEnumValues()); field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), new Model(prop.getValue())).setChoiceRenderer(enumCR).setChoices(new Model() { private static final long serialVersionUID = -858521070366432018L; @Override public Serializable getObject() { return new ArrayList<String>(prop.getEnumValues().keySet()); } }); break; case Long: field = new SpinnerFieldPanel<Long>("value", label.getDefaultModelObjectAsString(), Long.class, new Model<Long>(NumberUtils.toLong(prop.getValue())), null, null); break; case String: default: field = new AjaxTextFieldPanel("value", PARENT_PATH, new Model<String>(prop.getValue())); break; } field.setReadOnly(!prop.isWritable()); if (prop.isRequired()) { field.addRequiredLabel(); } item.add(field); } }; final AjaxButton userDetails = new IndicatingAjaxButton("userDetails", new Model<String>(getString("userDetails"))) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { editUserWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ViewUserModalPage(ApprovalModalPage.this.getPageReference(), editUserWin, userRestClient.read(formTO.getUserId())) { private static final long serialVersionUID = -2819994749866481607L; @Override protected void closeAction(final AjaxRequestTarget target, final Form form) { setResponsePage(ApprovalModalPage.this); } }; } }); editUserWin.show(target); } }; MetaDataRoleAuthorizationStrategy.authorize(userDetails, ENABLE, xmlRolesReader.getAllAllowedRoles("Users", "read")); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { Map<String, WorkflowFormPropertyTO> props = formTO.getPropertyMap(); for (int i = 0; i < propView.size(); i++) { @SuppressWarnings("unchecked") ListItem<WorkflowFormPropertyTO> item = (ListItem<WorkflowFormPropertyTO>) propView.get(i); String input = ((FieldPanel) item.get("value")).getField().getInput(); if (!props.containsKey(item.getModelObject().getId())) { props.put(item.getModelObject().getId(), new WorkflowFormPropertyTO()); } if (item.getModelObject().isWritable()) { switch (item.getModelObject().getType()) { case Boolean: props.get(item.getModelObject().getId()).setValue(String.valueOf("0".equals(input))); break; case Date: case Enum: case String: case Long: default: props.get(item.getModelObject().getId()).setValue(input); break; } } } formTO.setProperties(props.values()); try { restClient.submitForm(formTO); ((Todo) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); LOG.error("While submitting form {}", formTO, e); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form form) { // nothing } }; cancel.setDefaultFormProcessing(false); Form form = new Form(FORM); form.add(propView); form.add(userDetails); form.add(submit); form.add(cancel); MetaDataRoleAuthorizationStrategy.authorize(form, ENABLE, xmlRolesReader.getAllAllowedRoles("Approval", SUBMIT)); editUserWin = new ModalWindow("editUserWin"); editUserWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editUserWin.setInitialHeight(USER_WIN_HEIGHT); editUserWin.setInitialWidth(USER_WIN_WIDTH); editUserWin.setCookieName("edit-user-modal"); add(editUserWin); add(form); }
From source file:org.apache.syncope.client.console.pages.ApprovalModalPage.java
public ApprovalModalPage(final PageReference pageRef, final ModalWindow window, final WorkflowFormTO formTO) { super();//from w ww . j a va 2 s .com IModel<List<WorkflowFormPropertyTO>> formProps = new LoadableDetachableModel<List<WorkflowFormPropertyTO>>() { private static final long serialVersionUID = 3169142472626817508L; @Override protected List<WorkflowFormPropertyTO> load() { return formTO.getProperties(); } }; final ListView<WorkflowFormPropertyTO> propView = new AltListView<WorkflowFormPropertyTO>("propView", formProps) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<WorkflowFormPropertyTO> item) { final WorkflowFormPropertyTO prop = item.getModelObject(); Label label = new Label("key", prop.getName() == null ? prop.getId() : prop.getName()); item.add(label); FieldPanel field; switch (prop.getType()) { case Boolean: field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), new Model<Boolean>(Boolean.valueOf(prop.getValue()))) .setChoices(Arrays.asList(new String[] { "Yes", "No" })); break; case Date: SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern()) ? new SimpleDateFormat(prop.getDatePattern()) : new SimpleDateFormat(); Date parsedDate = null; if (StringUtils.isNotBlank(prop.getValue())) { try { parsedDate = df.parse(prop.getValue()); } catch (ParseException e) { LOG.error("Unparsable date: {}", prop.getValue(), e); } } field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(), new Model<Date>(parsedDate), df.toLocalizedPattern()); break; case Enum: MapChoiceRenderer<String, String> enumCR = new MapChoiceRenderer<String, String>( prop.getEnumValues()); field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), new Model(prop.getValue())).setChoiceRenderer(enumCR).setChoices(new Model() { private static final long serialVersionUID = -858521070366432018L; @Override public Serializable getObject() { return new ArrayList<String>(prop.getEnumValues().keySet()); } }); break; case Long: field = new SpinnerFieldPanel<Long>("value", label.getDefaultModelObjectAsString(), Long.class, new Model<Long>(NumberUtils.toLong(prop.getValue())), null, null); break; case String: default: field = new AjaxTextFieldPanel("value", PARENT_PATH, new Model<String>(prop.getValue())); break; } field.setReadOnly(!prop.isWritable()); if (prop.isRequired()) { field.addRequiredLabel(); } item.add(field); } }; final AjaxButton userDetails = new IndicatingAjaxButton("userDetails", new Model<String>(getString("userDetails"))) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { editUserWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ViewUserModalPage(ApprovalModalPage.this.getPageReference(), editUserWin, userRestClient.read(formTO.getUserKey())) { private static final long serialVersionUID = -2819994749866481607L; @Override protected void closeAction(final AjaxRequestTarget target, final Form form) { setResponsePage(ApprovalModalPage.this); } }; } }); editUserWin.show(target); } }; MetaDataRoleAuthorizationStrategy.authorize(userDetails, ENABLE, xmlRolesReader.getEntitlement("Users", "read")); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { Map<String, WorkflowFormPropertyTO> props = formTO.getPropertyMap(); for (int i = 0; i < propView.size(); i++) { @SuppressWarnings("unchecked") ListItem<WorkflowFormPropertyTO> item = (ListItem<WorkflowFormPropertyTO>) propView.get(i); String input = ((FieldPanel) item.get("value")).getField().getInput(); if (!props.containsKey(item.getModelObject().getId())) { props.put(item.getModelObject().getId(), new WorkflowFormPropertyTO()); } if (item.getModelObject().isWritable()) { switch (item.getModelObject().getType()) { case Boolean: props.get(item.getModelObject().getId()).setValue(String.valueOf("0".equals(input))); break; case Date: case Enum: case String: case Long: default: props.get(item.getModelObject().getId()).setValue(input); break; } } } formTO.getProperties().clear(); formTO.getProperties().addAll(props.values()); try { restClient.submitForm(formTO); ((Todo) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); LOG.error("While submitting form {}", formTO, e); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form form) { // nothing } }; cancel.setDefaultFormProcessing(false); Form form = new Form(FORM); form.add(propView); form.add(userDetails); form.add(submit); form.add(cancel); MetaDataRoleAuthorizationStrategy.authorize(form, ENABLE, xmlRolesReader.getEntitlement("Approval", SUBMIT)); editUserWin = new ModalWindow("editUserWin"); editUserWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editUserWin.setInitialHeight(USER_WIN_HEIGHT); editUserWin.setInitialWidth(USER_WIN_WIDTH); editUserWin.setCookieName("edit-user-modal"); add(editUserWin); add(form); }
From source file:be.ibridge.kettle.trans.step.textfileinput.TextFileInput.java
public static final Row convertLineToRow(LogWriter log, TextFileLine textFileLine, TextFileInputMeta info, DecimalFormat ldf, DecimalFormatSymbols ldfs, SimpleDateFormat ldaf, DateFormatSymbols ldafs, String fname, long rowNr, FileErrorHandler errorHandler) throws KettleException { Row r = new Row(); if (textFileLine == null || textFileLine.line == null || textFileLine.line.length() == 0) return r; int fieldnr;//from w ww. j a v a2 s . c om Value value; Value errorCount = null; if (info.isErrorIgnored() && info.getErrorCountField() != null && info.getErrorCountField().length() > 0) { errorCount = new Value(info.getErrorCountField(), 0L); } Value errorFields = null; if (info.isErrorIgnored() && info.getErrorFieldsField() != null && info.getErrorFieldsField().length() > 0) { errorFields = new Value(info.getErrorFieldsField(), ""); } Value errorText = null; if (info.isErrorIgnored() && info.getErrorTextField() != null && info.getErrorTextField().length() > 0) { errorText = new Value(info.getErrorTextField(), ""); } int nrfields = info.getInputFields().length; try { // System.out.println("Convertings line to string ["+line+"]"); ArrayList strings = convertLineToStrings(log, textFileLine.line, info); for (fieldnr = 0; fieldnr < nrfields; fieldnr++) { TextFileInputField f = info.getInputFields()[fieldnr]; String field = fieldnr < nrfields ? f.getName() : "empty" + fieldnr; int type = fieldnr < nrfields ? f.getType() : Value.VALUE_TYPE_STRING; String format = fieldnr < nrfields ? f.getFormat() : ""; int length = fieldnr < nrfields ? f.getLength() : -1; int precision = fieldnr < nrfields ? f.getPrecision() : -1; String group = fieldnr < nrfields ? f.getGroupSymbol() : ""; String decimal = fieldnr < nrfields ? f.getDecimalSymbol() : ""; String currency = fieldnr < nrfields ? f.getCurrencySymbol() : ""; String nullif = fieldnr < nrfields ? f.getNullString() : ""; String ifnull = fieldnr < nrfields ? f.getIfNullValue() : ""; int trim_type = fieldnr < nrfields ? f.getTrimType() : TextFileInputMeta.TYPE_TRIM_NONE; if (fieldnr < strings.size()) { String pol = (String) strings.get(fieldnr); try { value = convertValue(pol, field, type, format, length, precision, group, decimal, currency, nullif, ifnull, trim_type, ldf, ldfs, ldaf, ldafs); } catch (Exception e) { // OK, give some feedback! String message = "Couldn't parse field [" + field + "] with value [" + pol + "], format [" + format + "] ldaf=[" + ldaf.toLocalizedPattern() + "]"; if (info.isErrorIgnored()) { log.logBasic(fname, "WARNING: " + message + " : " + e.getMessage()); value = new Value(field, type); value.setNull(); if (errorCount != null) { errorCount.plus(1L); } if (errorFields != null) { StringBuffer sb = new StringBuffer(errorFields.getString()); if (sb.length() > 0) sb.append(", "); sb.append(field); errorFields.setValue(sb); } if (errorText != null) { StringBuffer sb = new StringBuffer(errorText.getString()); if (sb.length() > 0) sb.append(Const.CR); sb.append(message); errorText.setValue(sb); } if (errorHandler != null) { errorHandler.handleLineError(textFileLine.lineNumber, AbstractFileErrorHandler.NO_PARTS); } if (info.isErrorLineSkipped()) r.setIgnore(); } else { throw new KettleException(message, e); } } } else { // No data found: TRAILING NULLCOLS: add null value... value = new Value(field, type); value.setNull(); } // Now add value to the row! r.addValue(value); } // Add the error handling fields... if (errorCount != null) r.addValue(errorCount); if (errorFields != null) r.addValue(errorFields); if (errorText != null) r.addValue(errorText); // Support for trailing nullcols! if (fieldnr < info.getInputFields().length) { for (int i = fieldnr; i < info.getInputFields().length; i++) { TextFileInputField f = info.getInputFields()[i]; value = new Value(f.getName(), f.getType()); // build a // value! value.setLength(f.getLength(), f.getPrecision()); value.setNull(); r.addValue(value); } } } catch (Exception e) { throw new KettleException("Error converting line", e); } // Possibly add a filename... if (info.includeFilename()) { Value inc = new Value(info.getFilenameField(), fname); inc.setLength(100); r.addValue(inc); } // Possibly add a row number... if (info.includeRowNumber()) { Value inc = new Value(info.getRowNumberField(), Value.VALUE_TYPE_INTEGER); inc.setValue(rowNr); inc.setLength(9); r.addValue(inc); } return r; }