Package java.util.regex

Examples of java.util.regex.Pattern$Block


    }

    private ArrayList<Block> getBlocksAroundBlockByState(int column, int row, BlockState blockState){
        ArrayList<Block> blocksWithBlockState = new ArrayList<Block>();
        for(Direction direction : Direction.values()){
            Block block = getBlockFromDirection(column, row, direction);
            if(block!=null && block.getBlockState()!=null && block.getBlockState()== blockState)
                blocksWithBlockState.add(block);
        }
        return blocksWithBlockState;
    }
View Full Code Here


    private void generateBlocks(int columns, int rows) {
        blocks = new Block[columns][rows];
        for(int c=0; c<columns; c++)
            for(int r=0; r<rows; r++)
                blocks[c][r] = new Block(c*blockSize, r*blockSize, blockSize, blockSize);
    }
View Full Code Here

                else
                    g.drawImage(emptyFieldImage, 0, 0,null);

                for(int c=0; c<mineSweeper.getBlocks().length; c++)
                    for(int r=0; r<mineSweeper.getBlocks()[0].length; r++) {
                        Block block = mineSweeper.getBlocks()[c][r];

                        if(block.getBlockNumber()!=null){
                            g.setColor(block.getBlockNumber().getColor());
                            g.drawString(""+block.getBlockNumber().getNumber(), block.x+4, block.y+12);
                        }
                        if(block.getBlockState()!=null)
                            switch(block.getBlockState()){
                                case FLAG:      g.drawImage(flagBlock, block.x, block.y, null);
                                    break;
                                case BOMB:      g.drawImage(bombBlock, block.x, block.y, null);
                                    break;
                                case EMPTY:     if(block.getBlockNumber()==null)
                                    g.drawImage(emptyBlock, block.x, block.y, null);
                            }
                    }

            }
