/*
Parse a viewBox attribute.
197542
private static Box  parseViewBox(String val) throws SVGParseException
   {
      TextScanner scan = new TextScanner(val);
      scan.skipWhitespace();

      float minX = scan.nextFloat();
      scan.skipCommaWhitespace();
      float minY = scan.nextFloat();
      scan.skipCommaWhitespace();
      float width = scan.nextFloat();
      scan.skipCommaWhitespace();
      float height = scan.nextFloat();

      if (Float.isNaN(minX) || Float.isNaN(minY) || Float.isNaN(width) || Float.isNaN(height))
         throw new SVGParseException("Invalid viewBox definition - should have four numbers");
      if (width < 0)
         throw new SVGParseException("Invalid viewBox. width cannot be negative");
      if (height < 0)
         throw new SVGParseException("Invalid viewBox. height cannot be negative");

      return new SVG.Box(minX, minY, width, height);
   }
445231
function convertViewportValue(value) {
            var mask = /^(\d+)x(\d+)$/,
                matches;
            if (isString(value) && mask.test(value)) {
                matches = value.match(mask);
                return {
                    width: toInteger(matches[1]),
                    height: toInteger(matches[2])
                };
            } else if (isRegularObject(value) &&
                value.hasOwnProperty("width") && (value.width >= 1) &&
                value.hasOwnProperty("height") && (value.height >= 1)
            ) {
                return {
                    width: toInteger(value.width),
                    height: toInteger(value.height)
                };
            } else {
                return undefined;
            }
        }
1258787
function dotOperatorAttributeRead (attributeName, obj) {
      var attr

      if (obj) attr = obj[attributeName]

      if (typeof attr === 'function') return attr.bind(obj)

      return attr
    }
98744
function parseViewValue(value) {
                if (angular.isUndefined(value)) {
                    value = '';
                }
                value = (""+value).replace(decimalSeparator, '.');

                // Handle leading decimal point, like ".5"
                if (value.indexOf('.') === 0) {
                    value = '0' + value;
                }

                // Allow "-" inputs only when min < 0
                if (value.indexOf('-') === 0) {
                    if (min >= 0) {
                        value = null;
                        ngModelCtrl.$setViewValue(formatViewValue(lastValidValue));
                        ngModelCtrl.$render();
                    }
                    else if (value === '-') {
                        value = '';
                    }
                }

                var empty = ngModelCtrl.$isEmpty(value);
                if (empty) {
                    lastValidValue = '';
                    //ngModelCtrl.$modelValue = undefined;
                } 
                else {
                    if (regex.test(value) && (value.length <= maxInputLength)) {
                        if ((value > max) && limitMax) {
                            lastValidValue = max;
                        }
                        else if ((value < min) && limitMin) {
                            lastValidValue = min;
                        }
                        else {
                            lastValidValue = (value === '') ? null : parseFloat(value);
                        }
                    }
                    else {
                        // Render the last valid input in the field
                        ngModelCtrl.$setViewValue(formatViewValue(lastValidValue));
                        ngModelCtrl.$render();
                    }
                }

                return lastValidValue;
            }
1034830
function expandViewAttribValue( value ) {
    try {
        if ( isSpecial( value ) || Array.isArray( value[ 0 ] ) ) return value;
        if ( Array.isArray( value ) ) return {
            "0": value,
            "1": value[ 0 ]
        };
        return { "0": value };
    } catch ( ex ) {
        throw ex + "\n...in expandViewAttribValue: " + limitJson( value );
    }
}
520376
public static final Box getBox(View v)
    {
        if (v instanceof CSSBoxView) return getBox((CSSBoxView) v);

        AttributeSet attr = v.getAttributes();
        if (attr == null)
        {
            throw new NullPointerException("AttributeSet of " + v.getClass().getName() + "@"
                                + Integer.toHexString(v.hashCode()) + " is set to NULL.");
        }
        Object obj = attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
        if (obj != null && obj instanceof Box)
        {
            return (Box) obj;
        }
        else
        {
            throw new IllegalArgumentException("Box reference in attributes is not an instance of a Box.");
        }

    }
500919
def _parseAttrVal(self, attrStr):
        
        m = self.SPLIT_ATTR_RE.match(attrStr)
        if m is None:
            raise GFF3Exception(
                "can't parse attribute/value: '" + attrStr +
                "'", self.fileName, self.lineNumber)
        name = urllib.unquote(m.group(1))
        val = m.group(2)
        # Split by comma to separate then unquote.
        # Commas in values must be url encoded.
        return name, [urllib.unquote(v) for v in val.split(',')]
639892
private void  parseAttributesStyle(SvgElementBase obj, Attributes attributes) throws SVGParseException
   {
      for (int i=0; i<attributes.getLength(); i++)
      {
         String  val = attributes.getValue(i).trim();
         if (val.length() == 0) {  // Empty attribute. Ignore it.
            continue;
         }
         //boolean  inherit = val.equals("inherit");   // NYI

         switch (SVGAttr.fromString(attributes.getLocalName(i)))
         {
            case style:
               parseStyle(obj, val);
               break;

            case CLASS:
               obj.classNames = CSSParser.parseClassAttribute(val);
               break;

            default:
               if (obj.baseStyle == null)
                  obj.baseStyle = new Style();
               processStyleProperty(obj.baseStyle, attributes.getLocalName(i), attributes.getValue(i).trim());
               break;
         }
      }
   }
68128
private Object parseAttributeValue(XAttribute xAttribute) {
		String attributeString = xAttribute.toString();

		// TODO better solution?

		// All numeric values as double
		try {
			double a = Double.parseDouble(attributeString);
			return a;
		} catch (NumberFormatException e) {
			// Ignore
		}
		// Boolean
		if (attributeString.trim().toLowerCase().equals("true"))
			return true;
		if (attributeString.trim().toLowerCase().equals("false"))
			return false;
		// String
		return attributeString;
	}
182246
private String processViewPropertySvgReference(final String viewProperty) throws IOException {
        // find start of value
        int indexOfColon = viewProperty.indexOf(':');
        if (indexOfColon > -1) {
            int indexOfValueStart = -1;
            int indexOfSQ = viewProperty.indexOf('\'',
                                                 indexOfColon + 1);
            int indexOfDQ = viewProperty.indexOf('"',
                                                 indexOfColon + 1);
            if (indexOfSQ > -1) {
                indexOfValueStart = indexOfSQ;
            } else {
                indexOfValueStart = indexOfDQ;
            }
            if (indexOfValueStart > -1) {
                String viewValue = viewProperty.substring(indexOfValueStart + 1);

                // find end of value
                int indexOfValueEnd = -1;
                indexOfSQ = viewValue.lastIndexOf('\'');
                indexOfDQ = viewValue.lastIndexOf('"');
                if (indexOfSQ > -1) {
                    indexOfValueEnd = indexOfSQ;
                } else {
                    indexOfValueEnd = indexOfDQ;
                }
                if (indexOfValueEnd > -1) {
                    viewValue = viewValue.substring(0,
                                                    indexOfValueEnd);
                    if (viewValue.endsWith(SVG_FILE_SUFFIX)) {
                        // read svg file
                        String svgContents = getReferencedSvgFileContents(viewValue);
                        if (svgContents != null) {
                            String ignorableViewProperty = viewProperty.replace("\"view\"",
                                                                                "\"_view_file\"");
                            StringBuilder newViewProperty = new StringBuilder(ignorableViewProperty).append(LINE_SEPARATOR);
                            newViewProperty.append(viewProperty.substring(0,
                                                                          indexOfValueStart));
                            newViewProperty.append("\"").append(svgContents).append("\",").append(LINE_SEPARATOR);
                            return newViewProperty.toString();
                        }
                    }
                }
            }
        }

        // property not changed, return original property
        return viewProperty + LINE_SEPARATOR;
    }
51260
function parseAd(adElement) {
  var childNodes = adElement.childNodes;

  for (var adTypeElementKey in childNodes) {
    var adTypeElement = childNodes[adTypeElementKey];

    if (['Wrapper', 'InLine'].indexOf(adTypeElement.nodeName) === -1) {
      continue;
    }

    parserUtils.copyNodeAttribute('id', adElement, adTypeElement);
    parserUtils.copyNodeAttribute('sequence', adElement, adTypeElement);

    if (adTypeElement.nodeName === 'Wrapper') {
      return parseWrapper(adTypeElement);
    } else if (adTypeElement.nodeName === 'InLine') {
      return parseInLine(adTypeElement);
    }
  }
}
302889
function parseFont (str) {
	str = str.trim();
	var str_o = str;
	var idx = 0;

	var style = rFontStyle.exec(str);
	style = getValue(style);
	str = str.replace(style, '').trim();

	var variant = rFontVariant.exec(str);
	variant = getValue(variant);
	str = str.replace(variant, '').trim();

	var weight = rFontWeight.exec(str);
	weight = getValue(weight);
	str = str.replace(weight, '').trim();

	var size = rFontSize.exec(str);
	// console.log('size', size);
	size = getValue(size);
	str = str.replace(size, '').trim();

	var lineHeight = rFontLineHeight.exec(str);
	lineHeight = getValue(lineHeight);
	str = str.replace(lineHeight, '').trim();
	lineHeight = lineHeight.slice(1);

	var fontFamily = str.trim();

	return {
		style: style,
		variant: variant,
		weight: weight,
		size: size,
		lineHeight: lineHeight,
		fontFamily: fontFamily,
		string: str_o
	};
}
20063
function _parseAttr(val, isClick) {
        try {
            if (isClick) {
                /*jshint evil: true */
                var fn = Function(val);

                return fn ? fn() : {};
            }

            return JSON.parse(val);
        } catch (err) {
            return undefined;
        }
    }
