コード例 #1
1
ファイル: Macro.java プロジェクト: bramk/bnd
  public String _range(String args[]) {
    verifyCommand(args, _rangeHelp, _rangePattern, 2, 3);
    Version version = null;
    if (args.length >= 3) version = new Version(args[2]);
    else {
      String v = domain.getProperty("@");
      if (v == null) return null;
      version = new Version(v);
    }
    String spec = args[1];

    Matcher m = RANGE_MASK.matcher(spec);
    m.matches();
    String floor = m.group(1);
    String floorMask = m.group(2);
    String ceilingMask = m.group(3);
    String ceiling = m.group(4);

    String left = version(version, floorMask);
    String right = version(version, ceilingMask);
    StringBuilder sb = new StringBuilder();
    sb.append(floor);
    sb.append(left);
    sb.append(",");
    sb.append(right);
    sb.append(ceiling);

    String s = sb.toString();
    VersionRange vr = new VersionRange(s);
    if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) {
      domain.error(
          "${range} macro created an invalid range %s from %s and mask %s", s, version, spec);
    }
    return sb.toString();
  }
コード例 #2
0
  protected Map<String, String> getAttributes() {
    if (attributes != null) {
      return attributes;
    }

    attributes = new HashMap<String, String>();

    matcher = ADDITIONAL_ATTRIBUTES_PATTERN.matcher(firstLine);
    if (matcher.find()) {
      String s;
      Matcher attributeMatcher;

      s = matcher.group(2);
      attributeMatcher = ADDITIONAL_ATTRIBUTE_PATTERN.matcher(s);
      while (attributeMatcher.find()) {
        String key;
        String value;

        key = attributeMatcher.group(1);
        value = attributeMatcher.group(2);
        attributes.put(key.toLowerCase(Locale.ENGLISH), value);
      }
    }
    return attributes;
  }
コード例 #3
0
  private static String expand(String str) {
    if (str == null) {
      return null;
    }

    StringBuilder result = new StringBuilder();
    Pattern re = Pattern.compile("^(.*?)\\$\\{([^}]*)\\}(.*)");
    while (true) {
      Matcher matcher = re.matcher(str);
      if (matcher.matches()) {
        result.append(matcher.group(1));
        String property = matcher.group(2);
        if (property.equals("/")) {
          property = "file.separator";
        }
        String value = System.getProperty(property);
        if (value != null) {
          result.append(value);
        }
        str = matcher.group(3);
      } else {
        result.append(str);
        break;
      }
    }
    return result.toString();
  }
コード例 #4
0
  public static void main(String[] args) throws IOException {
    // Get input html
    StringBuffer sb = new StringBuffer();
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    for (String str = in.readLine(); str != null; str = in.readLine()) {
      sb.append("\n" + str);
    }
    String html = sb.toString();

    // Match all the questions
    Matcher matcher =
        Pattern.compile(
                "<\\s*div\\s+class\\s*=\\s*\"question-summary\"\\s*id\\s*=\\s*\"question-summary-(?<id>\\d+)\"\\s*>"
                    + ".*?<\\s*div\\s+class\\s*=\\s*\"summary\"\\s*>"
                    + ".*?<\\s*a\\s+.*?class\\s*=\\s*\"question-hyperlink\"\\s*>"
                    + "(?<title>.*?)"
                    + "</\\s*a\\s*>.*?<\\s*div\\s+class\\s*=\\s*\"user-action-time\"\\s*>"
                    + ".*?<\\s*span\\s+.*?>(?<time>.*?)</\\s*span\\s*>",
                Pattern.CASE_INSENSITIVE | Pattern.DOTALL)
            .matcher(html);

    // Output the information
    while (matcher.find()) {
      String id = matcher.group("id");
      String title = matcher.group("title");
      String time = matcher.group("time");
      System.out.println(id + ";" + title + ";" + time);
    }
  }
