|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.xerces.internal.impl.xs; |
|
|
|
import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo; |
|
import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl; |
|
import com.sun.org.apache.xerces.internal.xs.AttributePSVI; |
|
import com.sun.org.apache.xerces.internal.xs.ItemPSVI; |
|
import com.sun.org.apache.xerces.internal.xs.ShortList; |
|
import com.sun.org.apache.xerces.internal.xs.StringList; |
|
import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration; |
|
import com.sun.org.apache.xerces.internal.xs.XSConstants; |
|
import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition; |
|
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; |
|
import com.sun.org.apache.xerces.internal.xs.XSValue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public class AttributePSVImpl implements AttributePSVI { |
|
|
|
|
|
protected XSAttributeDeclaration fDeclaration = null; |
|
|
|
|
|
protected XSTypeDefinition fTypeDecl = null; |
|
|
|
|
|
* value in the original document, this is false; otherwise, it is true */ |
|
protected boolean fSpecified = false; |
|
|
|
|
|
protected ValidatedInfo fValue = new ValidatedInfo(); |
|
|
|
|
|
protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE; |
|
|
|
|
|
protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN; |
|
|
|
|
|
protected String[] fErrors = null; |
|
|
|
|
|
protected String fValidationContext = null; |
|
|
|
|
|
protected boolean fIsConstant; |
|
|
|
public AttributePSVImpl() {} |
|
|
|
public AttributePSVImpl(boolean isConstant, AttributePSVI attrPSVI) { |
|
fDeclaration = attrPSVI.getAttributeDeclaration(); |
|
fTypeDecl = attrPSVI.getTypeDefinition(); |
|
fSpecified = attrPSVI.getIsSchemaSpecified(); |
|
fValue.copyFrom(attrPSVI.getSchemaValue()); |
|
fValidationAttempted = attrPSVI.getValidationAttempted(); |
|
fValidity = attrPSVI.getValidity(); |
|
if (attrPSVI instanceof AttributePSVImpl) { |
|
final AttributePSVImpl attrPSVIImpl = (AttributePSVImpl) attrPSVI; |
|
fErrors = (attrPSVIImpl.fErrors != null) ? attrPSVIImpl.fErrors.clone() : null; |
|
} |
|
else { |
|
final StringList errorCodes = attrPSVI.getErrorCodes(); |
|
final int length = errorCodes.getLength(); |
|
if (length > 0) { |
|
final StringList errorMessages = attrPSVI.getErrorMessages(); |
|
final String[] errors = new String[length << 1]; |
|
for (int i = 0, j = 0; i < length; ++i) { |
|
errors[j++] = errorCodes.item(i); |
|
errors[j++] = errorMessages.item(i); |
|
} |
|
fErrors = errors; |
|
} |
|
} |
|
fValidationContext = attrPSVI.getValidationContext(); |
|
fIsConstant = isConstant; |
|
} |
|
|
|
// |
|
// AttributePSVI methods |
|
// |
|
|
|
|
|
|
|
*/ |
|
public ItemPSVI constant() { |
|
if (isConstant()) { |
|
return this; |
|
} |
|
return new AttributePSVImpl(true, this); |
|
} |
|
|
|
|
|
|
|
*/ |
|
public boolean isConstant() { |
|
return fIsConstant; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
@SuppressWarnings("deprecation") |
|
public String getSchemaDefault() { |
|
return fDeclaration == null ? null : fDeclaration.getConstraintValue(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public String getSchemaNormalizedValue() { |
|
return fValue.getNormalizedValue(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean getIsSchemaSpecified() { |
|
return fSpecified; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public short getValidationAttempted() { |
|
return fValidationAttempted; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public short getValidity() { |
|
return fValidity; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public StringList getErrorCodes() { |
|
if (fErrors == null || fErrors.length == 0) { |
|
return StringListImpl.EMPTY_LIST; |
|
} |
|
return new PSVIErrorList(fErrors, true); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public StringList getErrorMessages() { |
|
if (fErrors == null || fErrors.length == 0) { |
|
return StringListImpl.EMPTY_LIST; |
|
} |
|
return new PSVIErrorList(fErrors, false); |
|
} |
|
|
|
|
|
public String getValidationContext() { |
|
return fValidationContext; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XSTypeDefinition getTypeDefinition() { |
|
return fTypeDecl; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XSSimpleTypeDefinition getMemberTypeDefinition() { |
|
return fValue.getMemberTypeDefinition(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XSAttributeDeclaration getAttributeDeclaration() { |
|
return fDeclaration; |
|
} |
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public Object getActualNormalizedValue() { |
|
return fValue.getActualValue(); |
|
} |
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public short getActualNormalizedValueType() { |
|
return fValue.getActualValueType(); |
|
} |
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public ShortList getItemValueTypes() { |
|
return fValue.getListValueTypes(); |
|
} |
|
|
|
|
|
|
|
*/ |
|
public XSValue getSchemaValue() { |
|
return fValue; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public void reset() { |
|
fValue.reset(); |
|
fDeclaration = null; |
|
fTypeDecl = null; |
|
fSpecified = false; |
|
fValidationAttempted = AttributePSVI.VALIDATION_NONE; |
|
fValidity = AttributePSVI.VALIDITY_NOTKNOWN; |
|
fErrors = null; |
|
fValidationContext = null; |
|
} |
|
} |