public void append(ValueStoreBase newVal) { for (int i = 0; i < newVal.fValues.size(); i++) { fValues.addElement(newVal.fValues.elementAt(i)); // REVISIT: addValueType(newVal.getValueTypeAt(i)); addItemValueType(newVal.getItemValueTypeAt(i)); } } // append(ValueStoreBase)
/** endElement(): merges contents of fGlobalIDConstraintMap with the * top of fGlobalMapStack into fGlobalIDConstraintMap. */ public void endElement() { if (fGlobalMapStack.isEmpty()) { return; // must be an invalid doc! } HashMap oldMap = (HashMap) fGlobalMapStack.pop(); // return if there is no element if (oldMap == null) { return; } Iterator entries = oldMap.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry) entries.next(); IdentityConstraint id = (IdentityConstraint) entry.getKey(); ValueStoreBase oldVal = (ValueStoreBase) entry.getValue(); if (oldVal != null) { ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id); if (currVal == null) { fGlobalIDConstraintMap.put(id, oldVal); } else if (currVal != oldVal) { currVal.append(oldVal); } } } } // endElement()
/** Check identity constraints. */ public void endDocument() { int count = fValueStores.size(); for (int i = 0; i < count; i++) { ValueStoreBase valueStore = (ValueStoreBase) fValueStores.get(i); valueStore.endDocument(); } } // endDocument()
fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth()); if (values != null) { values.endDocumentFragment(); // nothing to do if nothing matched
LOOP: for (int i = 0; i < size1; ++i) { final Object value1 = values.elementAt(i); final short valueType1 = vsb.getValueTypeAt(i); final ShortList typeList1 = isListType(valueType1) ? vsb.getItemValueTypeAt(i) : null; for (int j=0; j < fValues.size(); ++j) { final Object value2 = fValues.elementAt(j); final short valueType2 = getValueTypeAt(j); final ShortList typeList2 = isListType(valueType2) ? getItemValueTypeAt(j) : null; if (EqualityHelper.isEqual(value1, value2, valueType1, valueType2, typeList1, typeList2, fSchemaVersion)) { continue LOOP; final Object value1 = values.elementAt(i+k); final Object value2 = fValues.elementAt(j+k); final short valueType1 = vsb.getValueTypeAt(i+k); final short valueType2 = getValueTypeAt(j+k); final ShortList typeList1 = isListType(valueType1) ? vsb.getItemValueTypeAt(i+k) : null; final ShortList typeList2 = isListType(valueType2) ? getItemValueTypeAt(j+k) : null;
fLocalItemValueTypes[i] = itemValueType; if (fValuesCount == fFieldCount) { checkDuplicateValues(); addValueType(fLocalValueTypes[i]); addItemValueType(fLocalItemValueTypes[i]);
/** * Returns true if this value store contains the locally scoped value stores */ public boolean contains() { // REVISIT: we can improve performance by using hash codes, instead of // traversing global vector that could be quite large. int next = 0; final int size = fValues.size(); LOOP : for (int i = 0; i < size; i = next) { next = i + fFieldCount; for (int j = 0; j < fFieldCount; j++) { final Object value1 = fLocalValues[j]; final Object value2 = fValues.elementAt(i); final short valueType1 = fLocalValueTypes[j]; final short valueType2 = getValueTypeAt(i); final ShortList typeList1 = isListType(valueType1) ? fLocalItemValueTypes[j] : null; final ShortList typeList2 = isListType(valueType2) ? getItemValueTypeAt(i) : null; if (!EqualityHelper.isEqual(value1, value2, valueType1, valueType2, typeList1, typeList2, fSchemaVersion)) { continue LOOP; } i++; } // found it return true; } // didn't find it return false; } // contains():boolean
public void endDocumentFragment() { // do all the necessary management... super.endDocumentFragment(); // verify references // get the key store corresponding (if it exists): fKeyValueStore = (ValueStoreBase) fValueStoreCache.fGlobalIDConstraintMap.get( ((KeyRef) fIdentityConstraint).getKey()); if (fKeyValueStore == null) { // report error String code = "KeyRefOutOfScope"; String value = fIdentityConstraint.getName(); reportSchemaError(code, new Object[] { value }); return; } int errorIndex = fKeyValueStore.contains(this); if (errorIndex != -1) { String code = "KeyNotFound"; String values = toString(fValues, errorIndex, fFieldCount); String name = fIdentityConstraint.getName(); reportSchemaError(code, new Object[] { name, values, fElementName }); } } // endDocumentFragment()
public void transplant(IdentityConstraint id, int initialDepth) { fLocalId.fDepth = initialDepth; fLocalId.fId = id; ValueStoreBase newVals = (ValueStoreBase) fIdentityConstraint2ValueStoreMap.get(fLocalId); if (id.getCategory() == IdentityConstraint.IC_KEYREF) return; ValueStoreBase currVals = (ValueStoreBase) fGlobalIDConstraintMap.get(id); if (currVals != null) { currVals.append(newVals); fGlobalIDConstraintMap.put(id, currVals); } else fGlobalIDConstraintMap.put(id, newVals); } // transplant(id)
/** End document. */ public void endDocument() { super.endDocument(); } // endDocument()
/** * Ends the value scope for the specified identity constraint. * * @param identityConstraint The identity constraint. */ public void endValueScopeFor(IdentityConstraint identityConstraint, int initialDepth) { ValueStoreBase valueStore = fValueStoreCache.getValueStoreFor(identityConstraint, initialDepth); valueStore.endValueScope(); } // endValueScopeFor(IdentityConstraint)