コード例 #5
0
ファイル: SourceFile.java プロジェクト: movinghorse/YCombo
  /**
   * Get dependencies of a source file.
   *
   * @param path The canonical path of source file.
   * @return Path of dependencies.
   */
  private ArrayList<String> getDependencies(String path) {
    if (!dependenceMap.containsKey(path)) {
      ArrayList<String> dependencies = new ArrayList<String>();
      Matcher m = PATTERN_REQUIRE.matcher(read(path, charset));

      while (m.find()) {
        // Decide which root path to use.
        // Path wrapped in <> is related to root path.
        // Path wrapped in "" is related to parent folder of the source file.
        String root = null;

        if (m.group(1).equals("<")) {
          root = this.root;
        } else {
          root = new File(path).getParent();
        }

        // Get path of required file.
        String required = m.group(2);

        File f = new File(root, required);

        if (f.exists()) {
          dependencies.add(canonize(f));
        } else {
          App.exit("Cannot find required file " + required + " in " + path);
        }
      }

      dependenceMap.put(path, dependencies);
    }

    return dependenceMap.get(path);
  }
コード例 #6
0
ファイル: InferModel.java プロジェクト: viirya/sina_topic
  private InstanceList readFile() throws IOException {

    String NL = System.getProperty("line.separator");
    Scanner scanner = new Scanner(new FileInputStream(fileName), encoding);

    ArrayList<Pipe> pipeList = new ArrayList<Pipe>();
    pipeList.add(new CharSequence2TokenSequence(Pattern.compile("\\p{L}\\p{L}+")));
    pipeList.add(new TokenSequence2FeatureSequence());

    InstanceList testing = new InstanceList(new SerialPipes(pipeList));

    try {
      while (scanner.hasNextLine()) {

        String text = scanner.nextLine();
        text = text.replaceAll("\\x0d", "");

        Pattern patten = Pattern.compile("^(.*?),(.*?),(.*)$");
        Matcher matcher = patten.matcher(text);

        if (matcher.find()) {
          docIds.add(matcher.group(1));
          testing.addThruPipe(new Instance(matcher.group(3), null, "test instance", null));
        }
      }
    } finally {
      scanner.close();
    }

    return testing;
  }
コード例 #7
0
  public void testBaseUrlPath() throws Exception {
    sau1 = setupSimAu(simAuConfig(tempDirPath));
    createContent(sau1);
    crawlContent(sau1);
    CachedUrlSet cus1 = sau1.getAuCachedUrlSet();

    tempDirPath2 = getTempDir().getAbsolutePath() + File.separator;
    Configuration config2 = simAuConfig(tempDirPath2);
    config2.put("base_url", "http://anotherhost.org/some/path/");
    SimulatedArchivalUnit sau2 = setupSimAu(config2);
    createContent(sau2);
    crawlContent(sau2);
    CachedUrlSet cus2 = sau1.getAuCachedUrlSet();
    List urls1 = auUrls(sau1);
    List urls2 = auUrls(sau2);

    Pattern pat1 = Pattern.compile("http://www\\.example\\.com(/.*)$");
    Pattern pat2 = Pattern.compile("http://anotherhost\\.org/some/path(/.*)$");
    List<String> l1 = auUrls(sau1);
    List<String> l2 = auUrls(sau2);
    assertEquals(l1.size(), l2.size());
    for (int ix = 0; ix < l1.size(); ix++) {
      Matcher m1 = pat1.matcher(l1.get(ix));
      assertTrue(m1.matches());
      Matcher m2 = pat2.matcher(l2.get(ix));
      assertTrue(m2.matches());
      assertEquals(m1.group(1), m2.group(1));
    }
  }
コード例 #8
0
 public Coords(String entry) {
   Matcher m = coordsPattern.matcher(entry);
   if (!m.matches()) {
     throw new IllegalArgumentException(entry);
   }
   chrom = m.group(1);
   start = Integer.parseInt(m.group(2));
   end = Integer.parseInt(m.group(3));
   strand = m.group(4).charAt(0);
 }
