	public static String createDisplayName(RElementName a, final int options) {
		StringBuilder sb = null;
		if ((options & DISPLAY_NS_PREFIX) != 0) {
			final RElementName namespace = a.getNamespace();
			if (namespace != null) {
				sb = new StringBuilder(32);
				if (!appendEnvAccess(namespace, sb, options)
						|| a.getType() != MAIN_DEFAULT) {
					return null;
				}
			}
			else if (a.getType() == MAIN_SEARCH_ENV
					|| a.getType() == MAIN_PACKAGE
					|| a.getType() == MAIN_SYSFRAME) {
				sb = new StringBuilder(32);
				if (!appendEnvAccess(a, sb, options)
						|| (a = a.getNextSegment()) != null && a.getType() != MAIN_DEFAULT) {
					return null;
				}
			}
			if (sb != null && a != null) {
				sb.append('$');
				final String name = a.getSegmentName();
				if (name != null) {
					appendSymbol(sb, name);
				}
				a = a.getNextSegment();
			}
		}
		if (sb == null) {
			String firstName;
			final int type = a.getType();
			switch (type) {
			case MAIN_DEFAULT:
			case MAIN_CLASS:
			case SUB_NAMEDPART:
			case SUB_NAMEDSLOT:
				firstName = a.getSegmentName();
				if (firstName != null) {
					sb = appendSymbol(sb, firstName);
				}
				else {
					firstName = ""; 
				}
				a = a.getNextSegment();
				if (a == null) {
					return (sb != null) ? sb.toString() : firstName;
				}
				if (sb == null) {
					sb = new StringBuilder(firstName);
				}
				break;
			case MAIN_SEARCH_ENV:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return firstName;
				}
				return null;
			case MAIN_SYSFRAME:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return "frame:"+firstName;
				}
				return null;
			case MAIN_PACKAGE:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return "package:"+firstName;
				}
				else if ((options & DISPLAY_EXACT) == 0) {
					return "package:<unknown>";
				}
				else {
					return null;
				}
			case MAIN_PROJECT:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return "project:"+firstName;
				}
				else if ((options & DISPLAY_EXACT) == 0) {
					return "project:<unknown>";
				}
				else {
					return null;
				}
			case SUB_INDEXED_D:
				if (a instanceof DefaultImpl) {
					sb = new StringBuilder("[["); 
					sb.append(a.getSegmentName());
					sb.append("]]"); 
					a = a.getNextSegment();
					break;
				}
				return null;
			case RESOURCE:
			case MAIN_OTHER:
				return a.getSegmentName();
			case ANONYMOUS:
				if ((options & DISPLAY_EXACT) == 0) {
					return "<anonymous>";
				}
				return null;
			default:
				return null;
			}
		}
		APPEND_SUB : while (a != null) {
			String name;
			switch (a.getType()) {
			case MAIN_DEFAULT:
			case MAIN_CLASS:
			case SUB_NAMEDPART:
				if (((options & DISPLAY_EXACT) != 0) && a instanceof IndexElementName) {
					sb.append("[[");
					sb.append(((IndexElementName) a).getIndex());
					sb.append("L]]");
				}
				else {
					sb.append('$');
					name = a.getSegmentName();
					if (name != null) {
						appendSymbol(sb, name);
					}
				}
				a = a.getNextSegment();
				continue APPEND_SUB;
			case SUB_NAMEDSLOT:
				sb.append('@');
				name = a.getSegmentName();
				if (name != null) {
					appendSymbol(sb, name);
				}
				a = a.getNextSegment();
				continue APPEND_SUB;
			case SUB_INDEXED_S:
				if (((options & DISPLAY_EXACT) != 0)) {
					return null;
				}
				sb.append("[…]"); 
				break APPEND_SUB;
			case SUB_INDEXED_D:
				if (a instanceof DefaultImpl) {
					sb.append("[["); 
					sb.append(a.getSegmentName());
					sb.append("]]"); 
					a = a.getNextSegment();
					continue APPEND_SUB;
				}
				else if ((options & DISPLAY_EXACT) == 0) {
					sb.append("[[…]]"); 
					continue APPEND_SUB;
				}
				else {
					return null;
				}
			default:
				if (((options & DISPLAY_EXACT) == 0)) {
					sb.append(" …"); 
					break APPEND_SUB;
				}
				return null;
			}
		}
		return sb.toString();
	}

	public static String createDisplayName(RElementName a, final int options) {
		StringBuilder sb = null;
		if ((options & DISPLAY_NS_PREFIX) != 0) {
			final RElementName namespace = a.getNamespace();
			if (namespace != null) {
				sb = new StringBuilder(32);
				if (!appendEnvAccess(namespace, sb, options)
						|| a.getType() != MAIN_DEFAULT) {
					return null;
				}
			}
			else if (a.getType() == MAIN_SEARCH_ENV
					|| a.getType() == MAIN_PACKAGE
					|| a.getType() == MAIN_SYSFRAME) {
				sb = new StringBuilder(32);
				if (!appendEnvAccess(a, sb, options)
						|| (a = a.getNextSegment()) != null && a.getType() != MAIN_DEFAULT) {
					return null;
				}
			}
			if (sb != null && a != null) {
				sb.append('$');
				final String name = a.getSegmentName();
				if (name != null) {
					appendSymbol(sb, name);
				}
				a = a.getNextSegment();
			}
		}
		if (sb == null) {
			String firstName;
			final int type = a.getType();
			switch (type) {
			case MAIN_DEFAULT:
			case MAIN_CLASS:
			case SUB_NAMEDPART:
			case SUB_NAMEDSLOT:
				firstName = a.getSegmentName();
				if (firstName != null) {
					sb = appendSymbol(sb, firstName);
				}
				else {
					firstName = ""; 
				}
				a = a.getNextSegment();
				if (a == null) {
					return (sb != null) ? sb.toString() : firstName;
				}
				if (sb == null) {
					sb = new StringBuilder(firstName);
				}
				break;
			case MAIN_SEARCH_ENV:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return firstName;
				}
				return null;
			case MAIN_SYSFRAME:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return "frame:"+firstName;
				}
				return null;
			case MAIN_PACKAGE:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return "package:"+firstName;
				}
				else if ((options & DISPLAY_EXACT) == 0) {
					return "package:<unknown>";
				}
				else {
					return null;
				}
			case MAIN_PROJECT:
				firstName = a.getSegmentName();
				if (firstName != null) {
					return "project:"+firstName;
				}
				else if ((options & DISPLAY_EXACT) == 0) {
					return "project:<unknown>";
				}
				else {
					return null;
				}
			case SUB_INDEXED_D:
				if (a instanceof DefaultImpl) {
					sb = new StringBuilder("[["); 
					sb.append(a.getSegmentName());
					sb.append("]]"); 
					a = a.getNextSegment();
					break;
				}
				return null;
			case RESOURCE:
			case MAIN_OTHER:
				return a.getSegmentName();
			case ANONYMOUS:
				if ((options & DISPLAY_EXACT) == 0) {
					return "<anonymous>";
				}
				return null;
			default:
				return null;
			}
		}
		APPEND_SUB : while (a != null) {
			String name;
			switch (a.getType()) {
			case MAIN_DEFAULT:
			case MAIN_CLASS:
			case SUB_NAMEDPART:
				if (((options & DISPLAY_EXACT) != 0) && a instanceof IndexElementName) {
					sb.append("[[");
					sb.append(((IndexElementName) a).getIndex());
					sb.append("L]]");
				}
				else {
					sb.append('$');
					name = a.getSegmentName();
					if (name != null) {
						appendSymbol(sb, name);
					}
				}
				a = a.getNextSegment();
				continue APPEND_SUB;
			case SUB_NAMEDSLOT:
				sb.append('@');
				name = a.getSegmentName();
				if (name != null) {
					appendSymbol(sb, name);
				}
				a = a.getNextSegment();
				continue APPEND_SUB;
			case SUB_INDEXED_S:
				if (((options & DISPLAY_EXACT) != 0)) {
					return null;
				}
				sb.append("[…]"); 
				break APPEND_SUB;
			case SUB_INDEXED_D:
				if (a instanceof DefaultImpl) {
					sb.append("[["); 
					sb.append(a.getSegmentName());
					sb.append("]]"); 
					a = a.getNextSegment();
					continue APPEND_SUB;
				}
				else if ((options & DISPLAY_EXACT) == 0) {
					sb.append("[[…]]"); 
					a = a.getNextSegment();
					continue APPEND_SUB;
				}
				else {
					return null;
				}
			default:
				if (((options & DISPLAY_EXACT) == 0)) {
					sb.append(" …"); 
					break APPEND_SUB;
				}
				return null;
			}
		}
		return sb.toString();
	}
