// (c) Tuomas J. Lukka package org.nongnu.alph.impl; import org.nongnu.alph.*; /** A text span that doesn't really belong to a scrollblock. * This is the implementation of the PEG xu_text--benja. */ public class URN5TextSpan implements TextSpan { /** The interned urn5 name string. */ private String urn5; /** The fake offset within the urn5 */ private int offset; /** The contents. */ private String str; public URN5TextSpan(String urn5, int offset, String str) { this.urn5 = urn5.intern(); this.offset = offset; this.str = str; } public String toString() { return "URN5Span["+urn5+","+offset+",'"+str+"']"; } public boolean intersects(Span s) { if(!(s instanceof URN5Span)) return false; URN5TextSpan other = (URN5TextSpan)s; // Because urn5 is interned, can do this if(other.urn5 != urn5) return false; if(offset <= other.offset) { int loc = other.offset - offset; int tlen = str.length() - loc; int olen = other.str.length(); int len; if(tlen < olen) len = tlen; else len = olen; if(len <= 0) return false; for(int i=0; i