コード例 #9
0
 public static int[] decodePrimerName(String pname) {
   Matcher m = primerNamePattern.matcher(pname);
   if (!m.matches()) {
     throw new IllegalArgumentException(pname);
   }
   int[] a = new int[3];
   a[0] = Integer.parseInt(m.group(1));
   a[1] = Integer.parseInt(m.group(2));
   a[2] = Integer.parseInt(m.group(3));
   return a;
 }
コード例 #10
0
 /**
  * Converts a colour from #rrggbb to Java Color object.
  *
  * @param rgb String e.g. #ff00ee
  * @return Colour
  * @throws IllegalArgumentException If colour string is not valid
  */
 protected Color convertRgb(String rgb) throws IllegalArgumentException {
   // Get colour parameter
   Matcher m = REGEX_RGB.matcher(rgb);
   if (!m.matches()) {
     throw new IllegalArgumentException(
         "MathML invalid colour '" + rgb + "'; expected #rrggbb (lower-case)");
   }
   return new Color(
       Integer.parseInt(m.group(1), 16),
       Integer.parseInt(m.group(2), 16),
       Integer.parseInt(m.group(3), 16));
 }
コード例 #11
0
 public static String removePrimerLR(String pname) {
   Matcher m = primerLRPattern.matcher(pname);
   if (!m.matches()) {
     throw new IllegalArgumentException(pname);
   }
   return m.group(1);
 }
コード例 #12
0
 /**
  * Takes a line and looks for an archive request tag. If one is found, the information from the
  * tag is returned as an <CODE>ArchiveRequest</CODE>. If a tag is found, the data in the tag is
  * stored in the <CODE>HashMap</CODE> provided.
  *
  * @param currentLine The line in which to look for the archive tag.
  * @param group The <CODE>ArchiveGroup</CODE> to which to add the <CODE>ArchiveRequest</CODE>. Can
  *     be <CODE>null</CODE>.
  * @param template The <CODE>Template</CODE> to which the <CODE>ArchiveRequest</CODE> belongs.
  * @return The archive request tag data as an instance of <CODE>ArchiveRequest</CODE>, <CODE>null
  *     </CODE> if the line passed in does not contain an arFile tag.
  */
 private ArchiveRequest parseArchiveRequestTag(
     String currentLine, ArchiveGroup group, Template template) {
   ArchiveRequest archiveTag;
   Matcher currentMatcher = archiveRequestPattern.matcher(currentLine);
   if (currentMatcher.find()) {
     String fileName = currentMatcher.group(1);
     archiveTag = template.getArchiveRequest(fileName);
     if (archiveTag == null) {
       archiveTag = new ArchiveRequest(fileName);
       template.addArchiveRequest(archiveTag);
     }
     if (group != null) {
       // Creating a new request object because the requests
       // in the groups flagged as not in database will mean the
       // group - request association is not in database. Requests
       // in the archiveRequests map flagged as not in database
       // means the request record is not there.
       String requestFileName = archiveTag.getFileName();
       String requestFileLocation = archiveTag.getFileLocation();
       ArchiveRequest groupRequest = new ArchiveRequest(requestFileLocation, requestFileName);
       group.addArchiveRequest(groupRequest);
     }
   } else archiveTag = null;
   return archiveTag;
 }
コード例 #13
0
 public static String getChrom(String chromName) {
   Matcher m = chromPattern.matcher(chromName);
   if (!m.matches()) {
     return chromName;
   }
   return m.group(1);
 }
コード例 #14
0
 public String getArtifactIdFromCoord(String coord) {
   Matcher m = COORD_P.matcher(coord);
   if (m.matches()) {
     return m.group(2);
   } else {
     return null;
   }
 }
