Package java.util.regex

Examples of java.util.regex.Pattern.flags()


          + (((pat.flags() & Pattern.CASE_INSENSITIVE) > 0) ? "i" : "")
          + (((pat.flags() & Pattern.COMMENTS) > 0) ? "x" : "")
          + (((pat.flags() & Pattern.DOTALL) > 0) ? "s" : "")
          + (((pat.flags() & Pattern.LITERAL) > 0) ? "q" : "")
          + (((pat.flags() & Pattern.MULTILINE) > 0) ? "m" : "")
          + (((pat.flags() & Pattern.UNICODE_CASE) > 0) ? "l" : "")
          + (((pat.flags() & Pattern.UNIX_LINES) > 0) ? "u" : "")
          + "@" + System.identityHashCode( o );

    } else if( o instanceof Alias ) {
      return ind + "Alias: " + dump( ((Alias)o).getValue(), indent );
View Full Code Here


          + (((pat.flags() & Pattern.COMMENTS) > 0) ? "x" : "")
          + (((pat.flags() & Pattern.DOTALL) > 0) ? "s" : "")
          + (((pat.flags() & Pattern.LITERAL) > 0) ? "q" : "")
          + (((pat.flags() & Pattern.MULTILINE) > 0) ? "m" : "")
          + (((pat.flags() & Pattern.UNICODE_CASE) > 0) ? "l" : "")
          + (((pat.flags() & Pattern.UNIX_LINES) > 0) ? "u" : "")
          + "@" + System.identityHashCode( o );

    } else if( o instanceof Alias ) {
      return ind + "Alias: " + dump( ((Alias)o).getValue(), indent );
    } else if( o instanceof PerlReference ) {
View Full Code Here

      }
      if (thisValue instanceof Pattern && thatValue instanceof Pattern) {
         // java.util.regex.Pattern does not implement equals!!
         Pattern thisPattern = (Pattern) thisValue;
         Pattern thatPattern = (Pattern) thatValue;
         return thisPattern.pattern().equals(thatPattern.pattern()) && thisPattern.flags() == thatPattern.flags();
      }
      return thisValue.equals(thatValue);
   }

}
View Full Code Here

                                              Pattern.LITERAL |
                                              Pattern.UNICODE_CASE |
                                              Pattern.COMMENTS |
                                              256 );

        String s = Bytes.regexFlags( lotsoflags.flags() );
        char prev = s.charAt( 0 );
        for( int i=1; i<s.length(); i++ ) {
            char current = s.charAt( i );
            assertTrue( prev < current );
            prev = current;
View Full Code Here

            assertTrue( prev < current );
            prev = current;
        }

        int check = Bytes.regexFlags( s );
        assertEquals( lotsoflags.flags(), check );
    }

    @Test
    public void testPattern() {
        Pattern p = Pattern.compile( "([a-zA-Z0-9_-])([a-zA-Z0-9_.-]*)@(((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.))" );
View Full Code Here

        format.setCalendar(new GregorianCalendar(new SimpleTimeZone(0, "GMT")));
        assert (a.get("date").equals(format.parse("2011-05-18T18:56:00Z")));
        Pattern pat = (Pattern) a.get("pat");
        Pattern pat2 = Pattern.compile(".*", BSON.regexFlags(""));
        assert (pat.pattern().equals(pat2.pattern()));
        assert (pat.flags() == (pat2.flags()));
        ObjectId oid = (ObjectId) a.get("oid");
        assert (oid.equals(new ObjectId("4d83ab3ea39562db9c1ae2ae")));
        DBRef ref = (DBRef) a.get("ref");
        assert (ref.equals(new DBRef(null, "test.test", new ObjectId("4d83ab59a39562db9c1ae2af"))));
        assert (a.get("code").equals(new Code("asdfdsa")));
View Full Code Here

    @Test
    public void regexParsing() {
        Pattern pattern = (Pattern) JSON.parse(("{ \"$regex\" : \".*\",  \"$options\": \"i\" }"));
        assertEquals(pattern.pattern(), ".*");
        assertEquals(pattern.flags(), Pattern.CASE_INSENSITIVE);
    }

    @Test
    public void oidParsing() {
        ObjectId id = (ObjectId) JSON.parse(("{ \"$oid\" : \"01234567890123456789abcd\" }"));
View Full Code Here

        decoder.setData( encoder.write( p ) );
        Pattern actual = (Pattern) decoder.decode();

        Assert.assertEquals( "Pattern not equal: " + p.pattern() + " != " + actual.pattern(), p.pattern(), actual.pattern() );
        Assert.assertEquals( "Flags not equal: " + p.flags() + " != " + actual.flags(), p.flags(), actual.flags() );
      } catch (SerealException e) {
        fail( e.getMessage() );
      }

    }
View Full Code Here

        decoder.setData( encoder.write( p ) );
        Pattern actual = (Pattern) decoder.decode();

        Assert.assertEquals( "Pattern not equal: " + p.pattern() + " != " + actual.pattern(), p.pattern(), actual.pattern() );
        Assert.assertEquals( "Flags not equal: " + p.flags() + " != " + actual.flags(), p.flags(), actual.flags() );
      } catch (SerealException e) {
        fail( e.getMessage() );
      }

    }
View Full Code Here

            if(covering.length == 3) {
                String opts = inputs.get(2).getString();
                flags |= parseOptionFlags(opts);
            }
            p = (Pattern)context.exectimeObjectAt(CACHE_INDEX);
            if((p == null) || (p.pattern() != pattern) || (p.flags() != flags)) {
                p = Pattern.compile(pattern, flags);
                context.putExectimeObject(CACHE_INDEX, p);
            }
        }
        String input = inputs.get(0).getString();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.