| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 114 | 2 | 1 | 0.996 | ExpressionStatement |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 114 | 660 | Closure/closure/goog/i18n/numberformat.js |
| 2 | 114 | 632 | Closure/closure/goog/locale/numberformat.js |
| ||||
/**
* Parses the trunk part of a pattern.
*
* @param {string} pattern Pattern string that need to be parsed.
* @param {Array.<number>} pos One element position array to set and receive
* parsing position.
* @private
*/
goog.i18n.NumberFormat.prototype.parseTrunk_= function (pattern, pos){
var decimalPos= -1;
var digitLeftCount= 0;
var zeroDigitCount= 0;
var digitRightCount= 0;
var groupingCount= -1;
var len= pattern.length;
for (var loop= true; pos[0]< len
&& loop; pos[0]++) {
var ch= pattern.charAt(pos[0]);
switch (ch)
{ case goog.i18n.NumberFormat.PATTERN_DIGIT_:
if (zeroDigitCount> 0) {
digitRightCount++;
}
else {
digitLeftCount++;
}
if (groupingCount>= 0
&& decimalPos< 0) {
groupingCount++;
}
break;
case goog.i18n.NumberFormat.PATTERN_ZERO_DIGIT_:
if (digitRightCount> 0) {
throw Error('Unexpected "0" in pattern "'+ pattern+ '"');
}
zeroDigitCount++;
if (groupingCount>= 0
&& decimalPos< 0) {
groupingCount++;
}
break;
case goog.i18n.NumberFormat.PATTERN_GROUPING_SEPARATOR_:
groupingCount= 0;
break;
case goog.i18n.NumberFormat.PATTERN_DECIMAL_SEPARATOR_:
if (decimalPos>= 0) {
throw Error('Multiple decimal separators in pattern "'+
pattern+ '"');
}
decimalPos= digitLeftCount+ zeroDigitCount+ digitRightCount;
break;
case goog.i18n.NumberFormat.PATTERN_EXPONENT_:
if (this.useExponentialNotation_) {
throw Error('Multiple exponential symbols in pattern "'+
pattern+ '"');
}
this.useExponentialNotation_= true;
this.minExponentDigits_= 0;
// Use lookahead to parse out the exponential part
// of the pattern, then jump into phase 2.
while ((pos[0]+ 1)< len
&& pattern.charAt(pos[0]+ 1)==
goog.i18n.NumberFormat.PATTERN_ZERO_DIGIT_) {
pos[0]++;
this.minExponentDigits_++;
}
if ((digitLeftCount+ zeroDigitCount)< 1
||this.minExponentDigits_< 1)
{
throw Error('Malformed exponential pattern "'+ pattern+ '"');
}
loop= false;
break;
default:
pos[0]--;
loop= false;
break; }
}
if (zeroDigitCount== 0
&& digitLeftCount> 0
&& decimalPos>= 0) {
// Handle '###.###' and '###.' and '.###'
var n= decimalPos;
if (n== 0) { // Handle '.###'
n++;
}
digitRightCount= digitLeftCount- n;
digitLeftCount= n- 1;
zeroDigitCount= 1;
}
// Do syntax checking on the digits.
if (decimalPos< 0
&& digitRightCount> 0
||decimalPos>= 0
&& (decimalPos< digitLeftCount
||decimalPos> digitLeftCount+ zeroDigitCount)
||groupingCount== 0){
throw Error('Malformed pattern "'+ pattern+ '"');
}
var totalDigits= digitLeftCount+ zeroDigitCount+ digitRightCount;
this.maximumFractionDigits_= decimalPos>= 0
? totalDigits- decimalPos
: 0;
if (decimalPos>= 0) {
this.minimumFractionDigits_= digitLeftCount+ zeroDigitCount- decimalPos;
if (this.minimumFractionDigits_< 0) {
this.minimumFractionDigits_= 0;
}
}
// The effectiveDecimalPos is the position the decimal is at or would be at
// if there is no decimal. Note that if decimalPos<0, then digitTotalCount ==
// digitLeftCount + zeroDigitCount.
var effectiveDecimalPos= decimalPos>= 0
? decimalPos
: totalDigits;
this.minimumIntegerDigits_= effectiveDecimalPos- digitLeftCount;
if (this.useExponentialNotation_) {
this.maximumIntegerDigits_= digitLeftCount+ this.minimumIntegerDigits_;
// in exponential display, we need to at least show something.
if (this.maximumFractionDigits_== 0
&& this.minimumIntegerDigits_== 0) {
this.minimumIntegerDigits_= 1;
}
}
this.groupingSize_= Math.max(0, groupingCount);
this.decimalSeparatorAlwaysShown_= decimalPos== 0
||decimalPos== totalDigits;
} ;
|
| ||||
/**
* Parses the trunk part of a pattern.
*
* @param {string} pattern Pattern string that need to be parsed.
* @param {Array} pos One element position array to set and receive parsing
* position.
* @private
*/
goog.locale.NumberFormat.prototype.parseTrunk_= function (pattern, pos){
var decimalPos= -1;
var digitLeftCount= 0;
var zeroDigitCount= 0;
var digitRightCount= 0;
var groupingCount= -1;
var len= pattern.length;
for (var loop= true; pos[0]< len
&& loop; pos[0]++) {
var ch= pattern.charAt(pos[0]);
switch (ch)
{ case goog.locale.NumberFormat.PATTERN_DIGIT_:
if (zeroDigitCount> 0) {
digitRightCount++;
}
else {
digitLeftCount++;
}
if (groupingCount>= 0
&& decimalPos< 0) {
groupingCount++;
}
break;
case goog.locale.NumberFormat.PATTERN_ZERO_DIGIT_:
if (digitRightCount> 0) {
throw Error('Unexpected "0" in pattern "'+ pattern+ '"');
}
zeroDigitCount++;
if (groupingCount>= 0
&& decimalPos< 0) {
groupingCount++;
}
break;
case goog.locale.NumberFormat.PATTERN_GROUPING_SEPARATOR_:
groupingCount= 0;
break;
case goog.locale.NumberFormat.PATTERN_DECIMAL_SEPARATOR_:
if (decimalPos>= 0) {
throw Error('Multiple decimal separators in pattern "'+
pattern+ '"');
}
decimalPos= digitLeftCount+ zeroDigitCount+ digitRightCount;
break;
case goog.locale.NumberFormat.PATTERN_EXPONENT_:
if (this.useExponentialNotation_) {
throw Error('Multiple exponential symbols in pattern "'+
pattern+ '"');
}
this.useExponentialNotation_= true;
this.minExponentDigits_= 0;
// Use lookahead to parse out the exponential part
// of the pattern, then jump into phase 2.
while ((pos[0]+ 1)< len
&& pattern.charAt(pos[0]+ 1)==
goog.locale.NumberFormat.PATTERN_ZERO_DIGIT_) {
pos[0]++;
this.minExponentDigits_++;
}
if ((digitLeftCount+ zeroDigitCount)< 1
||this.minExponentDigits_< 1)
{
throw Error('Malformed exponential pattern "'+ pattern+ '"');
}
loop= false;
break;
default:
pos[0]--;
loop= false;
break; }
}
if (zeroDigitCount== 0
&& digitLeftCount> 0
&& decimalPos>= 0) {
// Handle '###.###' and '###.' and '.###'
var n= decimalPos;
if (n== 0) { // Handle '.###'
n++;
}
digitRightCount= digitLeftCount- n;
digitLeftCount= n- 1;
zeroDigitCount= 1;
}
// Do syntax checking on the digits.
if (decimalPos< 0
&& digitRightCount> 0
||decimalPos>= 0
&& (decimalPos< digitLeftCount
||decimalPos> digitLeftCount+ zeroDigitCount)
||groupingCount== 0){
throw Error('Malformed pattern "'+ pattern+ '"');
}
var totalDigits= digitLeftCount+ zeroDigitCount+ digitRightCount;
this.maximumFractionDigits_= decimalPos>= 0
? totalDigits- decimalPos
: 0;
if (decimalPos>= 0) {
this.minimumFractionDigits_= digitLeftCount+ zeroDigitCount- decimalPos;
if (this.minimumFractionDigits_< 0) {
this.minimumFractionDigits_= 0;
}
}
// The effectiveDecimalPos is the position the decimal is at or would be at
// if there is no decimal. Note that if decimalPos<0, then digitTotalCount ==
// digitLeftCount + zeroDigitCount.
var effectiveDecimalPos= decimalPos>= 0
? decimalPos
: totalDigits;
this.minimumIntegerDigits_= effectiveDecimalPos- digitLeftCount;
if (this.useExponentialNotation_) {
this.maximumIntegerDigits_= digitLeftCount+ this.minimumIntegerDigits_;
// in exponential display, we need to at least show something.
if (this.maximumFractionDigits_== 0
&& this.minimumIntegerDigits_== 0) {
this.minimumIntegerDigits_= 1;
}
}
this.groupingSize_= Math.max(0, groupingCount);
this.decimalSeparatorAlwaysShown_= decimalPos== 0
||decimalPos== totalDigits;
} ;
|
| |||
/**
* Parses the trunk part of a pattern.
*
* @param {string} pattern Pattern string that need to be parsed.
* @param {Array.<number>} pos One element position array to set and receive
* parsing position.
* @private
*/
/**
* Parses the trunk part of a pattern.
*
* @param {string} pattern Pattern string that need to be parsed.
* @param {Array} pos One element position array to set and receive parsing
* position.
* @private
*/
goog. [[#variable57348a20]].NumberFormat.prototype.parseTrunk_= function (pattern,pos)
{ var decimalPos=-1;
var digitLeftCount=0;
var zeroDigitCount=0;
var digitRightCount=0;
var groupingCount=-1;
var len=pattern.length;
for (var loop= true; pos[0]<len
&& loop; pos[0]++)
{ var ch=pattern.charAt(pos[0]);
switch (ch)
{ case goog. [[#variable57348a20]].NumberFormat.PATTERN_DIGIT_:
if (zeroDigitCount>0)
{ digitRightCount++;
}
else
{ digitLeftCount++;
}
if (groupingCount>=0
&& decimalPos<0)
{ groupingCount++;
}
break;
case goog. [[#variable57348a20]].NumberFormat.PATTERN_ZERO_DIGIT_:
if (digitRightCount>0)
{ throw Error('Unexpected "0" in pattern "'+pattern+'"');
}
zeroDigitCount++;
if (groupingCount>=0
&& decimalPos<0)
{ groupingCount++;
}
break;
case goog. [[#variable57348a20]].NumberFormat.PATTERN_GROUPING_SEPARATOR_:
groupingCount=0;
break;
case goog. [[#variable57348a20]].NumberFormat.PATTERN_DECIMAL_SEPARATOR_:
if (decimalPos>=0)
{ throw Error('Multiple decimal separators in pattern "'+pattern+'"');
}
decimalPos=digitLeftCount+zeroDigitCount+digitRightCount;
break;
case goog. [[#variable57348a20]].NumberFormat.PATTERN_EXPONENT_:
if (this.useExponentialNotation_)
{ throw Error('Multiple exponential symbols in pattern "'+pattern+'"');
}
this.useExponentialNotation_= true;
this.minExponentDigits_=0;
// Use lookahead to parse out the exponential part
// of the pattern, then jump into phase 2.
while ((pos[0]+1)<len
&& pattern.charAt(pos[0]+1)==goog. [[#variable57348a20]].NumberFormat.PATTERN_ZERO_DIGIT_)
{ pos[0]++;
this.minExponentDigits_++;
}
if ((digitLeftCount+zeroDigitCount)<1
|| this.minExponentDigits_<1)
{ throw Error('Malformed exponential pattern "'+pattern+'"');
}
loop= false;
break;
default:
pos[0]--;
loop= false;
break; }
}
if (zeroDigitCount==0
&& digitLeftCount>0
&& decimalPos>=0)
{
// Handle '###.###' and '###.' and '.###'
var n=decimalPos;
if (n==0)
{ // Handle '.###'
n++;
}
digitRightCount=digitLeftCount-n;
digitLeftCount=n-1;
zeroDigitCount=1;
}
// Do syntax checking on the digits.
if (decimalPos<0
&& digitRightCount>0
|| decimalPos>=0
&& (decimalPos<digitLeftCount
|| decimalPos>digitLeftCount+zeroDigitCount)
|| groupingCount==0)
{ throw Error('Malformed pattern "'+pattern+'"');
}
var totalDigits=digitLeftCount+zeroDigitCount+digitRightCount;
this.maximumFractionDigits_=decimalPos>=0
?totalDigits-decimalPos
: 0;
if (decimalPos>=0)
{ this.minimumFractionDigits_=digitLeftCount+zeroDigitCount-decimalPos;
if (this.minimumFractionDigits_<0)
{ this.minimumFractionDigits_=0;
}
}
// The effectiveDecimalPos is the position the decimal is at or would be at
// if there is no decimal. Note that if decimalPos<0, then digitTotalCount ==
// digitLeftCount + zeroDigitCount.
var effectiveDecimalPos=decimalPos>=0
?decimalPos
:totalDigits;
this.minimumIntegerDigits_=effectiveDecimalPos-digitLeftCount;
if (this.useExponentialNotation_)
{ this.maximumIntegerDigits_=digitLeftCount+this.minimumIntegerDigits_;
// in exponential display, we need to at least show something.
if (this.maximumFractionDigits_==0
&& this.minimumIntegerDigits_==0)
{ this.minimumIntegerDigits_=1;
}
}
this.groupingSize_=Math.max(0,groupingCount);
this.decimalSeparatorAlwaysShown_=decimalPos==0
|| decimalPos==totalDigits;
} ;
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#57348a20]] | i18n |
| 1 | 2 | [[#57348a20]] | locale |