コード例 #15
0
 /**
  * Takes a line and looks for an archive tag. If one is found, the information from the tag is
  * returned as a <CODE>Signal</CODE>. If a signal ID is given in the tag, the data in the tag is
  * stored in the <CODE>HashMap</CODE> provided.
  *
  * @param currentLine The line in which to look for the archive tag.
  * @return The archive tag data as an instance of <CODE>Signal</CODE>, <CODE>null</CODE> if the
  *     line passed in does not contain an arReq tag.
  */
 private Signal parseArchiveTag(String currentLine) {
   Signal archiveTag;
   Matcher currentMatcher = archivePattern.matcher(currentLine);
   if (currentMatcher.find()) {
     archiveTag = new Signal(currentMatcher.group(1));
     String frequency = currentMatcher.group(2);
     BigDecimal frequencyValue;
     if (frequency == null) frequencyValue = null;
     else frequencyValue = new BigDecimal(frequency);
     archiveTag.setArchiveFrequency(frequencyValue);
     String type = currentMatcher.group(3);
     if (type == null) type = "Monitor";
     archiveTag.setArchiveType(type);
     archiveTag.setArchiveIndicator("Y");
   } else archiveTag = null;
   return archiveTag;
 }
コード例 #16
0
ファイル: EBNF.java プロジェクト: meatlover/pai
  private void addNonTerminal(String EBNF) {
    String p = "<([\\w-]+)>[\\s]*::=(" + "([\\s]*(<[\\w-]+>|(\"[^\"]*\")|[|\\[\\]{}])" + ")+)";
    Matcher m = Pattern.compile(p).matcher(EBNF);

    m.find();

    NonTerminal nt = new NonTerminal(m.group(1));
    List<? extends EBNFBranch> branches = EBNFBranch.getBranches(m.group(2));

    assert (branches.size() > 0);

    if (nonTerminals.size() == 0) {
      startSymbol = nt;
    }

    nonTerminals.put(nt, branches);
  }
