Java 类java.lang.IllegalArgumentException 实例源码

项目:LightSIP    文件:SIPDate.java   
/**
 * Set the wkday member
 * @param w String to set
 * @throws IllegalArgumentException if w is not a valid day.
 */
public void setWkday(String w) throws IllegalArgumentException {
    sipWkDay = w;
    if (sipWkDay.compareToIgnoreCase(MON) == 0) {
        wkday = Calendar.MONDAY;
    } else if (sipWkDay.compareToIgnoreCase(TUE) == 0) {
        wkday = Calendar.TUESDAY;
    } else if (sipWkDay.compareToIgnoreCase(WED) == 0) {
        wkday = Calendar.WEDNESDAY;
    } else if (sipWkDay.compareToIgnoreCase(THU) == 0) {
        wkday = Calendar.THURSDAY;
    } else if (sipWkDay.compareToIgnoreCase(FRI) == 0) {
        wkday = Calendar.FRIDAY;
    } else if (sipWkDay.compareToIgnoreCase(SAT) == 0) {
        wkday = Calendar.SATURDAY;
    } else if (sipWkDay.compareToIgnoreCase(SUN) == 0) {
        wkday = Calendar.SUNDAY;
    } else {
        throw new IllegalArgumentException("Illegal Week day :" + w);
    }
}
项目:incubator-netbeans    文件:ZOrderManager.java   
/** Stops to track given window (RootPaneContainer).
 */
public boolean detachWindow (RootPaneContainer rpc) {
    logger.entering(getClass().getName(), "detachWindow");

    if (!(rpc instanceof Window)) {
        throw new IllegalArgumentException("Argument must be subclas of java.awt.Window: " + rpc);   //NOI18N
    }

    WeakReference<RootPaneContainer> ww = getWeak(rpc);
    if (ww == null) {
        return false;
    }

    ((Window)rpc).removeWindowListener(this);
    return zOrder.remove(ww);
}
项目:LightSIP    文件:SIPDate.java   
/**
 * Set the month member
 * @param m String to set.
 * @throws IllegalArgumentException if m is not a valid month
 */