629665
function parseCSSSelector(selector) {
    const match = SELECTOR_RE.exec(selector);
    if (!match) {
        throw new Error("Unsupported or invalid CSS selector: " + selector);
    }
    const res = { nodeName: match[1].trim() };
    if (match[2]) {
        const attr = [match[2]];
        if (match[3]) { attr.push(match[3]); }
        // Decode the attribute value
        if(match[4]) {
            attr.push(match[4].replace(/\\([nrtf"\\])/g, function(_, k) {
                return valueDecodeTable[k];
            }));
        }
        res.attributes = [attr];
    }
    return res;
}
996173
private void parseAttributes(TypedArray a) {
    // We transform the default values from DIP to pixels
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
    rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
    circleRadius =
        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);

    circleRadius =
        (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);

    fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);

    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);

    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);

    float baseSpinSpeed =
        a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
    spinSpeed = baseSpinSpeed * 360;

    barSpinCycleTime =
        a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);

    barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);

    rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);

    linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);

    if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
      spin();
    }

    // Recycle
    a.recycle();
  }
1283003
public function getViewBox()
    {
        $attr = $this->getAttribute('viewBox');
        if (empty($attr)) {
            return null;
        }

        $result = preg_split('/[\s,]+/', $attr);
        if (count($result) !== 4) {
            return null;
        }

        return array_map('floatval', $result);
    }
455127
private static ViewType parseType(JsonNode node) throws UnknownViewTypeException {
		if (node.hasNonNull("type")) {
			try {
				return ViewType.valueOf(node.get("type").asText().toUpperCase(Locale.ENGLISH));
			} catch (IllegalArgumentException e) {
				throw new UnknownViewTypeException(node.get("type").asText());
			}
		} else {
			throw new UnknownViewTypeException("missing type");
		}
	}