コード例 #17
0
 public synchronized String format(String message) {
   Matcher matcher = variablePattern.matcher(message);
   while (matcher.find()) {
     String variable = matcher.group();
     variable = variable.substring(1);
     if (variable.startsWith("{") && variable.endsWith("}"))
       variable = variable.substring(1, variable.length() - 1);
     String value = variables.get(variable);
     if (value == null) value = "";
     message =
         message.replaceFirst(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
   }
   matcher = colorPattern.matcher(message);
   while (matcher.find())
     message =
         message.substring(0, matcher.start()) + "\247" + message.substring(matcher.end() - 1);
   return message;
 }
コード例 #18
0
 public BasicSpellChecker(String file) throws IOException {
   BufferedReader in = new BufferedReader(new FileReader(file));
   Pattern p = Pattern.compile("\\w+");
   for (String temp = ""; temp != null; temp = in.readLine()) {
     Matcher m = p.matcher(temp.toLowerCase());
     while (m.find())
       nWords.put((temp = m.group()), nWords.containsKey(temp) ? nWords.get(temp) + 1 : 1);
   }
   in.close();
 }
コード例 #19
0
  private void buildXmlPropertiesFile() {
    System.out.println(
        "\nBuilding and checking your pipeline properties file -> " + truncPipePropFile);
    StringBuilder toPrint = new StringBuilder();

    // walk through the prop file
    String[] prop = IO.loadFileIntoStringArray(truncPipePropFile);
    Pattern val = Pattern.compile("(<entry key.+>)([D|A|B].*)</entry>");
    boolean missingFile = false;
    for (String s : prop) {
      // does it match a file needing prepending? Data/, Apps/, Bed/
      Matcher mat = val.matcher(s);
      if (mat.matches()) {
        File test = new File(referenceDir, mat.group(2));
        if (test.exists()) {
          System.out.println("Found\t" + test);
          toPrint.append(mat.group(1));
          toPrint.append(test.toString());
          toPrint.append("</entry>");
        } else {
          System.out.println("Misssing\t" + test);
          missingFile = true;
        }
      }
      // threads?
      else if (s.contains("threads"))
        toPrint.append("<entry key=\"threads\">" + threads + "</entry>");

      // nope just save it and add a line return
      else toPrint.append(s);
      toPrint.append("\n");
    }
    // anything missing? if so exit
    if (missingFile)
      Misc.printErrAndExit(
          "\nFailed to find all of the files in your properties file, see above.\n");

    // OK, write it out
    completePipelinePropFile = new File(outputDirectory, "pipelineProperties.xml");
    if (IO.writeString(toPrint.toString(), completePipelinePropFile) == false)
      Misc.printErrAndExit("Problem writing -> " + truncPipePropFile);
  }
コード例 #20
0
 protected boolean shouldIgnoreBCCAddress(String address) {
   MilterServerService milterService = Config.getConfig().getMilterServerService();
   List<String> ignoreAddresses = milterService.getIgnoreBCCAddress();
   Matcher m = headerPattern2.matcher(address.toLowerCase(Locale.ENGLISH).trim());
   if (m.matches()) {
     String mailAddress = m.group(1);
     for (String ignoreAddress : ignoreAddresses) {
       if (ignoreAddress.equalsIgnoreCase(mailAddress)) return true;
     }
   } else {
     m = headerPattern3.matcher(address.toLowerCase(Locale.ENGLISH).trim());
     if (m.matches()) {
       String mailAddress = m.group(1);
       for (String ignoreAddress : ignoreAddresses) {
         if (ignoreAddress.equalsIgnoreCase(mailAddress)) return true;
       }
     }
   }
   return false;
 }
コード例 #21
0
  public String getResult() {
    if (result != null) {
      return result;
    }

    matcher = RESULT_PATTERN.matcher(firstLine);
    if (matcher.find()) {
      result = matcher.group(1);
    }
    return result;
  }
コード例 #22
0
  public int getStatus() {
    if (status != null) {
      return status;
    }

    matcher = STATUS_PATTERN.matcher(firstLine);
    if (matcher.find()) {
      status = Integer.parseInt(matcher.group(1));
    }
    return status;
  }
コード例 #23
0
  public static void loadPermissions(URL url) throws IOException, PermissionParseException {

    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String line;
    Pattern ignore = Pattern.compile("^\\s*(//.*)?$");
    Pattern valid =
        Pattern.compile("^\\s*permission\\s+(\\S+)" + "(\\s+\"([^\"]*)\"(,\\s+\"([^\"]*)\")?)?;$");

    Set<Permission> perms = new HashSet<Permission>();

    while ((line = in.readLine()) != null) {
      if (ignore.matcher(line).matches()) {
        continue;
      }

      Matcher matcher = valid.matcher(line);
      if (!matcher.matches()) {
        throw new PermissionParseException("invalid syntax: " + line);
      }

      int nGroups = matcher.groupCount();
      String type = matcher.group(1);
      String name = expand(nGroups >= 3 ? matcher.group(3) : null);
      String actions = expand(nGroups >= 5 ? matcher.group(5) : null);

      try {
        Permission perm = getPermission(type, name, actions);
        perms.add(perm);
      } catch (Throwable e) {
        String message =
            String.format(
                "could not instantiate permission: " + "type=%s name=%s actions=",
                type, name, actions);
        throw new PermissionParseException(message, e);
      }
    }

    in.close();

    permSet.addAll(perms);
  }
コード例 #24
0
 private static List<String> loadAccounts(String fileName) {
   List<String> accounts = new ArrayList<String>();
   try {
     Pattern pattern = Pattern.compile("[\\w]{1,16}");
     BufferedReader reader = new BufferedReader(new FileReader(new File(fileName)));
     String line;
     while ((line = reader.readLine()) != null) {
       Matcher matcher = pattern.matcher(line);
       if (!matcher.find()) continue;
       String username = matcher.group();
       if (!matcher.find()) continue;
       String password = matcher.group();
       accounts.add(username + ":" + password);
     }
     reader.close();
   } catch (Exception exception) {
     throw new RuntimeException(exception);
   }
   System.out.println("Loaded " + accounts.size() + " accounts.");
   return accounts;
 }
コード例 #25
0
  void findRemoveDirectives(boolean clean) {
    // if ( clean ) editor.startCompoundEdit();

    Sketch sketch = editor.getSketch();
    for (int i = 0; i < sketch.getCodeCount(); i++) {
      SketchCode code = sketch.getCode(i);
      String program = code.getProgram();
      StringBuffer buffer = new StringBuffer();

      Matcher m = pjsPattern.matcher(program);
      while (m.find()) {
        String mm = m.group();

        // TODO this urgently needs tests ..

        /* remove framing */
        mm = mm.replaceAll("^\\/\\*\\s*@pjs", "").replaceAll("\\s*\\*\\/\\s*$", "");
        /* fix multiline nice formatting */
        mm = mm.replaceAll("[\\s]*([^;\\s\\n\\r]+)[\\s]*,[\\s]*[\\n\\r]+", "$1,");
        /* fix multiline version without semicolons */
        mm = mm.replaceAll("[\\s]*([^;\\s\\n\\r]+)[\\s]*[\\n\\r]+", "$1;");
        mm = mm.replaceAll("\n", " ").replaceAll("\r", " ");

        // System.out.println(mm);

        if (clean) {
          m.appendReplacement(buffer, "");
        } else {
          String[] directives = mm.split(";");
          for (String d : directives) {
            // System.out.println(d);
            parseDirective(d);
          }
        }
      }

      if (clean) {
        m.appendTail(buffer);

        // TODO: not working!
        code.setProgram(buffer.toString());
        code.setModified(true);
      }
    }

    if (clean) {
      // editor.stopCompoundEdit();
      editor.setText(sketch.getCurrentCode().getProgram());
      sketch.setModified(false);
      sketch.setModified(true);
    }
  }
コード例 #26
0
  protected static String getMethodName(Test test) {
    String className;
    String desc = test.toString();
    Matcher matcher = methodpattern.matcher(desc);
    if (matcher.matches()) {
      className = matcher.group(1);

    } else {
      className = desc;
    }

    return className;
  }
コード例 #27
0
ファイル: TextViewHybrid.java プロジェクト: zukov/Jpicedt
  protected void getDimensionsFromLogFile(BufferedReader reader, PicText text) {
    if (reader == null) {
      return;
    }
    String line = ""; // il rale si j'initialise pas ...
    boolean finished = false;
    while (!finished) {
      try {
        line = reader.readLine();
      } catch (IOException ioex) {
        ioex.printStackTrace();
        return;
      }
      if (line == null) {
        System.out.println("Size of text not found in log file...");
        return;
      }

      System.out.println(line);
      Matcher matcher = LogFilePattern.matcher(line);

      if (line != null && matcher.find()) {
        System.out.println("FOUND :" + line);
        finished = true;
        try {
          text.setDimensions(
              0.3515 * Double.parseDouble(matcher.group(1)), // height, pt->mm (1pt=0.3515 mm)
              0.3515 * Double.parseDouble(matcher.group(2)), // width
              0.3515 * Double.parseDouble(matcher.group(3))); // depth
          areDimensionsComputed = true;
        } catch (NumberFormatException e) {
          System.out.println("Logfile number format problem: $line" + e.getMessage());
        } catch (IndexOutOfBoundsException e) {
          System.out.println("Logfile regexp problem: $line" + e.getMessage());
        }
      }
    }
    return;
  }
コード例 #28
0
ファイル: EditorView.java プロジェクト: rostam/basex
  /**
   * Handles info messages resulting from a query execution.
   *
   * @param msg info message
   * @return true if error was found
   */
  private boolean error(final String msg) {
    final String line = msg.replaceAll("[\\r\\n].*", "");
    Matcher m = XQERROR.matcher(line);
    int el, ec = 2;
    if (!m.matches()) {
      m = XMLERROR.matcher(line);
      if (!m.matches()) return true;
      el = Integer.parseInt(m.group(1));
      errFile = getEditor().file.path();
    } else {
      el = Integer.parseInt(m.group(1));
      ec = Integer.parseInt(m.group(2));
      errFile = m.group(3);
    }

    final EditorArea edit = find(IO.get(errFile), false);
    if (edit == null) return true;

    // find approximate error position
    final int ll = edit.last.length;
    int ep = ll;
    for (int e = 1, l = 1, c = 1; e < ll; ++c, e += cl(edit.last, e)) {
      if (l > el || l == el && c == ec) {
        ep = e;
        break;
      }
      if (edit.last[e] == '\n') {
        ++l;
        c = 0;
      }
    }
    if (ep < ll && Character.isLetterOrDigit(cp(edit.last, ep))) {
      while (ep > 0 && Character.isLetterOrDigit(cp(edit.last, ep - 1))) ep--;
    }
    edit.error(ep);
    errPos = ep;
    return true;
  }
コード例 #29
0
 /**
  * Takes a line and looks for an archive group tag. If one is found, the information from the tag
  * is returned as an <CODE>ArchiveGroup</CODE>. If a tag is found, the data in the tag is stored
  * in the <CODE>HashMap</CODE> provided.
  *
  * @param currentLine The line in which to look for the archive tag.
  * @param template The <CODE>Template</CODE> to which the <CODE>ArchiveGroup</CODE> belongs.
  * @return The archive request tag data as an instance of <CODE>ArchiveGroup</CODE>, <CODE>null
  *     </CODE> if the line passed in does not contain an arFile tag.
  */
 private ArchiveGroup parseArchiveGroupTag(String currentLine, Template template) {
   ArchiveGroup archiveTag;
   Matcher currentMatcher = archiveRequestPattern.matcher(currentLine);
   if (currentMatcher.find()) {
     String fileName = currentMatcher.group(1);
     archiveTag = template.getArchiveGroup(fileName);
     if (archiveTag == null) {
       File groupFile = new File(fileName);
       archiveTag = new ArchiveGroup(groupFile.getParent(), groupFile.getName());
       template.addArchiveGroup(archiveTag);
     }
   } else archiveTag = null;
   return archiveTag;
 }
コード例 #30
0
  public JilterStatus header(String headerf, String headerv) {

    logger.debug("jilter header {name='" + headerf + "',value='" + headerv + "'}");
    StringBuffer header = new StringBuffer();
    header.append(headerf);
    header.append(": ");
    header.append(headerv);
    header.append("\n");
    try {
      bos.write(header.toString().getBytes());
    } catch (IOException io) {
      logger.error("jilter failed to write header field", io);
    }
    Matcher m = headerPattern1.matcher(headerf.toLowerCase(Locale.ENGLISH).trim());
    if (m.matches()) {
      logger.debug("jilter found to/bcc/cc header");
      String[] addresses = headerv.split(",");
      for (int i = 0; i < addresses.length; i++) {
        includeBCC = includeBCC | rcpts.remove(addresses[i].toLowerCase(Locale.ENGLISH).trim());
        logger.debug("jilter del recipient {recipient='" + addresses[i] + "'}");
        m = headerPattern2.matcher(addresses[i].toLowerCase(Locale.ENGLISH).trim());
        if (m.matches()) {
          String mailAddress = m.group(1);
          includeBCC = includeBCC | rcpts.remove(mailAddress);
          logger.debug("jilter del recipient {recipient='" + mailAddress + "'}");
        } else {
          m = headerPattern3.matcher(addresses[i].toLowerCase(Locale.ENGLISH).trim());
          if (m.matches()) {
            String mailAddress = m.group(1);
            includeBCC = includeBCC | rcpts.remove(mailAddress);
            logger.debug("jilter del recipient {recipient='" + mailAddress + "'}");
          }
        }
      }
    }
    return JilterStatus.SMFIS_CONTINUE;
  }