Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5112cca0391a6e50f39982ad94f31b711cb8d535 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Created on Nov 30, 2009
 *
 * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
 */
package org.eclipse.osee.framework.branch.management.exchange.transform;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.osee.framework.jdk.core.text.Rule;
import org.eclipse.osee.framework.jdk.core.text.change.ChangeSet;
import org.eclipse.osee.framework.jdk.core.util.GUID;

public class V0_8_3_BranchRule extends Rule {
   private static final Pattern branchPattern = Pattern.compile("<entry ()branch_type");

   public V0_8_3_BranchRule() {
      super(null);
   }

   @Override
   public ChangeSet computeChanges(CharSequence seq) {
      ChangeSet changeSet = new ChangeSet(seq);

      Matcher branchMatcher = branchPattern.matcher(seq);
      while (branchMatcher.find()) {
         changeSet.insertBefore(branchMatcher.end(1), "branch_guid=\"" + GUID.create() + "\" branch_state=\"2\" ");
         ruleWasApplicable = true;
      }

      return changeSet;
   }
}

Back to the top