@Override public int hashCode() { int code = 0; for (State state = getCurrentState(); state != null; state = state.next) { code = code * 31 + state.attribute.hashCode(); } return code; }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#clear()} on each Attribute implementation. */ public final void clearAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.clear(); } }
/** * Captures the state of all Attributes. The return value can be passed to * {@link #restoreState} to restore the state of this or another AttributeSource. */ public final State captureState() { final State state = this.getCurrentState(); return (state == null) ? null : state.clone(); }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#end()} on each Attribute implementation. */ public final void endAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.end(); } }
/** * This method is for introspection of attributes, it should simply * add the key/values this AttributeSource holds to the given {@link AttributeReflector}. * * <p>This method iterates over all Attribute implementations and calls the * corresponding {@link AttributeImpl#reflectWith} method.</p> * * @see AttributeImpl#reflectWith */ public final void reflectWith(AttributeReflector reflector) { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.reflectWith(reflector); } }
final State initState = getCurrentState(); if (initState != null) { return new Iterator<AttributeImpl>() {
/** * Copies the contents of this {@code AttributeSource} to the given target {@code AttributeSource}. * The given instance has to provide all {@link Attribute}s this instance contains. * The actual attribute implementations must be identical in both {@code AttributeSource} instances; * ideally both AttributeSource instances should use the same {@link AttributeFactory}. * You can use this method as a replacement for {@link #restoreState}, if you use * {@link #cloneAttributes} instead of {@link #captureState}. */ public final void copyTo(AttributeSource target) { for (State state = getCurrentState(); state != null; state = state.next) { final AttributeImpl targetImpl = target.attributeImpls.get(state.attribute.getClass()); if (targetImpl == null) { throw new IllegalArgumentException("This AttributeSource contains AttributeImpl of type " + state.attribute.getClass().getName() + " that is not in the target"); } state.attribute.copyTo(targetImpl); } }
/** * Performs a clone of all {@link AttributeImpl} instances returned in a new * {@code AttributeSource} instance. This method can be used to e.g. create another TokenStream * with exactly the same attributes (using {@link #AttributeSource(AttributeSource)}). * You can also use it as a (non-performant) replacement for {@link #captureState}, if you need to look * into / modify the captured state. */ public final AttributeSource cloneAttributes() { final AttributeSource clone = new AttributeSource(this.factory); if (hasAttributes()) { // first clone the impls for (State state = getCurrentState(); state != null; state = state.next) { clone.attributeImpls.put(state.attribute.getClass(), state.attribute.clone()); } // now the interfaces for (Entry<Class<? extends Attribute>, AttributeImpl> entry : this.attributes.entrySet()) { clone.attributes.put(entry.getKey(), clone.attributeImpls.get(entry.getValue().getClass())); } } return clone; }
State thisState = this.getCurrentState(); State otherState = other.getCurrentState(); while (thisState != null && otherState != null) { if (otherState.attribute.getClass() != thisState.attribute.getClass() || !otherState.attribute.equals(thisState.attribute)) {
@Override public int hashCode() { int code = 0; for (State state = getCurrentState(); state != null; state = state.next) { code = code * 31 + state.attribute.hashCode(); } return code; }
@Override public int hashCode() { int code = 0; for (State state = getCurrentState(); state != null; state = state.next) { code = code * 31 + state.attribute.hashCode(); } return code; }
@Override public int hashCode() { int code = 0; for (State state = getCurrentState(); state != null; state = state.next) { code = code * 31 + state.attribute.hashCode(); } return code; }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#clear()} on each Attribute implementation. */ public final void clearAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.clear(); } }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#clear()} on each Attribute implementation. */ public final void clearAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.clear(); } }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#end()} on each Attribute implementation. */ public final void endAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.end(); } }
/** * Captures the state of all Attributes. The return value can be passed to * {@link #restoreState} to restore the state of this or another AttributeSource. */ public final State captureState() { final State state = this.getCurrentState(); return (state == null) ? null : state.clone(); }
/** * Captures the state of all Attributes. The return value can be passed to * {@link #restoreState} to restore the state of this or another AttributeSource. */ public final State captureState() { final State state = this.getCurrentState(); return (state == null) ? null : state.clone(); }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#end()} on each Attribute implementation. */ public final void endAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.end(); } }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#clear()} on each Attribute implementation. */ public final void clearAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.clear(); } }
/** * Captures the state of all Attributes. The return value can be passed to * {@link #restoreState} to restore the state of this or another AttributeSource. */ public final State captureState() { final State state = this.getCurrentState(); return (state == null) ? null : state.clone(); }