List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:org.sakaiproject.importer.impl.handlers.SamigoAssessmentHandler.java
private Collection doQuestions(List questions, String siteId) { AssessmentQuestion importableQuestion; AssessmentAnswer importableAnswer;/*from www . ja v a 2s . c o m*/ AssessmentAnswer importableChoice; Collection rv = new Vector(); ItemFacade itemFacade = null; String questionTextString = null; ItemText text = null; HashSet textSet = null; Answer answer = null; HashSet answerSet = null; AnswerFeedback answerFeedback = null; HashSet answerFeedbackSet = null; int questionCount = 0; for (Iterator i = questions.iterator(); i.hasNext();) { importableQuestion = (AssessmentQuestion) i.next(); questionCount++; Set correctAnswerIDs = importableQuestion.getCorrectAnswerIDs(); itemFacade = new ItemFacade(); itemFacade.setTypeId(new Long(importableQuestion.getQuestionType())); textSet = new HashSet(); questionTextString = contextualizeUrls(importableQuestion.getQuestionText(), siteId); if (importableQuestion.getQuestionType() == SamigoPoolHandler.MATCHING) { itemFacade.setInstruction(questionTextString); Collection answers = importableQuestion.getAnswers().values(); Collection choices = importableQuestion.getChoices().values(); int answerIndex = 1; for (Iterator j = answers.iterator(); j.hasNext();) { importableAnswer = (AssessmentAnswer) j.next(); text = new ItemText(); text.setSequence(Long.valueOf(answerIndex)); answerIndex++; text.setText(contextualizeUrls(importableAnswer.getAnswerText(), siteId)); answerSet = new HashSet(); int choiceIndex = 1; for (Iterator k = choices.iterator(); k.hasNext();) { importableChoice = (AssessmentAnswer) k.next(); answer = new Answer(); answer.setItem(itemFacade.getData()); answer.setItemText(text); answer.setSequence(new Long(choiceIndex)); choiceIndex++; // set label A, B, C, D, etc. on answer based on its sequence number answer.setLabel(new Character((char) (64 + choiceIndex)).toString()); answer.setText(contextualizeUrls(importableChoice.getAnswerText(), siteId)); answer.setIsCorrect(Boolean .valueOf(importableAnswer.getChoiceId().equals(importableChoice.getAnswerId()))); answerSet.add(answer); } text.setAnswerSet(answerSet); text.setItem(itemFacade.getData()); textSet.add(text); } } else { text = new ItemText(); text.setSequence(Long.valueOf(1)); text.setText(questionTextString); answerSet = new HashSet(); answerFeedbackSet = new HashSet(); Collection answers = importableQuestion.getAnswers().values(); StringBuilder answerBuffer = new StringBuilder(); for (Iterator j = answers.iterator(); j.hasNext();) { importableAnswer = (AssessmentAnswer) j.next(); answerBuffer.append(importableAnswer.getAnswerText()); if (j.hasNext()) answerBuffer.append("|"); String answerId = importableAnswer.getAnswerId(); answer = new Answer(); answer.setItem(itemFacade.getData()); answer.setItemText(text); answer.setSequence(new Long(importableAnswer.getPosition())); // set label A, B, C, D, etc. on answer based on its sequence number answer.setLabel(new Character((char) (64 + importableAnswer.getPosition())).toString()); if (importableQuestion.getQuestionType() == SamigoPoolHandler.TRUE_FALSE) { // Samigo only understands True/False answers in lower case answer.setText(importableAnswer.getAnswerText().toLowerCase()); } else if (importableQuestion.getQuestionType() == SamigoPoolHandler.FILL_BLANK_PLUS) { answer.setText(importableAnswer.getAnswerText()); Pattern pattern = Pattern.compile("_+|<<.*>>"); Matcher matcher = pattern.matcher(questionTextString); if (matcher.find()) questionTextString = questionTextString.replaceFirst(matcher.group(), "{}"); text.setText(questionTextString); itemFacade.setTypeId(Long.valueOf(SamigoPoolHandler.FILL_BLANK)); } else if (importableQuestion.getQuestionType() == SamigoPoolHandler.FILL_BLANK) { if (j.hasNext()) continue; answer.setText(answerBuffer.toString()); Pattern pattern = Pattern.compile("_+|<<.*>>"); Matcher matcher = pattern.matcher(questionTextString); if (matcher.find()) questionTextString = questionTextString.replaceFirst(matcher.group(), "{}"); text.setText(questionTextString); answer.setSequence(new Long(1)); } else { answer.setText(contextualizeUrls(importableAnswer.getAnswerText(), siteId)); } answer.setIsCorrect(new Boolean(correctAnswerIDs.contains(answerId))); answerSet.add(answer); } text.setAnswerSet(answerSet); text.setItem(itemFacade.getData()); textSet.add(text); } itemFacade.setItemTextSet(textSet); itemFacade.setCorrectItemFeedback(importableQuestion.getFeedbackWhenCorrect()); itemFacade.setInCorrectItemFeedback(importableQuestion.getFeedbackWhenIncorrect()); itemFacade.setTypeId(Long.valueOf(importableQuestion.getQuestionType())); itemFacade.setScore(importableQuestion.getPointValue()); itemFacade.setSequence(importableQuestion.getPosition()); // status is 0=inactive or 1=active itemFacade.setStatus(Integer.valueOf(1)); itemFacade.setHasRationale(Boolean.FALSE); itemFacade.setCreatedBy(SessionManager.getCurrentSessionUserId()); itemFacade.setCreatedDate(new java.util.Date()); itemFacade.setLastModifiedBy(SessionManager.getCurrentSessionUserId()); itemFacade.setLastModifiedDate(new java.util.Date()); // itemService.saveItem(itemFacade); rv.add(itemFacade); } return rv; }
From source file:kr.re.dev.LikeAA.LikeAA.java
@SuppressLint("UseValueOf") private Object[] makeEmptyArgs(Class<?>[] params) { Object[] args = new Object[params.length]; for (int i = 0, n = params.length; i < n; ++i) { if (params[i].isAssignableFrom(byte.class)) args[i] = new Byte((byte) 0); else if (params[i].isAssignableFrom(boolean.class)) args[i] = new Boolean(false); else if (params[i].isAssignableFrom(char.class)) args[i] = new Character((char) 0); else if (params[i].isAssignableFrom(int.class)) args[i] = new Integer(0); else if (params[i].isAssignableFrom(float.class)) args[i] = new Float(0.0f); else if (params[i].isAssignableFrom(long.class)) args[i] = new Long(0); else if (params[i].isAssignableFrom(double.class)) args[i] = new Double(0); else/*from w w w .j a va 2s . c o m*/ args[i] = null; } return args; }
From source file:org.apache.marmotta.commons.sesame.facading.util.FacadeUtils.java
/** * Transform a value passed as string to the base type (i.e. non-complex type) given as argument * * @param <T>// w w w . ja v a 2 s . c o m * @param value * @param returnType * @return * @throws IllegalArgumentException */ @SuppressWarnings("unchecked") public static <T> T transformToBaseType(String value, Class<T> returnType) throws IllegalArgumentException { // transformation to appropriate primitive type /* * README: the "dirty" cast: "(T) x" instead of "returnType.cast(x)" is required since * .cast does not work for primitive types (int, double, float, etc...). * Somehow it results in a ClassCastException */ if (Integer.class.equals(returnType) || int.class.equals(returnType)) { if (value == null) { return (T) (Integer) (0); } return (T) (Integer.decode(value)); } else if (Long.class.equals(returnType) || long.class.equals(returnType)) { if (value == null) { return (T) (Long) (0L); } return (T) (Long.decode(value)); } else if (Double.class.equals(returnType) || double.class.equals(returnType)) { if (value == null) { return (T) (Double) (0.0); } return (T) (Double.valueOf(value)); } else if (Float.class.equals(returnType) || float.class.equals(returnType)) { if (value == null) { return (T) (Float) (0.0F); } return (T) (Float.valueOf(value)); } else if (Byte.class.equals(returnType) || byte.class.equals(returnType)) { if (value == null) { return (T) (Byte) ((byte) 0); } return (T) (Byte.decode(value)); } else if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) { return (T) (Boolean.valueOf(value)); } else if (Character.class.equals(returnType) || char.class.equals(returnType)) { if (value == null) { if (Character.class.equals(returnType)) { return null; } else { return (T) new Character((char) 0); } } else if (value.length() > 0) { return (T) (Character) (value.charAt(0)); } else { return null; } } else if (Locale.class.equals(returnType)) { if (value == null) { return null; } else { return returnType.cast(LocaleUtils.toLocale(value)); } } else if (Date.class.equals(returnType)) { if (value == null) { return null; } else { try { return returnType.cast(ISODateTimeFormat.dateTimeParser().parseDateTime(value).toDate()); } catch (final IllegalArgumentException e) { e.printStackTrace(); return null; } } } else if (DateTime.class.equals(returnType)) { if (value == null) { return null; } else { try { return returnType.cast(ISODateTimeFormat.dateTimeParser().parseDateTime(value)); } catch (final IllegalArgumentException e) { e.printStackTrace(); return null; } } } else if (String.class.equals(returnType)) { return returnType.cast(value); } else { throw new IllegalArgumentException( "primitive type " + returnType.getName() + " not supported by transformation"); } }
From source file:com.github.xbn.array.helper.NewPrimitiveArrayHelper.java
public Character getWrapper(Object obj_thatIsPrimArr, int index, String array_name) { try {//w ww . ja v a 2s. c o m return (new Character(getPrimitiveArray(obj_thatIsPrimArr, NullContainer.BAD, array_name)[index])); } catch (RuntimeException rx) { ciObjNullUnexpectedTypeOrBadIndex(obj_thatIsPrimArr, index, array_name); throw rx; } }
From source file:com.diversityarrays.dal.server.ServerGui.java
public ServerGui(Image serverIconImage, IDalServer svr, DalServerFactory factory, File wwwRoot, DalServerPreferences prefs) {//from www.j a v a 2 s . c o m this.serverIconImage = serverIconImage; this.dalServerFactory = factory; this.wwwRoot = wwwRoot; this.preferences = prefs; JMenuBar menuBar = new JMenuBar(); JMenu serverMenu = new JMenu("Server"); menuBar.add(serverMenu); serverMenu.add(serverStartAction); serverMenu.add(serverStopAction); serverMenu.add(exitAction); JMenu commandMenu = new JMenu("Command"); menuBar.add(commandMenu); commandMenu.add(doSql); JMenu urlMenu = new JMenu("URL"); menuBar.add(urlMenu); urlMenu.add(new JMenuItem(copyDalUrlAction)); urlMenu.add(new JMenuItem(showDalUrlQRcodeAction)); setJMenuBar(menuBar); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); messages.setFont(GuiUtil.createMonospacedFont(12)); messages.setEditable(false); setServer(svr); quietOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean q = quietOption.isSelected(); if (server != null) { server.setQuiet(q); } } }); JScrollPane scrollPane = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JButton clear = new JButton(new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { messages.setText(""); } }); final boolean[] follow = new boolean[] { true }; final JCheckBox followTail = new JCheckBox("Follow", follow[0]); followTail.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { follow[0] = followTail.isSelected(); } }); final OutputStream os = new OutputStream() { @Override public void write(int b) throws IOException { char ch = (char) b; messages.append(new Character(ch).toString()); if (ch == '\n' && follow[0]) { verticalScrollBar.setValue(verticalScrollBar.getMaximum()); } } }; TeePrintStream pso = new TeePrintStream(System.out, os); TeePrintStream pse = new TeePrintStream(System.err, os); System.setErr(pse); System.setOut(pso); Box box = Box.createHorizontalBox(); box.add(clear); box.add(followTail); box.add(quietOption); box.add(Box.createHorizontalGlue()); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(BorderLayout.NORTH, box); bottom.add(BorderLayout.SOUTH, statusInfoLine); Container cp = getContentPane(); cp.add(BorderLayout.CENTER, scrollPane); cp.add(BorderLayout.SOUTH, bottom); pack(); setSize(640, 480); final MemoryUsageMonitor mum = new MemoryUsageMonitor(); mum.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { statusInfoLine.setMessage(mum.getMemoryUsage()); } }); if (server == null) { // If initial server is null, allow user to specify addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); serverStartAction.actionPerformed(null); } }); } else { addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); ensureDatabaseInitialisedThenStartServer(); } }); } }
From source file:us.mn.state.health.lims.testanalyte.form.TestAnalyteTestResultActionForm.java
/** * <p>//from ww w . j a va2 s. c o m * Return the value of a simple property with the specified name. * </p> * * @param name * Name of the property whose value is to be retrieved * * @exception IllegalArgumentException * if there is no property of the specified name * @exception NullPointerException * if the type specified for the property is invalid */ public Object get(String name) { // Return any non-null value for the specified property Object value = dynaValues.get(name); //System.out.println("I am in get(String name) " + name + " " + value); if (value != null) { return (value); } // Return a null value for a non-primitive property Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("The type for property " + name + " is invalid"); } if (!type.isPrimitive()) { return (value); } // Manufacture default values for primitive properties if (type == Boolean.TYPE) { return (Boolean.FALSE); } else if (type == Byte.TYPE) { return (new Byte((byte) 0)); } else if (type == Character.TYPE) { return (new Character((char) 0)); } else if (type == Double.TYPE) { return (new Double(0.0)); } else if (type == Float.TYPE) { return (new Float((float) 0.0)); } else if (type == Integer.TYPE) { return (new Integer(0)); } else if (type == Long.TYPE) { return (new Long(0)); } else if (type == Short.TYPE) { return (new Short((short) 0)); } else { return (null); } }
From source file:io.nuun.plugin.configuration.common.ConfigurationMembersInjector.java
@Override public void injectMembers(T instance) { NuunProperty injectConfigAnnotation = null; // The annotation is actual NuunProperty.class if (clonedAnno.annotationType() == NuunProperty.class) { injectConfigAnnotation = field.getAnnotation(NuunProperty.class); } else { // The annotation has the NuunProperty annotation on it we proxy it injectConfigAnnotation = AssertUtils.annotationProxyOf(NuunProperty.class, clonedAnno); }/*from w w w . j a v a 2s . c om*/ String configurationParameterName = injectConfigAnnotation.value(); // Pre verification // if (StringUtils.isEmpty(configurationParameterName)) { log.error("Value for annotation {} on field {} can not be null or empty.", clonedAnno.annotationType(), field.toGenericString()); throw new PluginException("Value for annotation %s on field %s can not be null or empty.", clonedAnno.annotationType(), field.toGenericString()); } if (!configuration.containsKey(configurationParameterName) && injectConfigAnnotation.mandatory()) { throw new PluginException("\"%s\" must be in one properties file for field %s.", configurationParameterName, field.toGenericString()); } try { this.field.setAccessible(true); Class<?> type = field.getType(); if (type == Integer.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setInt(instance, configuration.getInt(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setInt(instance, injectConfigAnnotation.defaultIntValue()); } } else if (type == Integer.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Integer(configuration.getInt(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Integer(injectConfigAnnotation.defaultIntValue())); } } else if (type == Boolean.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setBoolean(instance, configuration.getBoolean(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setBoolean(instance, injectConfigAnnotation.defaultBooleanValue()); } } else if (type == Boolean.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Boolean(configuration.getBoolean(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Boolean(injectConfigAnnotation.defaultBooleanValue())); } } else if (type == Short.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setShort(instance, configuration.getShort(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setShort(instance, injectConfigAnnotation.defaultShortValue()); } } else if (type == Short.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Short(configuration.getShort(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Short(injectConfigAnnotation.defaultShortValue())); } } else if (type == Byte.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setByte(instance, configuration.getByte(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setByte(instance, injectConfigAnnotation.defaultByteValue()); } } else if (type == Byte.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Byte(configuration.getByte(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Byte(injectConfigAnnotation.defaultByteValue())); } } else if (type == Long.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setLong(instance, configuration.getLong(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setLong(instance, injectConfigAnnotation.defaultLongValue()); } } else if (type == Long.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Long(configuration.getLong(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Long(injectConfigAnnotation.defaultLongValue())); } } else if (type == Float.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setFloat(instance, configuration.getFloat(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setFloat(instance, injectConfigAnnotation.defaultFloatValue()); } } else if (type == Float.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Float(configuration.getFloat(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Float(injectConfigAnnotation.defaultFloatValue())); } } else if (type == Double.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setDouble(instance, configuration.getDouble(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setDouble(instance, injectConfigAnnotation.defaultDoubleValue()); } } else if (type == Double.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Double(configuration.getDouble(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Double(injectConfigAnnotation.defaultDoubleValue())); } } else if (type == Character.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setChar(instance, configuration.getString(configurationParameterName).charAt(0)); } } else if (type == Character.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Character(configuration.getString(configurationParameterName).charAt(0))); } } else { Object property = getProperty(configurationParameterName, injectConfigAnnotation); field.set(instance, property); } } catch (IllegalArgumentException ex) { log.error("Wrong argument or argument type during configuration injection", ex); } catch (IllegalAccessException ex) { log.error("Illegal access during configuration injection", ex); } catch (InstantiationException ex) { log.error("Impossible to instantiate value converter", ex); } finally { this.field.setAccessible(false); } }
From source file:org.openamf.io.AMFSerializer.java
protected Object[] convertPrimitiveArrayToObjectArray(Object array) throws IOException { Class componentType = array.getClass().getComponentType(); Object[] result = null;// ww w.java 2 s .co m if (componentType == null) { throw new NullPointerException("componentType is null"); } else if (componentType == Character.TYPE) { char[] carray = (char[]) array; result = new Object[carray.length]; for (int i = 0; i < carray.length; i++) { result[i] = new Character(carray[i]); } } else if (componentType == Byte.TYPE) { byte[] barray = (byte[]) array; result = new Object[barray.length]; for (int i = 0; i < barray.length; i++) { result[i] = new Byte(barray[i]); } } else if (componentType == Short.TYPE) { short[] sarray = (short[]) array; result = new Object[sarray.length]; for (int i = 0; i < sarray.length; i++) { result[i] = new Short(sarray[i]); } } else if (componentType == Integer.TYPE) { int[] iarray = (int[]) array; result = new Object[iarray.length]; for (int i = 0; i < iarray.length; i++) { result[i] = new Integer(iarray[i]); } } else if (componentType == Long.TYPE) { long[] larray = (long[]) array; result = new Object[larray.length]; for (int i = 0; i < larray.length; i++) { result[i] = new Long(larray[i]); } } else if (componentType == Double.TYPE) { double[] darray = (double[]) array; result = new Object[darray.length]; for (int i = 0; i < darray.length; i++) { result[i] = new Double(darray[i]); } } else if (componentType == Float.TYPE) { float[] farray = (float[]) array; result = new Object[farray.length]; for (int i = 0; i < farray.length; i++) { result[i] = new Float(farray[i]); } } else if (componentType == Boolean.TYPE) { boolean[] barray = (boolean[]) array; result = new Object[barray.length]; for (int i = 0; i < barray.length; i++) { result[i] = new Boolean(barray[i]); } } else { throw new IllegalArgumentException("unexpected component type: " + componentType.getClass().getName()); } return result; }
From source file:org.warlock.spine.connection.Transmitter.java
private String readLine(InputStream is) throws IOException { StringBuilder sb = new StringBuilder(); int i = 0;/* w ww.ja v a2 s .c o m*/ do { i = is.read(); if (i == -1) { break; } if (i == 0xa) // \n { break; } if (i != 0xd) { // \r sb.append(new Character((char) i)); } } while (true); return sb.toString(); }
From source file:mitm.common.tools.SMIME.java
/** * @param args//from w w w . j a va 2 s . co m * @throws CryptoMessageSyntaxException */ public static void main(String[] args) { try { PropertyConfigurator.configure("conf/tools.log4j.properties"); InitializeBouncycastle.initialize(); securityFactory = SecurityFactoryFactory.getSecurityFactory(); CommandLineParser parser = new BasicParser(); Options options = createCommandLineOptions(); HelpFormatter formatter = new HelpFormatter(); CommandLine commandLine; try { commandLine = parser.parse(options, args); } catch (ParseException e) { formatter.printHelp("SMIME", options, true); throw e; } String inFile = commandLine.getOptionValue("in"); String keyFile = commandLine.getOptionValue("p12"); String password = commandLine.getOptionValue("password"); boolean binary = commandLine.hasOption("binary"); String p7mOut = commandLine.getOptionValue("p7mOut"); String cerOut = commandLine.getOptionValue("cerOut"); String alias = commandLine.getOptionValue("alias"); String digest = commandLine.getOptionValue("digest"); String outFile = commandLine.getOptionValue("out"); if (commandLine.hasOption("help") || args == null || args.length == 0) { formatter.printHelp("SMIME", options, true); return; } if (commandLine.hasOption("pwd")) { System.err.println("Please enter your password: "); /* * We will redirect the output to err so we do not get any * chars on the output. */ ConsoleReader consoleReader = new ConsoleReader(new FileInputStream(FileDescriptor.in), new PrintWriter(System.err)); password = consoleReader.readLine(new Character('*')); } KeyStore keyStore = null; if (keyFile != null) { keyStore = loadKeyStore(keyFile, password); } if (commandLine.hasOption("printAliases")) { if (keyStore == null) { throw new MissingArgumentException("p12 file is missing."); } printKeystoreAliases(keyStore); } MimeMessage message; if (commandLine.hasOption("r")) { if (commandLine.hasOption("p7m")) { message = loadp7m(inFile, binary); if (commandLine.hasOption("p7mOut")) { MailUtils.writeMessage(message, new File(p7mOut)); } } else { message = loadMessage(inFile); } KeyStoreKeyProvider basicKeyStore = null; if (keyStore != null) { basicKeyStore = new KeyStoreKeyProvider(keyStore, "test"); basicKeyStore.setUseOL2010Workaround(true); } if (message == null) { throw new MissingArgumentException("in file is not specified"); } inspectMessage(message, basicKeyStore, cerOut); } else if (commandLine.hasOption("sign")) { message = loadMessage(inFile); if (message == null) { throw new MissingArgumentException("in file is not specified"); } if (StringUtils.isEmpty(outFile)) { throw new MissingArgumentException("out file is not specified"); } sign(message, keyStore, alias, password, digest, outFile); } } catch (MissingArgumentException e) { System.err.println("Not all required parameters are specified. " + e); } catch (ParseException e) { System.err.println("Command line parsing error. " + e); } catch (Exception e) { logger.error("Some error ocurred", e); } }