View Full Code Here

      return null;
    }
    String pre = "\\$\\{";
    String post = "\\}";
    String regex = pre+"(.*?)"+post;
    Pattern pattern = Pattern.compile(regex);

    Matcher matcher = pattern.matcher(value);

    while (matcher.find()) {
      String sysKey = matcher.group(1);
      String p = pre + sysKey + post;
      String v = sysKey.equalsIgnoreCase("user.appdata") ? System.getenv("appdata") : System.getProperty(sysKey,"UNKNOWN");
View Full Code Here

    reader.close();
  }

  private SoftwareUpdateItem[] readSoftwareUpdateItems(BufferedReader reader, boolean onlyUpdates, boolean dragNdrop, PluginBaseInfo[] baseInfos) throws IOException {
    Pattern pluginTypePattern = Pattern.compile("\\[(.*):(.*)\\]");
    Pattern keyValuePattern = Pattern.compile("(.+?)=(.*)");
    Matcher matcher;

    ArrayList<SoftwareUpdateItem> updateItems = new ArrayList<SoftwareUpdateItem>();
    //ArrayList<PluginsSoftwareUpdateItem> blockedItems = new ArrayList<PluginsSoftwareUpdateItem>(0);

    try {
      SoftwareUpdateItem curItem=null;
      String line=reader.readLine();

      while (line != null) {
        matcher=pluginTypePattern.matcher(line);
        if (matcher.find()) { // new plugin
          String type=matcher.group(1);
          String className=matcher.group(2);

          if ("plugin".equals(type)) {
            curItem=new PluginSoftwareUpdateItem(className);
          }
          else if ("dataservice".equals(type)) {
            curItem=new DataServiceSoftwareUpdateItem(className);
          }
          else if ("tvbrowser".equals(type)) {
            curItem=new TvbrowserSoftwareUpdateItem(className);
          }

          if (curItem==null) {
            throw new IOException("invalid software update file");
          }

          updateItems.add(curItem);
        }
        else {
          matcher=keyValuePattern.matcher(line);

          if (matcher.find()) { // new plugin
            String value = matcher.group(2);
            value = value.replaceAll("\\\\", ""); // fix wrong HTML encoding in plugin descriptions

View Full Code Here

      flags |= Pattern.CASE_INSENSITIVE;
      flags |= Pattern.UNICODE_CASE;
    }

    // Compile the regular expression
    Pattern pattern;
    try {
      pattern = Pattern.compile(regex, flags);
    }
    catch (PatternSyntaxException exc) {
      throw new TvBrowserException(RegexSearcher.class, "error.1",
View Full Code Here

      } catch (TvBrowserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      if (searcher instanceof RegexSearcher) {
        Pattern pattern = ((RegexSearcher) searcher).getPattern();
        if (pattern != null) {
          if (pattern.pattern().startsWith(".*")) {
            pattern = Pattern.compile(pattern.pattern().substring(2));
          }
          if (pattern.pattern().endsWith(".*")) {
            pattern = Pattern.compile(pattern.pattern().substring(0,
                pattern.pattern().length() - 2));
          }
          for (HTMLDocument.Iterator it = document
              .getIterator(HTML.Tag.CONTENT); it.isValid(); it.next()) {
            try {
              String fragment = document.getText(it.getStartOffset(), it
                  .getEndOffset()
                  - it.getStartOffset());
              Matcher matcher = pattern.matcher(fragment);
              while (matcher.find()) {
                highlighter.addHighlight(it.getStartOffset() + matcher.start(),
                    it.getStartOffset() + matcher.end(), painter);
              }
            } catch (BadLocationException ex) {
View Full Code Here

    /**
     * Method for validating event strings against event string specifications, where a
     * specification is a regular expression involving event symbols. e.g. [b]([sgv])[u]
     */
    protected static boolean validateEventString(String eventString, String spec) {
        Pattern pattern = null;
        Matcher matcher = null;

        // set up the regular expression specification
        pattern = Pattern.compile(spec);
        // set up the actual event string
        matcher = pattern.matcher(eventString);

        // check if the actual string satisfies the specification
        if (matcher.find()) {
            // a match has been found, but we need to check that the whole event string
            // matches, and not just a substring
View Full Code Here

  protected Map getBeanProperties(Object bean) {
    HashMap values = new HashMap();
    if (bean == null) return values;
    Method[] m = bean.getClass().getMethods();
   
    Pattern p = Pattern.compile("get([A-Z]\\w+)");
   
    for (int i = 0; i < m.length; i++) {
      if (m[i].getName().equals("getClass")) continue;
      if (m[i].getParameterTypes().length > 0) continue;
      Matcher r = p.matcher(m[i].getName());
      if (r.matches()) {
        try {
          values.put(r.group(1).toLowerCase(), m[i].invoke(bean, new Object[0]));
        } catch (IllegalArgumentException e) {
          throw e;
View Full Code Here

   
    // javascript:loadOrAlert('WVOPRHRPFSCLAW7UWHCXCH7QNQIU6TWG')

    // accept raw hash of 32 base-32 chars, with garbage around it
    if (accept_magnets && guess) {
      Pattern pattern = Pattern.compile("[^a-zA-Z2-7][a-zA-Z2-7]{32}[^a-zA-Z2-7]");
      Matcher matcher = pattern.matcher(text);
      if (matcher.find()) {
        String hash = text.substring(matcher.start() + 1, matcher.start() + 33);
        return "magnet:?xt=urn:btih:" + hash;
      }

      pattern = Pattern.compile("[^a-fA-F0-9][a-fA-F0-9]{40}[^a-fA-F0-9]");
      matcher = pattern.matcher(text);
      if (matcher.find()) {
        String hash = text.substring(matcher.start() + 1, matcher.start() + 41);
        // convert from HEX to raw bytes
        byte[] infohash = ByteFormatter.decodeString(hash.toUpperCase());
        // convert to BASE32
View Full Code Here

TOP

Related Classes of java.util.regex.Pattern$Block

Copyright © 2018 www.massapicom. 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.