Package java.util.regex

Examples of java.util.regex.Pattern$Pos


         globals           = world.globals;
         metaSig           = world.metaSig;
         metaField         = world.metaField;
      }
      this.path = path;
      if (filename!=null && filename.length()>0) this.modulePos=new Pos(filename,1,1);
   }
View Full Code Here


         ans.add(make("<b>"+x.size()+(x.size()>1?" facts</b>":" fact</b>"), x));
      }
      if (asserts.size()>0) {
         x = new ArrayList<Browsable>(asserts.size());
         for(Map.Entry<String,Expr> e: asserts.entrySet()) {
            Pos sp = e.getValue().span();
            x.add(make(sp, sp, "<b>assert</b> "+e.getKey(), e.getValue()));
         }
         ans.add(make("<b>"+x.size()+(x.size()>1?" asserts</b>":" assert</b>"), x));
      }
      return ans;
View Full Code Here

   //============================================================================================================================//

   /** Add a sig declaration. */
   Sig addSig(String name, ExprVar par, List<ExprVar> parents, List<Decl> fields, Expr fact, Attr... attributes) throws Err {
      Sig obj;
      Pos pos = Pos.UNKNOWN.merge(WHERE.find(attributes));
      status = 3;
      dup(pos, name, true);
      String full = (path.length()==0) ? "this/"+name : path+"/"+name;
      Pos subset=null, subsig=null;
      boolean exact = false;
      if (par!=null) {
         if (par.label.equals("extends")) { subsig=par.span().merge(parents.get(0).span()); }
         else { exact=!par.label.equals("in"); subset=par.span(); for(ExprVar p:parents) subset=p.span().merge(subset); }
      }
View Full Code Here

   /** The given Sig will now point to a nonnull Sig. */
   private static Sig resolveSig(CompModule res, Set<Object> topo, Sig oldS) throws Err {
      if (res.new2old.containsKey(oldS)) return oldS;
      Sig realSig;
      final Pos pos = oldS.pos;
      final CompModule u = res.sig2module.get(oldS);
      final String name = base(oldS);
      final String fullname = (u.path.length()==0) ? ("this/"+name) : (u.path+"/"+name);
      if (!topo.add(oldS)) throw new ErrorType(pos, "Sig "+oldS+" is involved in a cyclic inheritance.");
      if (oldS instanceof SubsetSig)  {
View Full Code Here

         m.new2old.put(ka, ka);
         m.sigs.put(base(ka), ka);
         hasMetaSig = true;
         Expr allfields = ExprConstant.EMPTYNESS;
         for(Field field: s.getFields()) {
            Pos priv = field.isPrivate; if (priv==null) priv = s.isPrivate;
            PrimSig kb = new PrimSig(s.label+"$"+field.label, root.metaField, Attr.ONE, PRIVATE.makenull(priv), Attr.META);
            field2meta.put(field, kb);
            m.new2old.put(kb, kb);
            m.sigs.put(base(kb), kb);
            hasMetaField = true;
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

TOP

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

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.