List of usage examples for java.lang NumberFormatException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.diversityarrays.kdxplore.KDXplore.java
public static void mainImpl(String[] args, Closure<KDXploreFrame> onCreateCallback, final Closure<UpdateCheckContext> updateChecker) { Locale defaultLocale = Locale.getDefault(); System.out.println("Locale=" + defaultLocale); //$NON-NLS-1$ // System.setProperty("apple.laf.useScreenMenuBar", "true"); // //$NON-NLS-1$ //$NON-NLS-2$ // Initialise the appFolder KdxplorePreferences prefs = KdxplorePreferences.getInstance(); applyUIdefaultPreferences(prefs);/* w ww .j a v a2s.c o m*/ String kdxploreName = KDXPLORE_APP_NAME; ApplicationFolder defaultAppFolder = ApplicationFolders.getApplicationFolder(kdxploreName); String[] newArgs = CommandArgs.parseRunModeOption(defaultAppFolder, args); String baseNameForDistrib = kdxploreName.toLowerCase(); if (RunMode.DEMO == RunMode.getRunMode()) { kdxploreName = kdxploreName + "Demo"; //$NON-NLS-1$ } final ApplicationFolder appFolder = ApplicationFolders.getApplicationFolder(kdxploreName); CommandArgs commandArgs = new CommandArgs(appFolder, KdxConstants.VERSION, KdxConstants.VERSION_CODE, newArgs); org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClassPathExtender.class); if (commandArgs.baseDir == null) { File userDir = new File(System.getProperty("user.dir")); //$NON-NLS-1$ File distribDir; if ("kdxos_main".equals(userDir.getName())) { // In Eclipse project this is where we store it distribDir = new File(userDir.getParentFile(), baseNameForDistrib); } else { distribDir = new File(userDir, baseNameForDistrib); } System.out.println("userDir=" + userDir); //$NON-NLS-1$ System.out.println("distribDir=" + distribDir); //$NON-NLS-1$ commandArgs.baseDir = distribDir.isDirectory() ? distribDir : userDir; } if (!commandArgs.baseDir.isDirectory()) { GuiUtil.errorMessage(null, "baseDir is not a directory: " + commandArgs.baseDir); //$NON-NLS-1$ System.exit(1); } File libDir = new File(commandArgs.baseDir, "lib"); //$NON-NLS-1$ File[] libFiles = libDir.listFiles(); if (libFiles == null) { MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir), Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libDir.getPath()); System.exit(1); } else if (libFiles.length < REQD_LIB_COUNT) { MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir), Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libFiles.length); System.exit(1); } // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = // = = = = = = = CLASSPATH = = = = = = = ClassPathExtender.VERBOSE = !commandArgs.quiet; // RunMode.getRunMode().isDeveloper(); String libs_sb = "lib,plugins,kdxlibs,../runlibs"; //$NON-NLS-1$ boolean[] seenPdfbox = new boolean[1]; Consumer<File> jarChecker = new Consumer<File>() { @Override public void accept(File f) { if (f.getName().startsWith("pdfbox")) { seenPdfbox[0] = true; } } }; ClassPathExtender.appendToClassPath(commandArgs.baseDir, libs_sb, jarChecker, log); if (seenPdfbox[0]) { System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider"); } // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = doStaticInitChecks(commandArgs.quiet); if (commandArgs.runInitChecks) { System.out.println("Init checks OK"); //$NON-NLS-1$ System.exit(0); } establishLogger(appFolder); @SuppressWarnings("unused") String configName = commandArgs.establishKdxConfig(); Long versionSubinfo = null; if (commandArgs.errmsg == null) { if (!KdxploreConfig.getInstance().isEternal()) { commandArgs.expiryChecks(KdxConstants.VERSION); versionSubinfo = KdxConstants.getVersionSubinfo(); if (versionSubinfo == Long.MAX_VALUE) { versionSubinfo = null; } } } String baseTitle = appFolder.getApplicationName() + " v" + KdxConstants.VERSION; //$NON-NLS-1$ String expiresIn = ""; //$NON-NLS-1$ if (versionSubinfo != null) { if ((0 < versionSubinfo && versionSubinfo < 14) || RunMode.getRunMode().isDeveloper()) { expiresIn = " " + Msg.KDX_EXPIRES_IN_N_DAYS(versionSubinfo.intValue()); //$NON-NLS-1$ } } if (commandArgs.errmsg != null) { JOptionPane.showMessageDialog(null, commandArgs.errmsg, baseTitle + expiresIn, JOptionPane.ERROR_MESSAGE); System.exit(1); } final String kdxploreTitle = buildKdxploreTitle(baseTitle, expiresIn, commandArgs.kdxConfigService.getConfigName()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // TODO allow user to change "base font size" String uiMultiplier = null; try { String propertyName = CommandArgs.UI_MULTIPLIER_PROPERTY_NAME; uiMultiplier = System.getProperty(propertyName); if (uiMultiplier != null) { try { float multiplier = Float.parseFloat(uiMultiplier); setUIfontSize(multiplier); } catch (NumberFormatException e) { System.err.println(String.format("?invalid value for %s: %s", //$NON-NLS-1$ propertyName, uiMultiplier)); } } } catch (SecurityException e) { System.err.println(String.format("Ignoring: %s %s", //$NON-NLS-1$ e.getClass().getSimpleName(), e.getMessage())); } GuiUtil.initLookAndFeel(); try { KDXploreFrame frame = new KDXploreFrame(appFolder, kdxploreTitle, KdxConstants.VERSION_CODE, KdxConstants.VERSION, updateChecker); frame.setVisible(true); if (onCreateCallback != null) { onCreateCallback.execute(frame); } } catch (IOException e) { MsgBox.error(null, e, Msg.ERRTITLE_UNABLE_TO_START_KDXPLORE(KDXPLORE_APP_NAME)); } } }); }
From source file:it.geosolutions.geocollect.android.core.form.action.SendAction.java
/** * Send data to the server//from w ww. j a v a 2 s . com * @param fragment * @param action * @param m * @param p */ private void sendData(SherlockFragment fragment, FormAction action, Mission m, Page pi) { //createProgressAlert(); //uploadData(); android.support.v4.app.FragmentManager fm = fragment.getSherlockActivity().getSupportFragmentManager(); Fragment mTaskFragment = (Fragment) fm.findFragmentByTag(FRAGMENT_UPLOAD_DIALOG); if (mTaskFragment == null) { FragmentTransaction ft = fm.beginTransaction(); String url = (String) action.attributes.get("url");//TODO extenalize String murl = (String) action.attributes.get("mediaurl"); mTaskFragment = new UploadDialog() { /** * Navigate up to the list */ /* (non-Javadoc) * @see it.geosolutions.geocollect.android.core.widgets.dialog.UploadDialog#onFinish(android.app.Activity, it.geosolutions.geocollect.model.http.CommitResponse) */ @Override public void onFinish(Activity ctx, CommitResponse result) { if (result != null && result.isSuccess()) { if (ctx != null) { Toast.makeText(ctx, getResources().getString(R.string.data_send_success), Toast.LENGTH_LONG).show(); Intent i = new Intent(ctx, PendingMissionListActivity.class); i.putExtra(PendingMissionListActivity.KEY_NAVIGATING_UP, true); NavUtils.navigateUpTo(ctx, i); } super.onFinish(ctx, result); } else { Toast.makeText(ctx, R.string.error_sending_data, Toast.LENGTH_LONG).show(); super.onFinish(ctx, result); } } }; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(fragment.getSherlockActivity()); //String authKey = prefs.getString(LoginActivity.PREFS_AUTH_KEY, null); String email = prefs.getString(LoginActivity.PREFS_USER_EMAIL, null); String pass = prefs.getString(LoginActivity.PREFS_PASSWORD, null); int defaultImageSize = 1000; try { defaultImageSize = Integer .parseInt((String) m.getValueByTag(fragment.getSherlockActivity(), "config.maxImageSize")); } catch (NumberFormatException e) { Log.e(SendAction.class.getSimpleName(), e.getClass().getSimpleName(), e); } catch (NullPointerException e) { Log.e(SendAction.class.getSimpleName(), e.getClass().getSimpleName(), e); } String originIDString = MissionUtils.getMissionGCID(m); FormUtils.resizeImagesToMax(fragment.getActivity().getBaseContext(), originIDString, defaultImageSize); Bundle arguments = new Bundle(); // arguments.putString(UploadDialog.PARAMS.DATAURL, url); // arguments.putString(UploadDialog.PARAMS.MEDIAURL, murl); // arguments.putString(UploadDialog.PARAMS.DATA, MissionUtils.generateJsonString(null,m)); // arguments.putString(UploadDialog.PARAMS.ORIGIN_ID, originIDString); // arguments.putString(UploadDialog.PARAMS.MISSION_ID, m.getTemplate().id); // arguments.putString(UploadDialog.PARAMS.BASIC_AUTH, LoginRequestInterceptor.getB64Auth(email, pass)); // arguments.putStringArray(UploadDialog.PARAMS.MEDIA, FormUtils.getPhotoUriStrings(fragment.getActivity().getBaseContext(),originIDString)); // arguments.putBoolean(UploadDialog.PARAMS.MISSION_FEATURE_UPLOAD, false); mTaskFragment.setArguments(arguments); ((DialogFragment) mTaskFragment).setCancelable(false); ft.add(mTaskFragment, FRAGMENT_UPLOAD_DIALOG); //ft.add(R.id.embedded, newFragment); ft.commit(); } }
From source file:org.springframework.data.jdbc.config.oracle.RacFailoverInterceptorBeanDefinitionParser.java
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { //attributes//from ww w . j a v a 2s . c o m List<Integer> recoverableErrorCodesList = new ArrayList<Integer>(); String recoverableErrorCodes = element.getAttribute(RECOVERABLE_ERROR_CODES_ATTRIBUTE); if (StringUtils.hasText(recoverableErrorCodes)) { String[] parsedRecoverableErrorCodes = StringUtils.tokenizeToStringArray(recoverableErrorCodes, ",", true, true); for (int i = 0; i < parsedRecoverableErrorCodes.length; i++) { try { recoverableErrorCodesList.add(new Integer(parsedRecoverableErrorCodes[i])); } catch (NumberFormatException e) { parserContext.getReaderContext().error("Error parsing recoverable error code list: \"" + recoverableErrorCodes + "\"; " + e.getClass().getName() + " - " + e.getMessage(), element); } } if (logger.isDebugEnabled()) { logger.debug( "Using provided " + RECOVERABLE_ERROR_CODES_ATTRIBUTE + ": " + recoverableErrorCodesList); } } String maxNumberOfRetries = element.getAttribute(MAX_NUMBER_OF_RETRIES_ATTRIBUTE); if (logger.isDebugEnabled()) { if (StringUtils.hasText(maxNumberOfRetries)) { logger.debug("Using provided " + MAX_NUMBER_OF_RETRIES_ATTRIBUTE + ": " + maxNumberOfRetries); } } String backOffPolicyRef = null; if (element.hasAttribute(BACK_OFF_POLICY_ATTRIBUTE)) { backOffPolicyRef = element.getAttribute(BACK_OFF_POLICY_ATTRIBUTE); if (logger.isDebugEnabled()) { logger.debug("Using provided " + BACK_OFF_POLICY_ATTRIBUTE + ": " + backOffPolicyRef); } } BeanDefinitionBuilder retryTemplateBuilder = BeanDefinitionBuilder.genericBeanDefinition(); retryTemplateBuilder.getRawBeanDefinition().setBeanClassName(RETRY_TEMPLATE_CLASS); BeanDefinitionBuilder racFailoverRetryPolicyBuilder = BeanDefinitionBuilder.genericBeanDefinition(); racFailoverRetryPolicyBuilder.getRawBeanDefinition().setBeanClassName(RAC_FAILOVER_RETRY_POLICY_CLASS); if (recoverableErrorCodesList.size() > 0) { racFailoverRetryPolicyBuilder.addPropertyValue(RECOVERABLE_ERROR_CODES_PROPERTY, recoverableErrorCodesList); } if (StringUtils.hasText(maxNumberOfRetries)) { racFailoverRetryPolicyBuilder.addPropertyValue(MAX_NUMBER_OF_RETRIES_PROPERTY, maxNumberOfRetries); } retryTemplateBuilder.addPropertyValue(RETRY_POLICY_PROPERTY, racFailoverRetryPolicyBuilder.getRawBeanDefinition()); if (StringUtils.hasText(backOffPolicyRef)) { retryTemplateBuilder.addPropertyReference(BACK_OFF_POLICY_PROPERTY, backOffPolicyRef); } builder.addPropertyValue(RETRY_OPERATIONS_PROPERTY, retryTemplateBuilder.getRawBeanDefinition()); if (logger.isDebugEnabled()) { logger.debug("Using retry policy: " + racFailoverRetryPolicyBuilder.getRawBeanDefinition().getBeanClassName()); } builder.setRole(BeanDefinition.ROLE_SUPPORT); }
From source file:com.brianscottrussell.gameoflife.GameGrid.java
/** * given the grid input String, parses the row count if this is a valid input String * * Sample of expected format of input String where rowCount = 4: * 4 8/* w w w.j a va2s .c om*/ ......../n ....*.../n ...**.../n ........ * * @param input String * @return int as the row count * @throws InvalidGameGridInputException */ private int parseRowCountFromInputString(String input) throws InvalidGameGridInputException { try { // get the character(s), before the 1st space as the rowCount return Integer.valueOf(StringUtils.substring(input, 0, StringUtils.indexOf(input, ' '))); } catch (NumberFormatException e) { throw new InvalidGameGridInputException(e.getClass().getSimpleName() + ": " + e.getMessage()); } }
From source file:com.brianscottrussell.gameoflife.GameGrid.java
/** * given the grid input String, parses the column count if this is a valid input String * * Sample of expected format of input String where columnCount = 8: * 4 8//from www .j a v a 2s .co m ......../n ....*.../n ...**.../n ........ * * @param input String * @return int as the column count * @throws InvalidGameGridInputException */ private int parseColumnCountFromInputString(String input) throws InvalidGameGridInputException { try { // get the character(s), before the 1st carriage return as the rowCount return Integer.valueOf(StringUtils.substring(input, StringUtils.indexOf(input, ' ') + 1, StringUtils.indexOf(input, GameOfLife.LF))); } catch (NumberFormatException e) { throw new InvalidGameGridInputException(e.getClass().getSimpleName() + ": " + e.getMessage()); } }
From source file:org.idempiere.webservices.AbstractService.java
/** * /*from w w w . j av a 2 s .c o m*/ * @param strValue * @param columnClass * @param colName * @param m_webservicetype * @return */ protected Object convertToObj(String strValue, Class<?> columnClass, String colName) { Object value = null; if (columnClass == Boolean.class) { if ("Y".equalsIgnoreCase(strValue) || "true".equalsIgnoreCase(strValue)) value = new Boolean(true); else if ("N".equalsIgnoreCase(strValue) || "false".equalsIgnoreCase(strValue)) value = new Boolean(false); else throw new IdempiereServiceFault(" input column " + colName + " wrong value " + strValue, new QName("setValueAccordingToClass")); } else if (columnClass == Integer.class) { try { value = Integer.parseInt(strValue); } catch (NumberFormatException e) { throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " for " + colName, e.getCause(), new QName("setValueAccordingToClass")); } } else if (columnClass == BigDecimal.class) { try { value = new BigDecimal(strValue); } catch (Exception e) { throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " for " + colName, e.getCause(), new QName("setValueAccordingToClass")); } } else if (columnClass == Timestamp.class) { try { value = Timestamp.valueOf(strValue); } catch (Exception e) { throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " for " + colName, e.getCause(), new QName("setValueAccordingToClass")); } } else if (columnClass == byte[].class) { try { value = Base64.decodeBase64(strValue.getBytes()); } catch (Exception e) { throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " for " + colName, e.getCause(), new QName("setValueAccordingToClass")); } } else { value = strValue; } return value; }
From source file:org.entrystore.repository.impl.ListImpl.java
public void loadChildren() { try {//from w ww . j a v a 2 s . c o m synchronized (this.entry.repository) { if (children != null) { return; } children = new Vector<URI>(); RepositoryConnection rc = entry.repository.getConnection(); try { RepositoryResult<Statement> statements = rc.getStatements(null, null, null, false, this.resourceURI); while (statements.hasNext()) { Statement statement = statements.next(); org.openrdf.model.URI predicate = statement.getPredicate(); if (!predicate.toString().startsWith(RDF.NAMESPACE.toString() + "_")) { continue; } try { // children.add(URI.create(statement.getObject().stringValue())); String value = predicate.toString().substring(RDF.NAMESPACE.length()); int index = Integer.parseInt(value.substring(value.lastIndexOf("_") + 1)); // children.ensureCapacity(index); if (index > children.size()) { children.setSize(index); } children.set(index - 1, URI.create(statement.getObject().stringValue())); } catch (IndexOutOfBoundsException iobe) { log.error( "loadChildren() " + iobe.getClass().getSimpleName() + ": " + iobe.getMessage()); } catch (NumberFormatException nfe) { log.error("loadChildren() " + nfe.getClass().getSimpleName() + ": " + nfe.getMessage()); log.error("Causing statement: " + statement); } } children.trimToSize(); } catch (Exception e) { e.printStackTrace(); } finally { rc.close(); } } } catch (RepositoryException e) { e.printStackTrace(); } }
From source file:com.att.android.arodatacollector.utils.AROCollectorUtils.java
/** * Gets the process ID for the specified process name. * /*w ww . j a va 2 s. co m*/ * @param processName * The name of the process. * * @return The process ID. * @throws java.io.IOException * @throws java.lang.InterruptedException * @throws java.lang.IndexOutOfBoundsException */ public int getProcessID(String processName) throws IOException, InterruptedException { String line = null; int pid = 0; // default line = executePS(processName); String[] rows = line.split("\\n"); if (AROLogger.logVerbose) { for (int rowNum = 0; rowNum < rows.length; rowNum++) { AROLogger.v(TAG, "values row " + rowNum + ": " + ">>>" + rows[rowNum] + "<<<"); } } if (rows[0].startsWith(USER)) { AROLogger.v(TAG, "PID should be in 2nd column in single row retrieved"); for (int rowNum = 1; rowNum < rows.length; rowNum++) { final String row = rows[rowNum]; final String[] values_item = row.split("\\s+"); if (AROLogger.logVerbose) { for (int itemNum = 0; itemNum < values_item.length; itemNum++) { AROLogger.v(TAG, "item " + itemNum + ": " + ">>>" + values_item[itemNum] + "<<<"); } } // expects second column is PID // for (int itemNum = 1; itemNum < values_item.length; // itemNum++) { int itemNum = 1; // second column contains PID if (values_item[itemNum].length() > 0) { String temp = null; temp = values_item[itemNum]; try { pid = Integer.valueOf(temp); } catch (NumberFormatException nfe) { AROLogger.e(TAG, nfe.getClass().getName() + " thrown trying to parse PID"); // will allow to return default PID of 0 } // also check process code status itemNum = 7; // eighth column contains process state code; // do not want Z if (values_item[itemNum].equals("Z")) { continue;// look in next row } AROLogger.d(TAG, "header column: " + itemNum + ">>PID returned: " + pid); } // } return pid; } AROLogger.d(TAG, "exiting if USER block with PID (without finding one): " + pid); } else { AROLogger.d(TAG, "entered else-issuing ps command by itself"); line = executePS(""); rows = line.split("\\n"); if (rows != null && (rows.length > 1)) { int column_num = -1; // default for (int itemNumPS = 0; itemNumPS < rows.length; itemNumPS++) { final String row = rows[itemNumPS]; if (AROLogger.logVerbose) { AROLogger.v(TAG, "row " + itemNumPS + ": " + ">>>" + row + "<<<"); } final String[] value_item = row.split("\\s+"); // assumption on ps // command: // processname // is last row, // so even split // by space will // return // correct item // expect 1st row to return column header names; find column // with "PID" if (itemNumPS == 0) { AROLogger.d(TAG, "header row..."); for (int headerItemNum = 0; headerItemNum < value_item.length; headerItemNum++) { if (AROLogger.logVerbose) { AROLogger.v(TAG, "header item " + headerItemNum + "=" + value_item[headerItemNum]); } if (value_item[headerItemNum].equalsIgnoreCase("PID")) { column_num = headerItemNum; break; } } } else { AROLogger.v(TAG, "rows of processes..."); for (int processRowNum = 0; processRowNum < value_item.length; processRowNum++) { if (value_item[processRowNum].contains(processName)) { pid = Integer.valueOf(value_item[column_num]); // returns 1st match AROLogger.v(TAG, "for process " + processName + " found PID: " + pid); return pid; } } } } } else { // pid is still equal to 0; nothing else to do but log AROLogger.d(TAG, "values.length: " + rows.length + "-PID: " + pid); } } AROLogger.d(TAG, "exiting getProcessID()-returning PID: " + pid); return pid; }
From source file:uk.co.markfrimston.tasktree.TaskTree.java
public void loadConfig() throws Exception { try {//from w ww . j a va 2 s .c om File file = new File(filePath + CONFIG_FILENAME); if (!file.exists()) { saveConfig(); } DocumentBuilder builder = builderFact.newDocumentBuilder(); Document doc = builder.parse(file); Element root = doc.getDocumentElement(); if (root == null || !root.getNodeName().equals("config")) { throw new Exception("Missing root element \"config\""); } Iterator<Element> i = getElementChildren(root); loadUrl = null; saveUrl = null; mergeCommand = null; lastSyncTime = 0L; unsynchedChanges = true; while (i.hasNext()) { Element el = i.next(); if (el.getNodeName().equals("load-url")) { loadUrl = el.getTextContent(); if (loadUrl != null && loadUrl.length() == 0) { loadUrl = null; } } else if (el.getNodeName().equals("save-url")) { saveUrl = el.getTextContent(); if (saveUrl != null && saveUrl.length() == 0) { saveUrl = null; } } else if (el.getNodeName().equals("merge-command")) { mergeCommand = el.getTextContent(); if (mergeCommand != null && mergeCommand.length() == 0) { mergeCommand = null; } } else if (el.getNodeName().equals("last-sync")) { try { lastSyncTime = Long.parseLong(el.getTextContent()); } catch (NumberFormatException e) { } } else if (el.getNodeName().equals("unsynched-changes")) { unsynchedChanges = Boolean.parseBoolean(el.getTextContent()); } } } catch (Exception e) { throw new Exception("Failed to load config file: " + e.getClass().getName() + " - " + e.getMessage()); } }
From source file:net.iponweb.hadoop.streaming.parquet.TextRecordWriterWrapper.java
@Override public void write(Text key, Text value) throws IOException { Group grp = factory.newGroup(); String[] strK = key.toString().split(TAB, -1); String[] strV = value == null ? new String[0] : value.toString().split(TAB, -1); String kv_combined[] = (String[]) ArrayUtils.addAll(strK, strV); Iterator<PathAction> ai = recorder.iterator(); Stack<Group> groupStack = new Stack<>(); groupStack.push(grp);//from w ww . ja v a 2 s. co m int i = 0; try { while (ai.hasNext()) { PathAction a = ai.next(); switch (a.getAction()) { case GROUPEND: grp = groupStack.pop(); break; case GROUPSTART: groupStack.push(grp); grp = grp.addGroup(a.getName()); break; case FIELD: String s = null; PrimitiveType.PrimitiveTypeName primType = a.getType(); String colName = a.getName(); if (i < kv_combined.length) s = kv_combined[i++]; if (s == null) { if (a.getRepetition() == Type.Repetition.OPTIONAL) { i++; continue; } s = primType == PrimitiveType.PrimitiveTypeName.BINARY ? "" : "0"; } // If we have 'repeated' field, assume that we should expect JSON-encoded array // Convert array and append all values int repetition = 1; boolean repeated = false; ArrayList<String> s_vals = null; if (a.getRepetition() == Type.Repetition.REPEATED) { repeated = true; s_vals = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(s); Iterator<JsonNode> itr = node.iterator(); repetition = 0; while (itr.hasNext()) { String o; switch (primType) { case BINARY: o = itr.next().getTextValue(); // No array-of-objects! break; case BOOLEAN: o = String.valueOf(itr.next().getBooleanValue()); break; default: o = String.valueOf(itr.next().getNumberValue()); } s_vals.add(o); repetition++; } } for (int j = 0; j < repetition; j++) { if (repeated) // extract new s s = s_vals.get(j); try { switch (primType) { case INT32: grp.append(colName, new Double(Double.parseDouble(s)).intValue()); break; case INT64: case INT96: grp.append(colName, new Double(Double.parseDouble(s)).longValue()); break; case DOUBLE: grp.append(colName, Double.parseDouble(s)); break; case FLOAT: grp.append(colName, Float.parseFloat(s)); break; case BOOLEAN: grp.append(colName, s.equalsIgnoreCase("true") || s.equals("1")); break; case BINARY: grp.append(colName, Binary.fromString(s)); break; default: throw new RuntimeException("Can't handle type " + primType); } } catch (NumberFormatException e) { grp.append(colName, 0); } } } } realWriter.write(null, (SimpleGroup) grp); } catch (InterruptedException e) { Thread.interrupted(); throw new IOException(e); } catch (Exception e) { ByteArrayOutputStream out = new ByteArrayOutputStream(); e.printStackTrace(new PrintStream(out)); throw new RuntimeException("Failed on record " + grp + ", schema=" + schema + ", path action=" + recorder + " exception = " + e.getClass() + ", msg=" + e.getMessage() + ", cause=" + e.getCause() + ", trace=" + out.toString()); } }