public void setMonth(String m) throws IllegalArgumentException {
    sipMonth = m;
    if (sipMonth.compareToIgnoreCase(JAN) == 0) {
        month = Calendar.JANUARY;
    } else if (sipMonth.compareToIgnoreCase(FEB) == 0) {
        month = Calendar.FEBRUARY;
    } else if (sipMonth.compareToIgnoreCase(MAR) == 0) {
        month = Calendar.MARCH;
    } else if (sipMonth.compareToIgnoreCase(APR) == 0) {
        month = Calendar.APRIL;
    } else if (sipMonth.compareToIgnoreCase(MAY) == 0) {
        month = Calendar.MAY;
    } else if (sipMonth.compareToIgnoreCase(JUN) == 0) {
        month = Calendar.JUNE;
    } else if (sipMonth.compareToIgnoreCase(JUL) == 0) {
        month = Calendar.JULY;
    } else if (sipMonth.compareToIgnoreCase(AUG) == 0) {
        month = Calendar.AUGUST;
    } else if (sipMonth.compareToIgnoreCase(SEP) == 0) {
        month = Calendar.SEPTEMBER;
    } else if (sipMonth.compareToIgnoreCase(OCT) == 0) {
        month = Calendar.OCTOBER;
    } else if (sipMonth.compareToIgnoreCase(NOV) == 0) {
        month = Calendar.NOVEMBER;
    } else if (sipMonth.compareToIgnoreCase(DEC) == 0) {
        month = Calendar.DECEMBER;
    } else {
        throw new IllegalArgumentException("Illegal Month :" + m);
    }
}
项目:WeatherStream    文件:Weather_Table.java   
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`wId`":  {
      return wId;
    }
    case "`id`":  {
      return id;
    }
    case "`icon`":  {
      return icon;
    }
    case "`description`":  {
      return description;
    }
    case "`main`":  {
      return main;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
项目:WeatherStream    文件:WeatherForecastData_Table.java   
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`message`":  {
      return message;
    }
    case "`cnt`":  {
      return cnt;
    }
    case "`cod`":  {
      return cod;
    }
    case "`dt`":  {
      return dt;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
项目:WeatherStream    文件:Rain_Table.java   
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`dt`":  {
      return dt;
    }
    case "`rainCount`":  {
      return rainCount;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
项目:WeatherStream    文件:ForecastList_Table.java   
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`dt`":  {
      return dt;
    }
    case "`dt_txt`":  {
      return dt_txt;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
项目:WeatherStream    文件:Wind_Table.java   
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`speed`":  {
      return speed;
    }
    case "`deg`":  {
      return deg;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
项目:WeatherStream    文件:Coord_Table.java   
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`lon`":  {
      return lon;
    }
    case "`lat`":  {
      return lat;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
项目:essence    文件:ValueOutOfBoundDetector.java   
private boolean checkDateTimeCondition(String op, String targetVal, String value) {
    ValueOperatorType opt = ValueOperatorType.textToValue(op);
    try {
        Date td = DatatypeConverter.parseDateTime(targetVal).getTime();
        Date vd = DatatypeConverter.parseDateTime(value).getTime();
        int result = vd.compareTo(td);

        if (opt == ValueOperatorType.EQUAL_TO)
            return result == 0;
        else if (opt == ValueOperatorType.NOT_EQUAL_TO)
            return result != 0;
        else if (opt == ValueOperatorType.GREATER_THAN)
            return result > 0;
        else if (opt == ValueOperatorType.GREATER_THAN_EQUAL_TO)
            return result >= 0;
        else if (opt == ValueOperatorType.LESS_THAN)
            return result < 0;
        else if (opt == ValueOperatorType.LESS_THEN_EQUAL_TO)
            return result <= 0;         
    } catch (IllegalArgumentException ex) {
        log.warn("illegal datetime format target=" + targetVal+" value="+value);
        return false;
    }

    return false;
}
项目:cordova-plugin-quintech-background-geolocation    文件:LocationProviderFactory.java   
public LocationProvider getInstance (Integer locationProvider) {
    LocationProvider provider;
    switch (locationProvider) {
        case Config.ANDROID_DISTANCE_FILTER_PROVIDER:
            provider = new DistanceFilterLocationProvider(context);
            break;
        case Config.ANDROID_ACTIVITY_PROVIDER:
            provider = new ActivityRecognitionLocationProvider(context);
            break;
        default:
            throw new IllegalArgumentException("Provider not found");
    }

    provider.onCreate();
    return provider;
}
项目:armadacraft    文件:WorldGenerator.java   
public static WorldGenerator getByName(String name) {
    WorldGenerator gen = generators.getOrDefault(name, null);

    if (gen == null) {
        try {
            throw new IllegalArgumentException("\"" + name + "\" is not a valid WorldGenerator");
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            ArmadaCraft.getInstance().shutdown();
        }
    } else {
        return gen;
    }

    return null;
}
项目:vtd-xml    文件:FastIntBuffer.java   
/**
 * Sort the integers in the buffer 
 * @param order (as of version 2.9) 
 * it can be either ASCENDING or DESCENDING
 */
public void sort(int order) {
    switch (order) {
    case ASCENDING:
        if (size > 0)
            quickSort_ascending(0, size - 1);
        break;
    case DESCENDING:
        if (size > 0)
            quickSort_descending(0, size - 1);
        break;
    default:
        throw new IllegalArgumentException("Sort type undefined");
    }

}
项目:opengse    文件:GetDateHeaderLCaseTestServlet.java   
public void service ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException, IllegalArgumentException {
    PrintWriter out = response.getWriter();

    long expectedResult = 946684801000L;
    String param = "If-Modified-Since";

    try {
        long result = request.getDateHeader( param );

        if ( result == expectedResult ) {
            out.println( "GetDateHeaderLCaseTest test PASSED" );
        } else {
            out.println( "GetDateHeaderLCaseTest test FAILED <BR>" );
            out.println( "     HttpServletRequest.getDateHeader(" + param + ") returned an incorrect result<BR>" );
            out.println( "     Expected result = " + expectedResult + " <BR>" );
            out.println( "     Actual result = |" + result + "| <BR>" );
        }
    } catch ( java.lang.IllegalArgumentException ex ) {
        out.println( "GetDateHeaderLCaseTest test FAILED <BR>" );
        out.println( "     HttpServletRequest.getDateHeader(" + param + ") Can't convert the sent header value to Date <BR>" );
        out.println( "     HttpServletRequest.getDateHeader(" + param + ") threw IllegalArgumentException exception<BR>" );
        throw ex;
    }
}
项目:opengse    文件:GetDateHeaderTestServlet.java   
public void service ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException, IllegalArgumentException {
    PrintWriter out = response.getWriter();

    long expectedResult = 946684801000L;
    String param = "If-Modified-Since";

    try {
        long result = request.getDateHeader( param );

        if ( result == expectedResult ) {
            out.println( "GetDateHeaderTest test PASSED" );
        } else {
            out.println( "GetDateHeaderTest test FAILED <BR>" );
            out.println( "     HttpServletRequest.getDateHeader(" + param + ") returned an incorrect result<BR>" );
            out.println( "     Expected result = " + expectedResult + " <BR>" );
            out.println( "     Actual result = |" + result + "| <BR>" );
        }
    } catch ( java.lang.IllegalArgumentException ex ) {
        out.println( "GetDateHeaderTest test FAILED <BR>" );
        out.println( "     HttpServletRequest.getDateHeader(" + param + ") Can't convert the sent header value to Date <BR>" );
        out.println( "     HttpServletRequest.getDateHeader(" + param + ") threw IllegalArgumentException exception<BR>" );
        throw ex;
    }
}
项目:opengse    文件:GetDateHeaderMxCaseTestServlet.java   
public void service ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException, IllegalArgumentException {
    PrintWriter out = response.getWriter();

    long expectedResult = 946684801000L;
    String param = "If-Modified-Since";

    try {
        long result = request.getDateHeader( param );

        if ( result == expectedResult ) {
            out.println( "GetDateHeaderMxCaseTest test PASSED" );
        } else {
            out.println( "GetDateHeaderMxCaseTest test FAILED <BR>" );
            out.println( "     HttpServletRequest.getDateHeader(" + param + ") returned an incorrect result<BR>" );
            out.println( "     Expected result = " + expectedResult + " <BR>" );
            out.println( "     Actual result = |" + result + "| <BR>" );
        }
    } catch ( java.lang.IllegalArgumentException ex ) {
        out.println( "GetDateHeaderMxCaseTest test FAILED <BR>" );
        out.println( "     HttpServletRequest.getDateHeader(" + param + ") Can't convert the sent header value to Date <BR>" );
        out.println( "     HttpServletRequest.getDateHeader(" + param + ") threw IllegalArgumentException exception<BR>" );
        throw ex;
    }
}
项目:aidl2    文件:MoreSuppressingWarnings$$AidlClientImpl.java   
@Override
@SuppressWarnings({
    "wuhahahaha",
    "chirpkippy"
})
public void aMethod() throws IllegalArgumentException, RemoteException {
  Parcel data = Parcel.obtain();
  Parcel reply = Parcel.obtain();
  try {
    data.writeInterfaceToken(MoreSuppressingWarnings$$AidlServerImpl.DESCRIPTOR);

    delegate.transact(MoreSuppressingWarnings$$AidlServerImpl.TRANSACT_aMethod, data, reply, 0);
    reply.readException();
  } finally {
    data.recycle();
    reply.recycle();
  }
}
项目:aidl2    文件:ExtendingInterface$$AidlClientImpl.java   
@Override
public Date call() throws RemoteException, IllegalArgumentException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(ExtendingInterface$$AidlServerImpl.DESCRIPTOR);

        delegate.transact(ExtendingInterface$$AidlServerImpl.TRANSACT_call, data, reply, 0);
        reply.readException();

        return AidlUtil.readFromObjectStream(reply);
    } finally {
        data.recycle();
        reply.recycle();
    }
}
项目:fsharpadvent2016    文件:LispReader.java   
static private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {
    int uc = Character.digit(initch, base);
    if(uc == -1)
        throw new IllegalArgumentException("Invalid digit: " + (char) initch);
    int i = 1;
    for(; i < length; ++i)
        {
        int ch = read1(r);
        if(ch == -1 || isWhitespace(ch) || isMacro(ch))
            {
            unread(r, ch);
            break;
            }
        int d = Character.digit(ch, base);
        if(d == -1)
            throw new IllegalArgumentException("Invalid digit: " + (char) ch);
        uc = uc * base + d;
        }
    if(i != length && exact)
        throw new IllegalArgumentException("Invalid character length: " + i + ", should be: " + length);
    return uc;
}
项目:eclojure    文件:LispReader.java   
static private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {
    int uc = Character.digit(initch, base);
    if(uc == -1)
        throw new IllegalArgumentException("Invalid digit: " + (char) initch);
    int i = 1;
    for(; i < length; ++i)
        {
        int ch = read1(r);
        if(ch == -1 || isWhitespace(ch) || isMacro(ch))
            {
            unread(r, ch);
            break;
            }
        int d = Character.digit(ch, base);
        if(d == -1)
            throw new IllegalArgumentException("Invalid digit: " + (char) ch);
        uc = uc * base + d;
        }
    if(i != length && exact)
        throw new IllegalArgumentException("Invalid character length: " + i + ", should be: " + length);
    return uc;
}
项目:ca-iris    文件:URIUtils.java   
/**
 * Check that the scheme of a given URI matches the given String.
 * @param uri a String representation of the URI
 * @param scheme the scheme to match against
 * @return Returns false if either argument is null, false if uri
 *         violates RFC 2396 or has an undefined scheme,
 *         otherwise returns whether uri string-matches scheme.
 */
