X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fswingjs%2Fj2s%2Fjava%2Futil%2Fregex%2FMatcher.js;h=d46c4dbaa83049543d3d39c9a2a3edc8e1fcf9e4;hp=545f37027bc602078185678bfe8ae71def2147de;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/swingjs/j2s/java/util/regex/Matcher.js b/site/swingjs/j2s/java/util/regex/Matcher.js index 545f370..d46c4db 100644 --- a/site/swingjs/j2s/java/util/regex/Matcher.js +++ b/site/swingjs/j2s/java/util/regex/Matcher.js @@ -1,295 +1,295 @@ -Clazz.declarePackage("java.util.regex"); -Clazz.load(["java.util.regex.MatchResult"],"java.util.regex.Matcher",["java.lang.IllegalArgumentException","$.IndexOutOfBoundsException","$.NullPointerException","$.StringBuffer"],function(){ -c$=Clazz.decorateAsClass(function(){ -this.pat=null; -this.string=null; -this.leftBound=-1; -this.rightBound=-1; -this.appendPos=0; -this.replacement=null; -this.processedRepl=null; -this.replacementParts=null; -this.results=null; -Clazz.instantialize(this,arguments); -},java.util.regex,"Matcher",null,java.util.regex.MatchResult); -Clazz.defineMethod(c$,"appendReplacement", -function(sb,replacement){ -this.processedRepl=this.processReplacement(replacement); -sb.append(this.string.subSequence(this.appendPos,this.start())); -sb.append(this.processedRepl); -this.appendPos=this.end(); -return this; -},"StringBuffer,~S"); -Clazz.defineMethod(c$,"processReplacement", -($fz=function(replacement){ -if(this.replacement!=null&&this.replacement.equals(replacement)){ -if(this.replacementParts==null){ -return this.processedRepl; -}else{ -var sb=new StringBuffer(); -for(var i=0;irightBound||leftBound<0||rightBound<0||leftBound>this.string.length()||rightBound>this.string.length()){ -throw new IndexOutOfBoundsException(leftBound+" is out of bound of "+rightBound); -}this.leftBound=leftBound; -this.rightBound=rightBound; -this.results=null; -this.appendPos=0; -this.replacement=null; -return this; -},"~N,~N"); -Clazz.defineMethod(c$,"appendTail", -function(sb){ -return sb.append(this.string.subSequence(this.appendPos,this.string.length())); -},"StringBuffer"); -Clazz.defineMethod(c$,"replaceFirst", -function(replacement){ -this.reset(); -if(this.find()){ -var sb=new StringBuffer(); -this.appendReplacement(sb,replacement); -return this.appendTail(sb).toString(); -}return this.string.toString(); -},"~S"); -Clazz.defineMethod(c$,"replaceAll", -function(replacement){ -var sb=new StringBuffer(); -this.reset(); -while(this.find()){ -this.appendReplacement(sb,replacement); -} -return this.appendTail(sb).toString(); -},"~S"); -Clazz.defineMethod(c$,"pattern", -function(){ -return this.pat; -}); -Clazz.defineMethod(c$,"group", -function(groupIndex){ -if(this.results==null||groupIndex<0||groupIndex>this.results.length){ -return null; -}return this.results[groupIndex]; -},"~N"); -Clazz.defineMethod(c$,"group", -function(){ -return this.group(0); -}); -Clazz.defineMethod(c$,"find", -function(startIndex){ -var stringLength=this.string.length(); -if(startIndex<0||startIndex>stringLength)throw new IndexOutOfBoundsException("Out of bound "+startIndex); -startIndex=this.findAt(startIndex); -return false; -},"~N"); -Clazz.defineMethod(c$,"findAt", -($fz=function(startIndex){ -return-1; -},$fz.isPrivate=true,$fz),"~N"); -Clazz.defineMethod(c$,"find", -function(){ -{ -this.results=this.pat.regexp.exec(this.string.subSequence(this.leftBound,this.rightBound)); -}return(this.results!=null); -}); -Clazz.defineMethod(c$,"start", -function(groupIndex){ -var beginningIndex=0; -{ -beginningIndex=this.pat.regexp.lastIndex; -}beginningIndex-=this.results[0].length; -return beginningIndex; -},"~N"); -Clazz.defineMethod(c$,"end", -function(groupIndex){ -{ -return this.pat.regexp.lastIndex; -}return-1; -},"~N"); -Clazz.defineMethod(c$,"matches", -function(){ -return this.find(); -}); -c$.quoteReplacement=Clazz.defineMethod(c$,"quoteReplacement", -function(string){ -if(string.indexOf('\\') < 0 && string.indexOf ('$')<0)return string; -var res=new StringBuffer(string.length*2); -var ch; -var len=string.length; -for(var i=0;irightBound||leftBound<0||rightBound<0||leftBound>this.string.length()||rightBound>this.string.length()){ +throw new IndexOutOfBoundsException(leftBound+" is out of bound of "+rightBound); +}this.leftBound=leftBound; +this.rightBound=rightBound; +this.results=null; +this.appendPos=0; +this.replacement=null; +return this; +},"~N,~N"); +Clazz.defineMethod(c$,"appendTail", +function(sb){ +return sb.append(this.string.subSequence(this.appendPos,this.string.length())); +},"StringBuffer"); +Clazz.defineMethod(c$,"replaceFirst", +function(replacement){ +this.reset(); +if(this.find()){ +var sb=new StringBuffer(); +this.appendReplacement(sb,replacement); +return this.appendTail(sb).toString(); +}return this.string.toString(); +},"~S"); +Clazz.defineMethod(c$,"replaceAll", +function(replacement){ +var sb=new StringBuffer(); +this.reset(); +while(this.find()){ +this.appendReplacement(sb,replacement); +} +return this.appendTail(sb).toString(); +},"~S"); +Clazz.defineMethod(c$,"pattern", +function(){ +return this.pat; +}); +Clazz.defineMethod(c$,"group", +function(groupIndex){ +if(this.results==null||groupIndex<0||groupIndex>this.results.length){ +return null; +}return this.results[groupIndex]; +},"~N"); +Clazz.defineMethod(c$,"group", +function(){ +return this.group(0); +}); +Clazz.defineMethod(c$,"find", +function(startIndex){ +var stringLength=this.string.length(); +if(startIndex<0||startIndex>stringLength)throw new IndexOutOfBoundsException("Out of bound "+startIndex); +startIndex=this.findAt(startIndex); +return false; +},"~N"); +Clazz.defineMethod(c$,"findAt", +($fz=function(startIndex){ +return-1; +},$fz.isPrivate=true,$fz),"~N"); +Clazz.defineMethod(c$,"find", +function(){ +{ +this.results=this.pat.regexp.exec(this.string.subSequence(this.leftBound,this.rightBound)); +}return(this.results!=null); +}); +Clazz.defineMethod(c$,"start", +function(groupIndex){ +var beginningIndex=0; +{ +beginningIndex=this.pat.regexp.lastIndex; +}beginningIndex-=this.results[0].length; +return beginningIndex; +},"~N"); +Clazz.defineMethod(c$,"end", +function(groupIndex){ +{ +return this.pat.regexp.lastIndex; +}return-1; +},"~N"); +Clazz.defineMethod(c$,"matches", +function(){ +return this.find(); +}); +c$.quoteReplacement=Clazz.defineMethod(c$,"quoteReplacement", +function(string){ +if(string.indexOf('\\') < 0 && string.indexOf ('$')<0)return string; +var res=new StringBuffer(string.length*2); +var ch; +var len=string.length; +for(var i=0;i