List of usage examples for java.util InputMismatchException InputMismatchException
public InputMismatchException(String s)
From source file:uk.gov.gchq.gaffer.function.MultiFilterFunction.java
@Override public Class<?>[] getInputClasses() { final TreeMap<Integer, Class<?>> inputClassMap = new TreeMap<>(); for (final ConsumerFunctionContext<Integer, FilterFunction> context : getFunctions()) { final Class<?>[] inputClasses = context.getFunction().getInputClasses(); for (int i = 0; i < inputClasses.length; i++) { final Integer index = context.getSelection().get(i); if (inputClassMap.containsKey(index)) { final Class<?> otherClazz = inputClassMap.get(index); if (otherClazz.isAssignableFrom(inputClasses[i])) { inputClassMap.put(index, inputClasses[i]); } else if (!inputClasses[i].isAssignableFrom(otherClazz)) { throw new InputMismatchException( "Input types for function " + getClass().getSimpleName() + " are not compatible"); }/* w w w .j a v a 2 s. co m*/ } else { inputClassMap.put(index, inputClasses[i]); } } } return inputClassMap.values().toArray(new Class<?>[inputClassMap.size()]); }
From source file:org.apache.hama.ml.recommendation.cf.OnlineCF.java
@Override public void setInputPreferences(String path) { LOG.debug("path = " + path); String alreadySetPath = conf.get(OnlineCF.Settings.CONF_INPUT_PATH, null); if (alreadySetPath != null && !alreadySetPath.equals(path)) { throw new InputMismatchException( "different input path given" + ", old: " + alreadySetPath + ", current:" + path); }// ww w . ja v a 2 s. co m conf.set(OnlineCF.Settings.CONF_INPUT_PATH, path); }
From source file:org.apache.hama.ml.recommendation.cf.OnlineCF.java
@Override public void setInputUserFeatures(String path) { LOG.debug("path = " + path); String alreadySetPath = conf.get(OnlineCF.Settings.CONF_INPUT_PATH, null); if (alreadySetPath != null && !alreadySetPath.equals(path)) { throw new InputMismatchException( "different input path given" + ", old: " + alreadySetPath + ", current:" + path); }/*from ww w. j a va 2s .c om*/ conf.set(OnlineCF.Settings.CONF_INPUT_PATH, path); }
From source file:org.apache.hama.ml.recommendation.cf.OnlineCF.java
@Override public void setInputItemFeatures(String path) { LOG.debug("path = " + path); String alreadySetPath = conf.get(OnlineCF.Settings.CONF_INPUT_PATH, null); if (alreadySetPath != null && !alreadySetPath.equals(path)) { throw new InputMismatchException( "different input path given" + ", old: " + alreadySetPath + ", current:" + path); }//from w w w.j av a 2s .co m conf.set(OnlineCF.Settings.CONF_INPUT_PATH, path); }
From source file:etymology.config.CommandLineReader.java
private static boolean getTrueFalseValue(String value) { value = value.toLowerCase();// w ww .j a v a 2 s .c om if (value.equals("true") || value.equals("yes") || value.equals("on") || value.equals("+")) { return true; } if (value.equals("false") || value.equals("no") || value.equals("off") || value.equals("-")) { return false; } throw new InputMismatchException(value); }
From source file:net.maizegenetics.analysis.imputation.FILLINImputationAccuracy.java
/** * Calculates proportion imputed, homozygous proportion right, heterozygous proportion right * @param impGT/* w w w. j a v a 2s . co m*/ * @param keyGT * @return * @deprecated a similar method is need in the core part of accuracy. */ @Deprecated public static double[] compareAlignment(GenotypeTable impGT, GenotypeTable keyGT, String taxaPrefix) { int hetKeys = 0, hetCompared = 0, hetRight = 0; int homoKeys = 0, homoCompared = 0, homoRight = 0; //if(impGT.numberOfTaxa()!=keyGT.numberOfTaxa()) throw new InputMismatchException("Number of Taxa do not match"); if (impGT.numberOfSites() != keyGT.numberOfSites()) throw new InputMismatchException("Number of Sites do not match"); Random r = new Random(); for (int t = 0; t < impGT.numberOfTaxa(); t++) { if (taxaPrefix != null && !impGT.taxaName(t).startsWith(taxaPrefix)) continue; int tCompStart = homoCompared; int tHomoRightStart = homoRight; int key_t = keyGT.taxa().indexOf(impGT.taxaName(t)); if (key_t < 0) continue; //key_t=r.nextInt(impGT.numberOfTaxa()); //System.out.print(impGT.taxaName(t)+"\t"+keyGT.taxaName(t)); boolean report = impGT.taxaName(t).startsWith("XZ009E0126"); for (int s = 0; s < impGT.numberOfSites(); s++) { byte keyB = keyGT.genotype(key_t, s); if (keyB == UNKNOWN_DIPLOID_ALLELE) continue; byte impB = impGT.genotype(t, s); if (isHeterozygous(keyB)) { hetKeys++; if (impB != UNKNOWN_DIPLOID_ALLELE) { hetCompared++; if (keyB == impB) hetRight++; } } else { homoKeys++; if (impB != UNKNOWN_DIPLOID_ALLELE) { homoCompared++; if (keyB == impB) homoRight++; if (report) { if (keyB != impB) { System.out.print("Wrong\t"); } else { System.out.print("Right\t"); } System.out.printf("%s %d %s %s %n", impGT.chromosome(s).getName(), impGT.chromosomalPosition(s), NucleotideAlignmentConstants.getNucleotideIUPAC(keyB), NucleotideAlignmentConstants.getNucleotideIUPAC(impB)); } // if(keyB!=impB) System.out.printf("Wrong: %s %s %n", // NucleotideAlignmentConstants.getNucleotideIUPAC(keyB), // NucleotideAlignmentConstants.getNucleotideIUPAC(impB)); } } } //System.out.println("\t"+(homoCompared-tCompStart)+"\t"+(homoRight-tHomoRightStart)); } double totalKey = hetKeys + homoKeys; double propImp = (double) (hetCompared + homoCompared) / totalKey; double homoRightProp = (double) homoRight / (double) homoCompared; double hetRightProp = (double) hetRight / (double) hetCompared; return new double[] { propImp, homoRightProp, hetRightProp }; }
From source file:enumj.Enumerator.java
/** * Returns the one and only element of the current enumerator. * * @return the single element.// ww w . j a v a 2 s. co m * @exception InputMismatchException the current enumerator has * <code>0</code> or more than <code>1</code> elements. */ public default E single() { if (!hasNext()) { throw new InputMismatchException(Messages.NO_SINGLE_ENUMERATOR_ELEMENT); } final E result = next(); if (hasNext()) { throw new InputMismatchException(Messages.NO_SINGLE_ENUMERATOR_ELEMENT); } return result; }