static public boolean checkScheme(String uri, String scheme) {
    if ( (uri == null) || (scheme == null) )
        return false;
    URI uriObj;
    try {
        uriObj = URI.create(uri);
    }
    catch (IllegalArgumentException e) {
        /* RFC 2396 violation */
        return false;
    }
    String uriScheme = uriObj.getScheme();
    if (uriScheme == null)
        /* scheme undefined */
        return false;
    return (uriScheme.equals(scheme));
}
项目:VTD-XML    文件:FastIntBuffer.java   
/**
 * Sort the integers in the buffer 
 * @param order (as of version 2.9) 
 * it can be either ASCENDING or DESCENDING
 */
public void sort(int order) {
    switch (order) {
    case ASCENDING:
        if (size > 0)
            quickSort_ascending(0, size - 1);
        break;
    case DESCENDING:
        if (size > 0)
            quickSort_descending(0, size - 1);
        break;
    default:
        throw new IllegalArgumentException("Sort type undefined");
    }

}
项目:Silence    文件:SmsCipher.java   
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message)
    throws LegacyMessageException, InvalidMessageException,
           DuplicateMessageException, NoSessionException
{
  try {
    byte[]        decoded       = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
    SignalMessage signalMessage = new SignalMessage(decoded);
    SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1));
    byte[]        padded        = sessionCipher.decrypt(signalMessage);
    byte[]        plaintext     = transportDetails.getStrippedPaddingMessageBody(padded);

    if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) {
      signalProtocolStore.deleteSession(new SignalProtocolAddress(message.getSender(), 1));
    }

    return message.withMessageBody(new String(plaintext));
  } catch (IOException | IllegalArgumentException | NullPointerException e) {
    throw new InvalidMessageException(e);
  }
}
项目:mc_backup    文件:DownloadsIntegration.java   
private static boolean useSystemDownloadManager() {
    if (!AppConstants.ANDROID_DOWNLOADS_INTEGRATION) {
        return false;
    }

    int state = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
    try {
        state = GeckoAppShell.getContext().getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads");
    } catch (IllegalArgumentException e) {
        // Download Manager package does not exist
        return false;
    }

    return (PackageManager.COMPONENT_ENABLED_STATE_ENABLED == state ||
            PackageManager.COMPONENT_ENABLED_STATE_DEFAULT == state);
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
/**
 * Determines the ad rotation represented by a String. Returns null if the String does not match any known.
 *
 * @param v A String representation of a ad rotation
 * @return a {@link AdRotation} or null if there is no match
 */
public static AdRotation parseAdRotation(String v) {
    if (StringTable.DeleteValue.equals(v)) {
        return null;
    }

    if (v == null || v.isEmpty()) {
        return null;
    }

    try {
        AdRotation rotation = new AdRotation();
        rotation.setType(AdRotationType.fromValue(v));
        return rotation;
    } catch (IllegalArgumentException e) {
        return null;
    }
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
public static Minute parseMinute(String s) {
    int minuteNumber = Integer.parseInt(s);

    switch (minuteNumber) {
        case 0:
            return Minute.ZERO;
        case 15:
            return Minute.FIFTEEN;
        case 30:
            return Minute.THIRTY;
        case 45:
            return Minute.FORTY_FIVE;
        default:
            throw new IllegalArgumentException("Unknown minute");
    }
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
public static Day parseDay(String s) {      
    if (s.toLowerCase().equals("sunday"))
        return Day.SUNDAY;
    if (s.toLowerCase().equals("monday"))
        return Day.MONDAY;
    if (s.toLowerCase().equals("tuesday"))
        return Day.TUESDAY;
    if (s.toLowerCase().equals("wednesday"))
        return Day.WEDNESDAY;
    if (s.toLowerCase().equals("thursday"))
        return Day.THURSDAY;
    if (s.toLowerCase().equals("friday"))
        return Day.FRIDAY;
    if (s.toLowerCase().equals("saturday"))
        return Day.SATURDAY;
    throw new IllegalArgumentException("Unknown day");
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
public static String toBiddingSchemeBulkString(BiddingScheme biddingScheme) throws Exception {
    if (biddingScheme == null)
        return null;

    if (biddingScheme instanceof EnhancedCpcBiddingScheme) {
        return "EnhancedCpc";
    } else if (biddingScheme instanceof InheritFromParentBiddingScheme) {;
        return "InheritFromParent";
    } else if (biddingScheme instanceof MaxConversionsBiddingScheme) {
        return "MaxConversions";
    } else if (biddingScheme instanceof ManualCpcBiddingScheme) {
        return "ManualCpc";
    } else if (biddingScheme instanceof TargetCpaBiddingScheme) {
        return "TargetCpa";
    } else if (biddingScheme instanceof MaxClicksBiddingScheme) {
        return "MaxClicks";
    } else {
        throw new IllegalArgumentException("Unknown bidding scheme");
    }
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
public static String toRemarketingRuleBulkString(RemarketingRule remarketingRule) {
    if (remarketingRule == null) {
        return null;
    }
    if (remarketingRule instanceof CustomEventsRule) {
        return String.format("CustomEvents%s", getCustomEventsRule((CustomEventsRule)remarketingRule));
    } else if (remarketingRule instanceof PageVisitorsRule) {
        return String.format("PageVisitors%s", getRuleItemGroups(((PageVisitorsRule)remarketingRule).getRuleItemGroups().getRuleItemGroups()));
    } else if (remarketingRule instanceof PageVisitorsWhoVisitedAnotherPageRule) {
        return String.format("PageVisitorsWhoVisitedAnotherPage(%s) and (%s)", getRuleItemGroups(
                ((PageVisitorsWhoVisitedAnotherPageRule)remarketingRule).getRuleItemGroups().getRuleItemGroups()),
                getRuleItemGroups(((PageVisitorsWhoVisitedAnotherPageRule)remarketingRule).getAnotherRuleItemGroups().getRuleItemGroups()));
    } else if (remarketingRule instanceof PageVisitorsWhoDidNotVisitAnotherPageRule) {
        return String.format("PageVisitorsWhoDidNotVisitAnotherPage(%s) and not (%s)", getRuleItemGroups(
                ((PageVisitorsWhoDidNotVisitAnotherPageRule)remarketingRule).getIncludeRuleItemGroups().getRuleItemGroups()),
                getRuleItemGroups(((PageVisitorsWhoDidNotVisitAnotherPageRule)remarketingRule).getExcludeRuleItemGroups().getRuleItemGroups()));
    } else if (remarketingRule instanceof RemarketingRule){
        return null;
    } else {
        throw new IllegalArgumentException("Invalid Remarketing Rule");
    }
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
public static RemarketingRule parseRemarketingRule(String s) {
    if (StringExtensions.isNullOrEmpty(s))
        return null;
    int pos = s.indexOf('(');
    if (pos == -1) {
        throw new IllegalArgumentException(String.format("Invalid Remarketing Rule: %s", s));
    }       
    String type = s.substring(0, pos);
    String ruleStr = s.substring(pos + 1, s.length() - 1);      
    if (type.toLowerCase().equals("pagevisitors")) {
        return parsePageVisitorsRule(ruleStr);
    } else if (type.toLowerCase().equals("pagevisitorswhovisitedanotherpage")) {
        return parsePageVisitorsWhoVisitedAnotherPageRule(ruleStr);
    } else if (type.toLowerCase().equals("pagevisitorswhodidnotvisitanotherpage")) {
        return parsePageVisitorsWhoDidNotVisitAnotherPage(ruleStr);
    } else if (type.toLowerCase().equals("customevents")) {
        return parseCustomeventsRule(ruleStr);
    } else {
        throw new IllegalArgumentException(String.format("Invalid Custom Remarketing Rule Type: %s", type));
    }
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
private static NumberOperator parseNumberOperator(String operator) {
    if (operator == null) {
        return null;
    }
    operator = operator.toLowerCase();
    if (operator.equals("equals")) {
        return NumberOperator.EQUALS;
    } else if (operator.equals("greaterthan")) {
        return NumberOperator.GREATER_THAN;
    } else if (operator.equals("lessthan")) {
        return NumberOperator.LESS_THAN;
    } else if (operator.equals("greaterthanequalto")) {
        return NumberOperator.GREATER_THAN_EQUAL_TO;
    } else if (operator.equals("lessthanequalto")) {
        return NumberOperator.LESS_THAN_EQUAL_TO;
    } else {
        throw new IllegalArgumentException(String.format("Invalid Number Rule Item operator: ", operator));
    }
}
项目:BingAds-Java-SDK    文件:StringExtensions.java   
private static StringOperator parseStringOperator(String operator) {
    if (operator == null) {
        return null;
    }
    operator = operator.toLowerCase();
    if (operator.equals("equals")) {
        return StringOperator.EQUALS;
    } else if (operator.equals("contains")) {
        return StringOperator.CONTAINS;
    } else if (operator.equals("beginswith")) {
        return StringOperator.BEGINS_WITH;
    } else if (operator.equals("endswith")) {
        return StringOperator.ENDS_WITH;
    } else if (operator.equals("notequals")) {
        return StringOperator.NOT_EQUALS;
    } else if (operator.equals("doesnotcontain")) {
        return StringOperator.DOES_NOT_CONTAIN;
    } else if (operator.equals("doesnotbeginwith")) {
        return StringOperator.DOES_NOT_BEGIN_WITH;
    } else if (operator.equals("doesnotendwith")) {
        return StringOperator.DOES_NOT_END_WITH;
    } else {
        throw new IllegalArgumentException(String.format("Invalid String Rule Item perator: ", operator));
    }
}
项目:semanticvectors    文件:VectorSearcher.java   
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public VectorSearcherPerm(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  try {
    theAvg = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(queryVecStore, luceneUtils, flagConfig, queryTerms);
  } catch (IllegalArgumentException e) {
    logger.info("Couldn't create permutation VectorSearcher ...");
    throw e;
  }

  if (theAvg.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}
项目:semanticvectors    文件:VectorSearcher.java   
/**
 * @param queryVecStore Vector store to use for query generation (this is also reversed).
 * @param searchVecStore The vector store to search (this is also reversed).
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public BalancedVectorSearcherPerm(
    VectorStore queryVecStore, VectorStore searchVecStore, LuceneUtils luceneUtils,
    FlagConfig flagConfig, String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  specialFlagConfig = flagConfig;
  specialLuceneUtils = luceneUtils;
  try {
    oneDirection = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(queryVecStore, luceneUtils, flagConfig, queryTerms);
    otherDirection = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(searchVecStore, luceneUtils, flagConfig, queryTerms);
  } catch (IllegalArgumentException e) {
    logger.info("Couldn't create balanced permutation VectorSearcher ...");
    throw e;
  }

  if (oneDirection.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}
项目:semanticvectors    文件:VectorSearcher.java   
/**
  * Lucene search, no semantic vectors required
  * @param luceneUtils LuceneUtils object to use for query weighting. (May not be null.)
  * @param queryTerms Terms that will be parsed into a query expression
  */
 public VectorSearcherLucene(LuceneUtils luceneUtils,
     FlagConfig flagConfig, String[] queryTerms)
         throws IllegalArgumentException, ZeroVectorException {

  super(null, null, luceneUtils, flagConfig);
  this.specialLuceneUtils = luceneUtils;
  this.specialFlagConfig = flagConfig;
  Directory dir;
try {
    dir = FSDirectory.open(FileSystems.getDefault().getPath(flagConfig.luceneindexpath()));
    this.iSearcher = new IndexSearcher(DirectoryReader.open(dir));

    if (!flagConfig.elementalvectorfile().equals("elementalvectors"))
    {this.acceptableTerms = new VectorStoreRAM(flagConfig);
    acceptableTerms.initFromFile(flagConfig.elementalvectorfile());
    }
} catch (IOException e) {
    logger.info("Lucene index initialization failed: "+e.getMessage());
}

  this.queryTerms = queryTerms;

 }
项目:lcm    文件:LcmTestClient.java   
public boolean checkReply(primitives_t reply, int iteration) {
    try {
        int n = iteration;
        checkField(reply.i8, (byte)(n % 100), "i8");
        checkField(reply.i16, (short)(n * 10), "i16");
        checkField((long)reply.i64, (long)(n * 10000), "i64");
        checkField(reply.position[0], (float)n, "position[0]");
        checkField(reply.position[1], (float)n, "position[1]");
        checkField(reply.position[2], (float)n, "position[2]");
        checkField(reply.orientation[0], (double)n, "orientation[0]");
        checkField(reply.orientation[1], (double)n, "orientation[1]");
        checkField(reply.orientation[2], (double)n, "orientation[2]");
        checkField(reply.orientation[3], (double)n, "orientation[3]");
        checkField(reply.num_ranges, n, "num_ranges");
        for (int i = 0; i < reply.num_ranges; i++) {
            checkField(reply.ranges[i], (short)i, String.format("ranges[%d]", i));
        }
        checkField(reply.name, String.valueOf(n), "name");
        checkField(reply.enabled, n % 2 == 1, "enabled");
    } catch (IllegalArgumentException ex) {
        ex.printStackTrace(System.err);
        return false;
    }
    return true;
}
项目:Chronicle-Map    文件:ReplicatedGlobalMutableState$$Native.java   
@Override
public void copyFrom(ReplicatedGlobalMutableState from) {
    setAllocatedExtraTierBulks(from.getAllocatedExtraTierBulks());
    setFirstFreeTierIndex(from.getFirstFreeTierIndex());
    setExtraTiersInUse(from.getExtraTiersInUse());
    setSegmentHeadersOffset(from.getSegmentHeadersOffset());
    setDataStoreSize(from.getDataStoreSize());
    setCurrentCleanupSegmentIndex(from.getCurrentCleanupSegmentIndex());
    int _modificationIteratorsCount = from.getModificationIteratorsCount();
    if (_modificationIteratorsCount < 0 || _modificationIteratorsCount > 128) {
        throw new IllegalArgumentException("_modificationIteratorsCount should be in [0, 128] range, " + _modificationIteratorsCount + " is given");
    }
    bs.writeByte(offset + 29, (byte) (_modificationIteratorsCount));
    for (int index = 0; index < 128; index++) {
        setModificationIteratorInitAt(index, from.getModificationIteratorInitAt(index));
    }
}
项目:reach-banner    文件:Clustering.java   
/** Clustering constructor.
    *
    * @param instances Instances that are clustered
    * @param numLabels Number of clusters
    * @param labels Assignment of instances to clusters; many-to-one with 
    *               range [0,numLabels).
    */
   public Clustering( InstanceList instances, int numLabels, int[] labels )
   {

if ( instances.size() != labels.length )
    throw new IllegalArgumentException("Instance list length does not match cluster labeling");

if (numLabels<1)
    throw new IllegalArgumentException("Number of labels must be strictly positive.");

for (int i=0 ; i<labels.length ; i++)
    if (labels[i]<0 || labels[i]>=numLabels)
    throw new IllegalArgumentException("Label mapping must have range [0,numLabels).");

this.instances = instances;
this.numLabels = numLabels;
this.labels = labels;

   }
项目:incubator-netbeans    文件:ZOrderManager.java   
/** Adds given window (RootPaneContainer) to the set of windows which are tracked.
 */
public void attachWindow (RootPaneContainer rpc) {
    logger.entering(getClass().getName(), "attachWindow");

    if (!(rpc instanceof Window)) {
        throw new IllegalArgumentException("Argument must be subclas of java.awt.Window: " + rpc);   //NOI18N
    }
    if (getWeak(rpc) != null) {
        throw new IllegalArgumentException("Window already attached: " + rpc);   //NOI18N
    }

    zOrder.add(new WeakReference<RootPaneContainer>(rpc));
    ((Window)rpc).addWindowListener(this);
}
项目:incubator-netbeans    文件:ZOrderManager.java   
public void windowActivated(WindowEvent e) {
    logger.entering(getClass().getName(), "windowActivated");

    WeakReference<RootPaneContainer> ww = getWeak((RootPaneContainer)e.getWindow());
    if (ww != null) {
        // place as last item in zOrder list
        zOrder.remove(ww);
        zOrder.add(ww);
    } else {
        throw new IllegalArgumentException("Window not attached: " + e.getWindow()); //NOI18N
    }
}