http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java index 95ed482..f2fd9e0 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java @@ -19,14 +19,14 @@ import static org.apache.juneau.internal.StringUtils.*; import java.lang.reflect.*; import java.util.*; -import javax.xml.namespace.*; import javax.xml.stream.*; -import javax.xml.stream.events.*; import org.apache.juneau.*; import org.apache.juneau.annotation.*; +import org.apache.juneau.json.*; import org.apache.juneau.parser.*; import org.apache.juneau.transform.*; +import org.apache.juneau.xml.*; /** * Parses text generated by the {@link HtmlSerializer} class back into a POJO model. @@ -48,9 +48,9 @@ import org.apache.juneau.transform.*; * <li>{@link HtmlSerializerContext} * </ul> */ -@SuppressWarnings({ "rawtypes", "unchecked" }) +@SuppressWarnings({ "rawtypes", "unchecked", "hiding" }) @Consumes("text/html,text/html+stripped") -public final class HtmlParser extends ReaderParser { +public final class HtmlParser extends XmlParser { /** Default parser, all default settings.*/ public static final HtmlParser DEFAULT = new HtmlParser().lock(); @@ -58,143 +58,170 @@ public final class HtmlParser extends ReaderParser { /* * Reads anything starting at the current event. * <p> - * Precondition: Must be pointing at START_ELEMENT or CHARACTERS event. - * Postcondition: Pointing at next event to be processed. + * Precondition: Must be pointing at outer START_ELEMENT. + * Postcondition: Pointing at outer END_ELEMENT. */ - private <T> T parseAnything(HtmlParserSession session, ClassMeta<T> eType, XMLEventReader r, Object outer, BeanPropertyMeta pMeta) throws Exception { + private <T> T parseAnything(HtmlParserSession session, ClassMeta<T> eType, XMLStreamReader r, Object outer, boolean isRoot, BeanPropertyMeta pMeta) throws Exception { if (eType == null) eType = (ClassMeta<T>)object(); PojoSwap<T,Object> transform = (PojoSwap<T,Object>)eType.getPojoSwap(); ClassMeta<?> sType = eType.getSerializedClassMeta(); session.setCurrentClass(sType); - BeanDictionary bd = (pMeta == null ? session.getBeanDictionary() : pMeta.getBeanDictionary()); + BeanRegistry breg = (pMeta == null ? session.getBeanRegistry() : pMeta.getBeanRegistry()); - Object o = null; + int event = r.getEventType(); + if (event != START_ELEMENT) + throw new XMLStreamException("parseAnything must be called on outer start element.", r.getLocation()); - XMLEvent event = r.nextEvent(); - while (! (event.isStartElement() || (event.isCharacters() && ! event.asCharacters().isWhiteSpace()) || event.isEndDocument())) - event = r.nextEvent(); + if (! isRoot) + event = r.next(); + boolean isEmpty = (event == END_ELEMENT); - if (event.isEndDocument()) - throw new XMLStreamException("Unexpected end of stream in parseAnything for type '"+eType+"'", event.getLocation()); + // Skip until we find a start element, end document, or non-empty text. + if (! isEmpty) + event = skipWs(r); - if (event.isCharacters()) { - String text = parseCharacters(event, r); - if (sType.isObject()) - o = text; - else if (sType.isCharSequence()) + if (event == END_DOCUMENT) + throw new XMLStreamException("Unexpected end of stream in parseAnything for type '"+eType+"'", r.getLocation()); + + // Handle @Html(asXml=true) beans. + HtmlClassMeta hcm = sType.getExtendedMeta(HtmlClassMeta.class); + if (hcm.isAsXml()) + return super.parseAnything(session, eType, null, r, outer, false, pMeta); + + Object o = null; + + boolean isValid = true; + Tag tag = (event == CHARACTERS ? null : Tag.forString(r.getName().getLocalPart(), false)); + + if (isEmpty) { + o = ""; + } else if (tag == null || tag.isOneOf(BR,BS,TB,FF)) { + String text = parseCharacters(session, r); + if (sType.isObject() || sType.isCharSequence()) o = text; - else if (sType.isNumber()) - o = parseNumber(text, (Class<? extends Number>)eType.getInnerClass()); else if (sType.isChar()) o = text.charAt(0); else if (sType.isBoolean()) o = Boolean.parseBoolean(text); + else if (sType.isNumber()) + o = parseNumber(text, (Class<? extends Number>)eType.getInnerClass()); else if (sType.canCreateNewInstanceFromString(outer)) o = sType.newInstanceFromString(outer, text); else if (sType.canCreateNewInstanceFromNumber(outer)) o = sType.newInstanceFromNumber(session, outer, parseNumber(text, sType.getNewInstanceFromNumberClass())); else - throw new XMLStreamException("Unexpected characters '"+event.asCharacters().getData()+"' for type '"+eType+"'", event.getLocation()); - - } else { - Tag tag = Tag.forString(event.asStartElement().getName().getLocalPart(), false); - - // The _type attribute can be any of the following: - // "object" - A map. - // "array" - An array. - // "X" - A bean type name as defined through @Bean.typeName(). - - String typeName = "object"; - String text = ""; - - if (tag.isOneOf(STRING, NUMBER, BOOLEAN, BR, FF, BS, TB)) - text = parseCharacters(event, r); - - if (tag == TABLE) { - Map<String,String> attrs = getAttributes(event); - typeName = attrs.get(session.getBeanTypePropertyName()); - if (bd.hasName(typeName)) - sType = eType = (ClassMeta<T>)bd.getClassMeta(typeName); - // Reset to "object" if it was a bean type name. - if (! typeName.equals("array")) - typeName = "object"; - } + isValid = false; - boolean isValid = true; - - if (tag == NULL) - nextTag(r, xNULL); - else if (tag == A) - o = parseAnchor(session, event, r, eType); - else if (sType.isObject()) { - if (tag == STRING) - o = text; - else if (tag == NUMBER) - o = parseNumber(text, null); - else if (tag == BOOLEAN) - o = Boolean.parseBoolean(text); - else if (tag == TABLE) { - if (typeName.equals("object")) { - o = parseIntoMap(session, r, (Map)new ObjectMap(session), sType.getKeyType(), sType.getValueType(), pMeta); - } else if (typeName.equals("array")) { - o = parseTableIntoCollection(session, r, (Collection)new ObjectList(session), sType.getElementType(), pMeta); - } else - isValid = false; - } - else if (tag == UL) - o = parseIntoCollection(session, r, new ObjectList(session), null, pMeta); - } - else if (tag == STRING && sType.isCharSequence()) + } else if (tag == STRING) { + String text = parseElementText(session, r); + if (sType.isObject() || sType.isCharSequence()) o = text; - else if (tag == STRING && sType.isChar()) + else if (sType.isChar()) o = text.charAt(0); - else if (tag == STRING && sType.canCreateNewInstanceFromString(outer)) + else if (sType.canCreateNewInstanceFromString(outer)) o = sType.newInstanceFromString(outer, text); - else if (tag == NUMBER && sType.isNumber()) + else if (sType.canCreateNewInstanceFromNumber(outer)) + o = sType.newInstanceFromNumber(session, outer, parseNumber(text, sType.getNewInstanceFromNumberClass())); + else + isValid = false; + skipTag(r, xSTRING); + + } else if (tag == NUMBER) { + String text = parseElementText(session, r); + if (sType.isObject()) + o = parseNumber(text, Number.class); + else if (sType.isNumber()) o = parseNumber(text, (Class<? extends Number>)sType.getInnerClass()); - else if (tag == NUMBER && sType.canCreateNewInstanceFromNumber(outer)) + else if (sType.canCreateNewInstanceFromNumber(outer)) o = sType.newInstanceFromNumber(session, outer, parseNumber(text, sType.getNewInstanceFromNumberClass())); - else if (tag == BOOLEAN && sType.isBoolean()) + else + isValid = false; + skipTag(r, xNUMBER); + + } else if (tag == BOOLEAN) { + String text = parseElementText(session, r); + if (sType.isObject() || sType.isBoolean()) o = Boolean.parseBoolean(text); - else if (tag == TABLE) { - if (typeName.equals("object")) { - if (sType.isMap()) { - o = parseIntoMap(session, r, (Map)(sType.canCreateNewInstance(outer) ? sType.newInstance(outer) : new ObjectMap(session)), sType.getKeyType(), sType.getValueType(), pMeta); - } else if (sType.canCreateNewInstanceFromObjectMap(outer)) { - ObjectMap m = new ObjectMap(session); - parseIntoMap(session, r, m, string(), object(), pMeta); - o = sType.newInstanceFromObjectMap(outer, m); - } else if (sType.canCreateNewBean(outer)) { - BeanMap m = session.newBeanMap(outer, sType.getInnerClass()); - o = parseIntoBean(session, r, m).getBean(); - } - else - isValid = false; - } else if (typeName.equals("array")) { - if (sType.isCollection()) - o = parseTableIntoCollection(session, r, (Collection)(sType.canCreateNewInstance(outer) ? sType.newInstance(outer) : new ObjectList(session)), sType.getElementType(), pMeta); - else if (sType.isArray()) - o = session.toArray(sType, parseTableIntoCollection(session, r, new ArrayList(), sType.getElementType(), pMeta)); - else - isValid = false; - } else + else + isValid = false; + skipTag(r, xBOOLEAN); + + } else if (tag == NULL) { + skipTag(r, NULL); + skipTag(r, xNULL); + + } else if (tag == A) { + o = parseAnchor(session, r, eType); + skipTag(r, xA); + + } else if (tag == TABLE) { + + String typeName = getAttribute(r, session.getBeanTypePropertyName(), "object"); + + if (breg.hasName(typeName)) { + sType = eType = (ClassMeta<T>)breg.getClassMeta(typeName); + typeName = sType.isArray() ? "array" : "object"; + } else if (! "array".equals(typeName)) { + // Type name could be a subtype name. + typeName = "object"; + } + + if (typeName.equals("object")) { + if (sType.isObject()) { + o = parseIntoMap(session, r, (Map)new ObjectMap(session), sType.getKeyType(), sType.getValueType(), pMeta); + } else if (sType.isMap()) { + o = parseIntoMap(session, r, (Map)(sType.canCreateNewInstance(outer) ? sType.newInstance(outer) : new ObjectMap(session)), sType.getKeyType(), sType.getValueType(), pMeta); + } else if (sType.canCreateNewInstanceFromObjectMap(outer)) { + ObjectMap m = new ObjectMap(session); + parseIntoMap(session, r, m, string(), object(), pMeta); + o = sType.newInstanceFromObjectMap(outer, m); + } else if (sType.canCreateNewBean(outer)) { + BeanMap m = session.newBeanMap(outer, sType.getInnerClass()); + o = parseIntoBean(session, r, m).getBean(); + } else { isValid = false; - } else if (tag == UL) { - if (sType.isCollection()) - o = parseIntoCollection(session, r, (Collection)(sType.canCreateNewInstance(outer) ? sType.newInstance(outer) : new ObjectList(session)), sType.getElementType(), pMeta); - else if (sType.isArray()) - o = session.toArray(sType, parseIntoCollection(session, r, new ArrayList(), sType.getElementType(), pMeta)); + } + skipTag(r, xTABLE); + + } else if (typeName.equals("array")) { + if (sType.isObject()) + o = parseTableIntoCollection(session, r, (Collection)new ObjectList(session), sType.getElementType(), pMeta); + else if (sType.isCollection()) + o = parseTableIntoCollection(session, r, (Collection)(sType.canCreateNewInstance(outer) ? sType.newInstance(outer) : new ObjectList(session)), sType.getElementType(), pMeta); + else if (sType.isArray()) { + ArrayList l = (ArrayList)parseTableIntoCollection(session, r, new ArrayList(), sType.getElementType(), pMeta); + o = session.toArray(sType, l); + } else isValid = false; - } else + skipTag(r, xTABLE); + + } else { isValid = false; + } + + } else if (tag == UL) { + String typeName = getAttribute(r, session.getBeanTypePropertyName(), "array"); + + if (breg.hasName(typeName)) + sType = eType = (ClassMeta<T>)breg.getClassMeta(typeName); + + if (sType.isObject()) + o = parseIntoCollection(session, r, (Collection)new ObjectList(session), sType.getElementType(), pMeta); + else if (sType.isCollection() || sType.isObject()) + o = parseIntoCollection(session, r, (Collection)(sType.canCreateNewInstance(outer) ? sType.newInstance(outer) : new ObjectList(session)), sType.getElementType(), pMeta); + else if (sType.isArray()) + o = session.toArray(sType, parseIntoCollection(session, r, new ArrayList(), sType.getElementType(), pMeta)); + else + isValid = false; + skipTag(r, xUL); - if (! isValid) - throw new XMLStreamException("Unexpected tag '"+tag+"' for type '"+eType+"'", event.getLocation()); } + if (! isValid) + throw new XMLStreamException("Unexpected tag '"+tag+"' for type '"+eType+"'", r.getLocation()); if (transform != null && o != null) o = transform.unswap(session, o, eType); @@ -202,15 +229,23 @@ public final class HtmlParser extends ReaderParser { if (outer != null) setParent(eType, o, outer); + skipWs(r); return (T)o; } + private static String getAttribute(XMLStreamReader r, String name, String def) { + for (int i = 0; i < r.getAttributeCount(); i++) + if (r.getAttributeLocalName(i).equals(name)) + return r.getAttributeValue(i); + return def; + } + /* * Reads an anchor tag and converts it into a bean. */ - private <T> T parseAnchor(HtmlParserSession session, XMLEvent e, XMLEventReader r, ClassMeta<T> beanType) throws XMLStreamException { - String href = e.asStartElement().getAttributeByName(new QName("href")).getValue(); - String name = parseCharacters(e, r); + private <T> T parseAnchor(HtmlParserSession session, XMLStreamReader r, ClassMeta<T> beanType) throws XMLStreamException { + String href = r.getAttributeValue(null, "href"); + String name = parseElementText(session, r); Class<T> beanClass = beanType.getInnerClass(); if (beanClass.isAnnotationPresent(HtmlLink.class)) { HtmlLink h = beanClass.getAnnotation(HtmlLink.class); @@ -222,12 +257,10 @@ public final class HtmlParser extends ReaderParser { return session.convertToType(href, beanType); } - private Map<String,String> getAttributes(XMLEvent e) { + private Map<String,String> getAttributes(XMLStreamReader r) { Map<String,String> m = new TreeMap<String,String>() ; - for (Iterator i = e.asStartElement().getAttributes(); i.hasNext();) { - Attribute a = (Attribute)i.next(); - m.put(a.getName().getLocalPart(), a.getValue()); - } + for (int i = 0; i < r.getAttributeCount(); i++) + m.put(r.getAttributeLocalName(i), r.getAttributeValue(i)); return m; } @@ -236,7 +269,7 @@ public final class HtmlParser extends ReaderParser { * Precondition: Must be pointing at <table> event. * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event. */ - private <K,V> Map<K,V> parseIntoMap(HtmlParserSession session, XMLEventReader r, Map<K,V> m, ClassMeta<K> keyType, ClassMeta<V> valueType, BeanPropertyMeta pMeta) throws Exception { + private <K,V> Map<K,V> parseIntoMap(HtmlParserSession session, XMLStreamReader r, Map<K,V> m, ClassMeta<K> keyType, ClassMeta<V> valueType, BeanPropertyMeta pMeta) throws Exception { while (true) { Tag tag = nextTag(r, TR, xTABLE); if (tag == xTABLE) @@ -244,19 +277,17 @@ public final class HtmlParser extends ReaderParser { tag = nextTag(r, TD, TH); // Skip over the column headers. if (tag == TH) { - parseElementText(r, xTH); + skipElementText(r); nextTag(r, TH); - parseElementText(r, xTH); + skipElementText(r); nextTag(r, xTR); continue; } - K key = parseAnything(session, keyType, r, m, pMeta); - nextTag(r, xTD); + K key = parseAnything(session, keyType, r, m, false, pMeta); nextTag(r, TD); - V value = parseAnything(session, valueType, r, m, pMeta); + V value = parseAnything(session, valueType, r, m, false, pMeta); setName(valueType, value, key); m.put(key, value); - nextTag(r, xTD); nextTag(r, xTR); } @@ -268,13 +299,12 @@ public final class HtmlParser extends ReaderParser { * Precondition: Must be pointing at event following <ul> event. * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event. */ - private <E> Collection<E> parseIntoCollection(HtmlParserSession session, XMLEventReader r, Collection<E> l, ClassMeta<E> elementType, BeanPropertyMeta pMeta) throws Exception { + private <E> Collection<E> parseIntoCollection(HtmlParserSession session, XMLStreamReader r, Collection<E> l, ClassMeta<E> elementType, BeanPropertyMeta pMeta) throws Exception { while (true) { Tag tag = nextTag(r, LI, xUL); if (tag == xUL) break; - l.add(parseAnything(session, elementType, r, l, pMeta)); - nextTag(r, xLI); + l.add(parseAnything(session, elementType, r, l, false, pMeta)); } return l; } @@ -284,16 +314,15 @@ public final class HtmlParser extends ReaderParser { * Precondition: Must be pointing at event following <ul> event. * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event. */ - private Object[] parseArgs(HtmlParserSession session, XMLEventReader r, ClassMeta<?>[] argTypes) throws Exception { + private Object[] parseArgs(HtmlParserSession session, XMLStreamReader r, ClassMeta<?>[] argTypes) throws Exception { Object[] o = new Object[argTypes.length]; int i = 0; while (true) { Tag tag = nextTag(r, LI, xUL); if (tag == xUL) break; - o[i] = parseAnything(session, argTypes[i], r, session.getOuter(), null); + o[i] = parseAnything(session, argTypes[i], r, session.getOuter(), false, null); i++; - nextTag(r, xLI); } return o; } @@ -303,11 +332,11 @@ public final class HtmlParser extends ReaderParser { * Precondition: Must be pointing at event following <ul> event. * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event. */ - private <E> Collection<E> parseTableIntoCollection(HtmlParserSession session, XMLEventReader r, Collection<E> l, ClassMeta<E> elementType, BeanPropertyMeta pMeta) throws Exception { + private <E> Collection<E> parseTableIntoCollection(HtmlParserSession session, XMLStreamReader r, Collection<E> l, ClassMeta<E> elementType, BeanPropertyMeta pMeta) throws Exception { if (elementType == null) elementType = (ClassMeta<E>)object(); - BeanDictionary bd = (pMeta == null ? session.getBeanDictionary() : pMeta.getBeanDictionary()); + BeanRegistry breg = (pMeta == null ? session.getBeanRegistry() : pMeta.getBeanRegistry()); Tag tag = nextTag(r, TR); List<String> keys = new ArrayList<String>(); @@ -315,14 +344,20 @@ public final class HtmlParser extends ReaderParser { tag = nextTag(r, TH, xTR); if (tag == xTR) break; - keys.add(parseElementText(r, xTH)); + keys.add(parseElementText(session, r)); } while (true) { - XMLEvent event = r.nextTag(); - tag = Tag.forEvent(event); + r.nextTag(); + tag = Tag.forEvent(r); if (tag == xTABLE) break; + + String type = getAttribute(r, session.getBeanTypePropertyName(), null); + if (breg.hasName(type)) { + elementType = (ClassMeta)breg.getClassMeta(type); + } + if (elementType.canCreateNewBean(l)) { BeanMap m = session.newBeanMap(l, elementType.getInnerClass()); for (int i = 0; i < keys.size(); i++) { @@ -336,19 +371,18 @@ public final class HtmlParser extends ReaderParser { BeanMapEntry e = m.getProperty(key); if (e == null) { //onUnknownProperty(key, m, -1, -1); - parseAnything(session, object(), r, l, null); + parseAnything(session, object(), r, l, false, null); } else { BeanPropertyMeta bpm = e.getMeta(); ClassMeta<?> cm = bpm.getClassMeta(); - Object value = parseAnything(session, cm, r, m.getBean(false), bpm); + Object value = parseAnything(session, cm, r, m.getBean(false), false, bpm); setName(cm, value, key); bpm.set(m, value); } - nextTag(r, xTD); } l.add(m == null ? null : (E)m.getBean()); } else { - String c = getAttributes(event).get(session.getBeanTypePropertyName()); + String c = getAttributes(r).get(session.getBeanTypePropertyName()); Map m = (Map)(elementType.isMap() && elementType.canCreateNewInstance(l) ? elementType.newInstance(l) : new ObjectMap(session)); for (int i = 0; i < keys.size(); i++) { tag = nextTag(r, TD, NULL); @@ -360,16 +394,15 @@ public final class HtmlParser extends ReaderParser { String key = keys.get(i); if (m != null) { ClassMeta<?> et = elementType.getElementType(); - Object value = parseAnything(session, et, r, l, pMeta); + Object value = parseAnything(session, et, r, l, false, pMeta); setName(et, value, key); m.put(key, value); } - nextTag(r, xTD); } if (m != null && c != null) { ObjectMap m2 = (m instanceof ObjectMap ? (ObjectMap)m : new ObjectMap(m).setBeanSession(session)); m2.put(session.getBeanTypePropertyName(), c); - l.add((E)bd.cast(m2)); + l.add((E)breg.cast(m2)); } else { l.add((E)m); } @@ -384,7 +417,7 @@ public final class HtmlParser extends ReaderParser { * Precondition: Must be pointing at event following <table> event. * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event. */ - private <T> BeanMap<T> parseIntoBean(HtmlParserSession session, XMLEventReader r, BeanMap<T> m) throws Exception { + private <T> BeanMap<T> parseIntoBean(HtmlParserSession session, XMLStreamReader r, BeanMap<T> m) throws Exception { while (true) { Tag tag = nextTag(r, TR, xTABLE); if (tag == xTABLE) @@ -392,116 +425,110 @@ public final class HtmlParser extends ReaderParser { tag = nextTag(r, TD, TH); // Skip over the column headers. if (tag == TH) { - parseElementText(r, xTH); + skipElementText(r); nextTag(r, TH); - parseElementText(r, xTH); + skipElementText(r); nextTag(r, xTR); continue; } - String key = parseElementText(r, xTD); + String key = parseElementText(session, r); nextTag(r, TD); BeanPropertyMeta pMeta = m.getPropertyMeta(key); if (pMeta == null) { if (m.getMeta().isSubTyped()) { - Object value = parseAnything(session, object(), r, m.getBean(false), null); + Object value = parseAnything(session, object(), r, m.getBean(false), false, null); m.put(key, value); } else { onUnknownProperty(session, key, m, -1, -1); - parseAnything(session, object(), r, null, null); + parseAnything(session, object(), r, null, false, null); } } else { ClassMeta<?> cm = pMeta.getClassMeta(); - Object value = parseAnything(session, cm, r, m.getBean(false), pMeta); + Object value = parseAnything(session, cm, r, m.getBean(false), false, pMeta); setName(cm, value, key); pMeta.set(m, value); } - nextTag(r, xTD); nextTag(r, xTR); } return m; } + /* * Parse until the next event is an end tag. */ - private String parseCharacters(XMLEvent e, XMLEventReader r) throws XMLStreamException { - - List<String> strings = new LinkedList<String>(); - - while (true) { - int eventType = e.getEventType(); - if (eventType == CHARACTERS) { - Characters c = e.asCharacters(); - if (! c.isWhiteSpace()) - strings.add(c.getData()); - } - else if (eventType == START_ELEMENT) { - Tag tag = Tag.forEvent(e); - if (tag == BR) - strings.add("\n"); - else if (tag == FF) - strings.add("\f"); - else if (tag == BS) - strings.add("\b"); - else if (tag == TB) - strings.add("\t"); + private String parseCharacters(HtmlParserSession session, XMLStreamReader r) throws XMLStreamException { + + StringBuilder sb = session.getStringBuilder(); + + int et = r.getEventType(); + int depth = (et == START_ELEMENT ? 1 : et == END_ELEMENT ? -1 : 0); + + while (depth >= 0) { + if (et == START_ELEMENT) { + Tag tag = Tag.forEvent(r); + if (tag == BR) { + sb.append("\n"); + } else if (tag == BS) { + sb.append("\b"); + } else if (tag == TB) { + sb.append("\t"); + r.next(); + } else if (tag == FF) { + sb.append("\f"); + } else if (! tag.isOneOf(STRING, NUMBER, BOOLEAN)) { + sb.append('<').append(r.getLocalName()); + for (int i = 0; i < r.getAttributeCount(); i++) + sb.append(' ').append(r.getAttributeName(i)).append('=').append('\'').append(r.getAttributeValue(i)).append('\''); + sb.append('>'); + } + } else if (et == END_ELEMENT) { + Tag tag = Tag.forEvent(r); + if (! tag.isOneOf(xBR, xBS, xTB, xFF, xSTRING, xNUMBER, xBOOLEAN)) { + sb.append('<').append(r.getLocalName()).append('>'); + } + } else if (et == CHARACTERS && ! r.isWhiteSpace()) { + sb.append(r.getText().trim()); } - // Ignore all other elements. + et = r.next(); + if (et == START_ELEMENT) + depth++; + else if (et == END_ELEMENT) + depth--; + } - XMLEvent eNext = r.peek(); + String s = sb.toString(); + session.returnStringBuilder(sb); + return s; + } - if (eNext.isStartElement() || eNext.isEndElement()) { - Tag tag = Tag.forEvent(eNext); - if (! (tag.isOneOf(A, xA, BR, xBR, FF, xFF, BS, xBS, TB, xTB, STRING, xSTRING, NUMBER, xNUMBER, BOOLEAN, xBOOLEAN))) - return trim(join(strings)); - } else if (eNext.isEndDocument()) { - return trim(join(strings)); - } + private void skipCharacters(XMLStreamReader r) throws XMLStreamException { - e = r.nextEvent(); - } - } + int et = r.getEventType(); - private String trim(String s) { - int i2 = 0, i3; - for (i2 = 0; i2 < s.length(); i2++) { - char c = s.charAt(i2); - if (c != ' ') - break; - } - for (i3 = s.length(); i3 > i2; i3--) { - char c = s.charAt(i3-1); - if (c != ' ') - break; + int depth = (et == START_ELEMENT ? 1 : et == END_ELEMENT ? -1 : 0); + while (depth >= 0) { + et = r.next(); + if (et == START_ELEMENT) + depth++; + else if (et == END_ELEMENT) + depth--; } - return s.substring(i2, i3); } /* - * Reads the element text of the current element, accounting for <a> and <br> tags. <br> - * Precondition: Must be pointing at first event AFTER the start tag. + * Reads the element text of the current element, accounting for <a> and <br> tags. + * Precondition: Must be pointing at parent START_ELEMENT tag. * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event. */ - private String parseElementText(XMLEventReader r, Tag endTag) throws XMLStreamException { - - List<String> strings = new LinkedList<String>(); - - XMLEvent e = r.nextEvent(); - Tag nTag = (e.isEndElement() ? Tag.forEvent(e) : null); - - while (nTag != endTag) { - if (e.isCharacters()) - strings.add(parseCharacters(e, r)); - e = r.nextEvent(); - - if (e.getEventType() == END_ELEMENT) - nTag = Tag.forEvent(e); - - if (nTag == endTag) - return join(strings); - } + private String parseElementText(HtmlParserSession session, XMLStreamReader r/*, Tag endTag*/) throws XMLStreamException { + r.next(); + return parseCharacters(session, r); + } - return ""; + private void skipElementText(XMLStreamReader r) throws XMLStreamException { + r.next(); + skipCharacters(r); } enum Tag { @@ -548,12 +575,13 @@ public final class HtmlParser extends ReaderParser { cache.put(id, this); } - static Tag forEvent(XMLEvent event) throws XMLStreamException { - if (event.isStartElement()) - return forString(event.asStartElement().getName().getLocalPart(), false); - else if (event.isEndElement()) - return forString(event.asEndElement().getName().getLocalPart(), true); - throw new XMLStreamException("Invalid call to Tag.forEvent on event of type ["+event.getEventType()+"]"); + static Tag forEvent(XMLStreamReader r) throws XMLStreamException { + int et = r.getEventType(); + if (et == START_ELEMENT) + return forString(r.getLocalName(), false); + else if (et == END_ELEMENT) + return forString(r.getLocalName(), true); + throw new XMLStreamException("Invalid call to Tag.forEvent on event of type ["+et+"]"); } private static Tag forString(String tag, boolean end) throws XMLStreamException { @@ -617,33 +645,47 @@ public final class HtmlParser extends ReaderParser { } /* - * Reads the current tag. Advances past anything that's not a start or end tag. Throws an exception if + * Reads the next tag. Advances past anything that's not a start or end tag. Throws an exception if * it's not one of the expected tags. * Precondition: Must be pointing before the event we want to parse. * Postcondition: Pointing at the tag just parsed. */ - private Tag nextTag(XMLEventReader r, Tag...expected) throws XMLStreamException { - XMLEvent event = r.nextTag(); - Tag tag = Tag.forEvent(event); + private Tag nextTag(XMLStreamReader r, Tag...expected) throws XMLStreamException { + int et = r.next(); + + while (et != START_ELEMENT && et != END_ELEMENT && et != END_DOCUMENT) + et = r.next(); + + if (et == END_DOCUMENT) + throw new XMLStreamException("Unexpected end of document: " + r.getLocation()); + + Tag tag = Tag.forEvent(r); if (expected.length == 0) return tag; for (Tag t : expected) if (t == tag) return tag; - throw new XMLStreamException("Unexpected tag: " + tag, event.getLocation()); + + throw new XMLStreamException("Unexpected tag: " + tag + ". Expected one of the following: " + JsonSerializer.DEFAULT.toString(expected), r.getLocation()); } - private String join(List<String> s) { - if (s.size() == 0) - return ""; - if (s.size() == 1) - return s.get(0); - StringBuilder sb = new StringBuilder(); - for (String ss : s) - sb.append(ss); - return sb.toString(); + private void skipTag(XMLStreamReader r, Tag...expected) throws XMLStreamException { + Tag tag = Tag.forEvent(r); + if (tag.isOneOf(expected)) + r.next(); + else + throw new XMLStreamException("Unexpected tag: " + tag + ". Expected one of the following: " + JsonSerializer.DEFAULT.toString(expected), r.getLocation()); } + + private int skipWs(XMLStreamReader r) throws XMLStreamException { + int event = r.getEventType(); + while (event != START_ELEMENT && event != END_ELEMENT && event != END_DOCUMENT && r.isWhiteSpace()) + event = r.next(); + return event; + } + + //-------------------------------------------------------------------------------- // Overridden methods //-------------------------------------------------------------------------------- @@ -657,25 +699,25 @@ public final class HtmlParser extends ReaderParser { protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception { HtmlParserSession s = (HtmlParserSession)session; type = s.normalizeClassMeta(type); - return parseAnything(s, type, s.getXmlEventReader(), s.getOuter(), null); + return parseAnything(s, type, s.getXmlStreamReader(), s.getOuter(), true, null); } @Override /* ReaderParser */ protected <K,V> Map<K,V> doParseIntoMap(ParserSession session, Map<K,V> m, Type keyType, Type valueType) throws Exception { HtmlParserSession s = (HtmlParserSession)session; - return parseIntoMap(s, s.getXmlEventReader(), m, s.getClassMeta(keyType), s.getClassMeta(valueType), null); + return parseIntoMap(s, s.getXmlStreamReader(), m, s.getClassMeta(keyType), s.getClassMeta(valueType), null); } @Override /* ReaderParser */ protected <E> Collection<E> doParseIntoCollection(ParserSession session, Collection<E> c, Type elementType) throws Exception { HtmlParserSession s = (HtmlParserSession)session; - return parseIntoCollection(s, s.getXmlEventReader(), c, s.getClassMeta(elementType), null); + return parseIntoCollection(s, s.getXmlStreamReader(), c, s.getClassMeta(elementType), null); } @Override /* ReaderParser */ protected Object[] doParseArgs(ParserSession session, ClassMeta<?>[] argTypes) throws Exception { HtmlParserSession s = (HtmlParserSession)session; - return parseArgs(s, s.getXmlEventReader(), argTypes); + return parseArgs(s, s.getXmlStreamReader(), argTypes); } @Override /* CoreApi */ @@ -734,10 +776,6 @@ public final class HtmlParser extends ReaderParser { @Override /* Lockable */ public HtmlParser clone() { - try { - return (HtmlParser)super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); // Shouldn't happen - } + return (HtmlParser)super.clone(); } }
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java index 49808d1..a362bdc 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java @@ -13,7 +13,7 @@ package org.apache.juneau.html; import org.apache.juneau.*; -import org.apache.juneau.parser.*; +import org.apache.juneau.xml.*; /** * Configurable properties on the {@link HtmlParser} class. @@ -46,7 +46,7 @@ import org.apache.juneau.parser.*; * </ul> * </ul> */ -public final class HtmlParserContext extends ParserContext { +public final class HtmlParserContext extends XmlParserContext { /** * Constructor. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java index 893a1df..5d3c3bf 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java @@ -19,15 +19,14 @@ import java.util.*; import javax.xml.stream.*; import org.apache.juneau.*; -import org.apache.juneau.internal.*; -import org.apache.juneau.parser.*; +import org.apache.juneau.xml.*; /** * Session object that lives for the duration of a single use of {@link HtmlParser}. * <p> * This class is NOT thread safe. It is meant to be discarded after one-time use. */ -public final class HtmlParserSession extends ParserSession { +public final class HtmlParserSession extends XmlParserSession { private XMLEventReader xmlEventReader; @@ -57,23 +56,6 @@ public final class HtmlParserSession extends ParserSession { super(ctx, op, input, javaMethod, outer, locale, timeZone); } - /** - * Wraps the specified reader in an {@link XMLEventReader}. - * This event reader gets closed by the {@link #close()} method. - * - * @param in The reader to read from. - * @param estimatedSize The estimated size of the input. If <code>-1</code>, uses a default size of <code>8196</code>. - * @return A new XML event reader using a new {@link XMLInputFactory}. - * @throws ParseException - */ - final XMLEventReader getXmlEventReader() throws Exception { - Reader r = IOUtils.getBufferedReader(super.getReader()); - XMLInputFactory factory = XMLInputFactory.newInstance(); - factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); - this.xmlEventReader = factory.createXMLEventReader(r); - return xmlEventReader; - } - @Override /* ParserSession */ public boolean close() { if (super.close()) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java index 647e746..44c50b9 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java @@ -104,9 +104,9 @@ public final class HtmlSchemaDocSerializer extends HtmlDocSerializer { type = "number"; else if (sType.isBoolean()) type = "boolean"; - else if (sType.isBean() || sType.isMap()) + else if (sType.isMapOrBean()) type = "object"; - else if (sType.isCollection() || sType.isArray()) + else if (sType.isCollectionOrArray()) type = "array"; else type = "any"; @@ -120,7 +120,7 @@ public final class HtmlSchemaDocSerializer extends HtmlDocSerializer { if (aType != null) { if (sType.isEnum()) out.put("enum", getEnumStrings((Class<Enum<?>>)sType.getInnerClass())); - else if (sType.isCollection() || sType.isArray()) { + else if (sType.isCollectionOrArray()) { ClassMeta componentType = sType.getElementType(); if (sType.isCollection() && isParentClass(Set.class, sType.getInnerClass())) out.put("uniqueItems", true); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java index 63f9fe7..adcb891 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java @@ -13,6 +13,7 @@ package org.apache.juneau.html; import static org.apache.juneau.serializer.SerializerContext.*; +import static org.apache.juneau.html.HtmlSerializer.ContentResult.*; import java.io.*; import java.lang.reflect.*; @@ -165,7 +166,7 @@ public class HtmlSerializer extends XmlSerializer { * @throws IOException If a problem occurred trying to send output to the writer. */ private HtmlWriter doSerialize(HtmlSerializerSession session, Object o, HtmlWriter w) throws Exception { - serializeAnything(session, w, o, null, null, session.getInitialDepth()-1, null); + serializeAnything(session, w, o, null, null, session.getInitialDepth()-1, null, true); return w; } @@ -179,13 +180,15 @@ public class HtmlSerializer extends XmlSerializer { * @param name The attribute name of this object if this object was a field in a JSON object (i.e. key of a {@link java.util.Map.Entry} or property name of a bean). * @param indent The current indentation value. * @param pMeta The bean property being serialized, or <jk>null</jk> if we're not serializing a bean property. - * + * @param isRoot <jk>true</jk> if this is the root element of the document. + * @return The type of content encountered. Either simple (no whitespace) or normal (elements with whitespace). * @throws Exception If a problem occurred trying to convert the output. */ @SuppressWarnings({ "rawtypes", "unchecked" }) - protected void serializeAnything(HtmlSerializerSession session, HtmlWriter out, Object o, ClassMeta<?> eType, String name, int indent, BeanPropertyMeta pMeta) throws Exception { + protected ContentResult serializeAnything(HtmlSerializerSession session, HtmlWriter out, Object o, ClassMeta<?> eType, String name, int indent, BeanPropertyMeta pMeta, boolean isRoot) throws Exception { ClassMeta<?> aType = null; // The actual type + ClassMeta<?> wType = null; // The wrapped type (delegate) ClassMeta<?> sType = object(); // The serialized type if (eType == null) @@ -200,17 +203,25 @@ public class HtmlSerializer extends XmlSerializer { } session.indent += indent; - int i = session.indent; + + ContentResult cr = CR_NORMAL; // Determine the type. - if (o == null || (aType.isChar() && ((Character)o).charValue() == 0)) - out.tag(i, "null").nl(); - else { + if (o == null || (aType.isChar() && ((Character)o).charValue() == 0)) { + out.tag("null"); + cr = ContentResult.CR_SIMPLE; + + } else { + + if (aType.isDelegate()) { + wType = aType; + aType = ((Delegate)o).getClassMeta(); + } sType = aType.getSerializedClassMeta(); String typeName = null; if (session.isAddBeanTypeProperties() && ! eType.equals(aType)) - typeName = aType.getDictionaryName(); + typeName = aType.getResolvedDictionaryName(); // Swap if necessary PojoSwap swap = aType.getPojoSwap(); @@ -225,59 +236,107 @@ public class HtmlSerializer extends XmlSerializer { HtmlClassMeta html = sType.getExtendedMeta(HtmlClassMeta.class); - if (html.isAsXml() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isAsXml())) - super.serializeAnything(session, out, o, null, null, null, false, XmlFormat.NORMAL, null); - else if (html.isAsPlainText() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isAsPlainText())) + if (html.isAsXml() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isAsXml())) { + super.serializeAnything(session, out, o, null, null, null, false, XmlFormat.MIXED, false, null); + + } else if (html.isAsPlainText() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isAsPlainText())) { out.write(o == null ? "null" : o.toString()); - else if (o == null || (sType.isChar() && ((Character)o).charValue() == 0)) - out.tag(i, "null").nl(); - else if (sType.hasToObjectMapMethod()) - serializeMap(session, out, sType.toObjectMap(o), eType, typeName, pMeta); - else if (sType.isBean()) - serializeBeanMap(session, out, session.toBeanMap(o), pMeta); - else if (sType.isNumber()) - out.sTag(i, "number").append(o).eTag("number").nl(); - else if (sType.isBoolean()) - out.sTag(i, "boolean").append(o).eTag("boolean").nl(); - else if (sType.isMap()) { + cr = CR_SIMPLE; + + } else if (o == null || (sType.isChar() && ((Character)o).charValue() == 0)) { + out.tag("null"); + cr = CR_SIMPLE; + + } else if (sType.isNumber()) { + if (eType.isNumber()) + out.append(o); + else + out.sTag("number").append(o).eTag("number"); + cr = CR_SIMPLE; + + } else if (sType.isBoolean()) { + if (eType.isBoolean()) + out.append(o); + else + out.sTag("boolean").append(o).eTag("boolean"); + cr = CR_SIMPLE; + + } else if (sType.hasToObjectMapMethod()) { + out.nlIf(! isRoot); + serializeMap(session, out, sType.toObjectMap(o), sType, null, null, typeName, pMeta); + + } else if (sType.isMap() || (wType != null && wType.isMap())) { + out.nlIf(! isRoot); if (o instanceof BeanMap) - serializeBeanMap(session, out, (BeanMap)o, pMeta); + serializeBeanMap(session, out, (BeanMap)o, eType, pMeta); else - serializeMap(session, out, (Map)o, eType, typeName, pMeta); - } - else if (sType.isCollection()) { - serializeCollection(session, out, (Collection)o, eType, name, pMeta); - } - else if (sType.isArray()) { - serializeCollection(session, out, toList(sType.getInnerClass(), o), eType, name, pMeta); - } - else if (session.isUri(sType, pMeta, o)) { + serializeMap(session, out, (Map)o, sType, eType.getKeyType(), eType.getValueType(), typeName, pMeta); + + } else if (sType.isBean()) { + BeanMap m = session.toBeanMap(o); + Class<?> c = o.getClass(); + if (c.isAnnotationPresent(HtmlLink.class)) { + HtmlLink h = o.getClass().getAnnotation(HtmlLink.class); + Object urlProp = m.get(h.hrefProperty()); + Object nameProp = m.get(h.nameProperty()); + out.oTag("a").attrUri("href", urlProp).append('>').encodeText(nameProp).eTag("a"); + cr = CR_SIMPLE; + } else { + out.nlIf(! isRoot); + serializeBeanMap(session, out, m, eType, pMeta); + } + + } else if (sType.isCollection() || sType.isArray() || (wType != null && wType.isCollection())) { + out.nlIf(! isRoot); + serializeCollection(session, out, o, sType, eType, name, pMeta); + + } else if (session.isUri(sType, pMeta, o)) { String label = session.getAnchorText(pMeta, o); - out.oTag(i, "a").attrUri("href", o).append('>'); + out.oTag("a").attrUri("href", o).append('>'); out.append(label); - out.eTag("a").nl(); + out.eTag("a"); + cr = CR_SIMPLE; + + } else { + if (isRoot) + out.sTag("string").encodeText(session.toString(o)).eTag("string"); + else + out.encodeText(session.toString(o)); + cr = CR_SIMPLE; } - else - out.sTag(i, "string").encodeText(session.toString(o)).eTag("string").nl(); } session.pop(); session.indent -= indent; + return cr; + } + + /** + * Identifies what the contents were of a serialized bean. + */ + static enum ContentResult { + CR_SIMPLE, // Simple content. Shouldn't use whitespace. + CR_NORMAL // Normal content. Use whitespace. } @SuppressWarnings({ "rawtypes", "unchecked" }) - private void serializeMap(HtmlSerializerSession session, HtmlWriter out, Map m, ClassMeta<?> type, String typeName, BeanPropertyMeta ppMeta) throws Exception { - ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType(); + private void serializeMap(HtmlSerializerSession session, HtmlWriter out, Map m, ClassMeta<?> sType, ClassMeta<?> eKeyType, ClassMeta<?> eValueType, String typeName, BeanPropertyMeta ppMeta) throws Exception { + + ClassMeta<?> keyType = eKeyType == null ? sType.getKeyType() : eKeyType; + ClassMeta<?> valueType = eValueType == null ? sType.getValueType() : eValueType; ClassMeta<?> aType = session.getClassMetaForObject(m); // The actual type int i = session.getIndent(); - if (typeName == null) - typeName = "object"; - out.oTag(i, "table").attr(session.getBeanTypePropertyName(), typeName); + + out.oTag(i, "table"); + + if (typeName != null && ppMeta != null && ppMeta.getClassMeta() != aType) + out.attr(session.getBeanTypePropertyName(), typeName); + out.appendln(">"); if (session.isAddKeyValueTableHeaders() && ! (aType.getExtendedMeta(HtmlClassMeta.class).isNoTableHeaders() || (ppMeta != null && ppMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isNoTableHeaders()))) { out.sTag(i+1, "tr").nl(); - out.sTag(i+2, "th").nl().appendln(i+3, "<string>key</string>").eTag(i+2, "th").nl(); - out.sTag(i+2, "th").nl().appendln(i+3, "<string>value</string>").eTag(i+2, "th").nl(); + out.sTag(i+2, "th").append("key").eTag("th").nl(); + out.sTag(i+2, "th").append("value").eTag("th").nl(); out.eTag(i+1, "tr").nl(); } for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) { @@ -293,40 +352,35 @@ public class HtmlSerializer extends XmlSerializer { } out.sTag(i+1, "tr").nl(); - out.sTag(i+2, "td").nl(); - serializeAnything(session, out, key, keyType, null, 2, null); - out.eTag(i+2, "td").nl(); - out.sTag(i+2, "td").nl(); - serializeAnything(session, out, value, valueType, (key == null ? "_x0000_" : key.toString()), 2, null); - out.eTag(i+2, "td").nl(); + out.sTag(i+2, "td"); + ContentResult cr = serializeAnything(session, out, key, keyType, null, 2, null, false); + if (cr == CR_NORMAL) + out.i(i+2); + out.eTag("td").nl(); + out.sTag(i+2, "td"); + cr = serializeAnything(session, out, value, valueType, (key == null ? "_x0000_" : key.toString()), 2, null, false); + if (cr == CR_NORMAL) + out.i(i+2); + out.eTag("td").nl(); out.eTag(i+1, "tr").nl(); } out.eTag(i, "table").nl(); } - private void serializeBeanMap(HtmlSerializerSession session, HtmlWriter out, BeanMap<?> m, BeanPropertyMeta ppMeta) throws Exception { + private void serializeBeanMap(HtmlSerializerSession session, HtmlWriter out, BeanMap<?> m, ClassMeta<?> eType, BeanPropertyMeta ppMeta) throws Exception { int i = session.getIndent(); - Object o = m.getBean(); - - Class<?> c = o.getClass(); - if (c.isAnnotationPresent(HtmlLink.class)) { - HtmlLink h = o.getClass().getAnnotation(HtmlLink.class); - Object urlProp = m.get(h.hrefProperty()); - Object nameProp = m.get(h.nameProperty()); - out.oTag(i, "a").attrUri("href", urlProp).append('>').encodeText(nameProp).eTag("a").nl(); - return; - } + out.oTag(i, "table"); String typeName = m.getMeta().getDictionaryName(); - if (typeName == null) - typeName = "object"; - out.oTag(i, "table").attr(session.getBeanTypePropertyName(), typeName); + if (typeName != null && eType != m.getClassMeta()) + out.attr(session.getBeanTypePropertyName(), typeName); + out.append('>').nl(); if (session.isAddKeyValueTableHeaders() && ! (m.getClassMeta().getExtendedMeta(HtmlClassMeta.class).isNoTableHeaders() || (ppMeta != null && ppMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isNoTableHeaders()))) { out.sTag(i+1, "tr").nl(); - out.sTag(i+2, "th").nl().appendln(i+3, "<string>key</string>").eTag(i+2, "th").nl(); - out.sTag(i+2, "th").nl().appendln(i+3, "<string>value</string>").eTag(i+2, "th").nl(); + out.sTag(i+2, "th").append("key").eTag("th").nl(); + out.sTag(i+2, "th").append("value").eTag("th").nl(); out.eTag(i+1, "tr").nl(); } @@ -344,31 +398,34 @@ public class HtmlSerializer extends XmlSerializer { continue; out.sTag(i+1, "tr").nl(); - out.sTag(i+2, "td").nl(); - out.sTag(i+3, "string").encodeText(key).eTag("string").nl(); - out.eTag(i+2, "td").nl(); - out.sTag(i+2, "td").nl(); + out.sTag(i+2, "td").encodeText(key).eTag("td").nl(); + out.sTag(i+2, "td"); try { - serializeAnything(session, out, value, cMeta, key, 2, pMeta); + ContentResult cr = serializeAnything(session, out, value, cMeta, key, 2, pMeta, false); + if (cr == CR_NORMAL) + out.i(i+2); } catch (SerializeException e) { throw e; } catch (Error e) { throw e; } catch (Throwable e) { + e.printStackTrace(); session.addBeanGetterWarning(pMeta, e); } - out.eTag(i+2, "td").nl(); + out.eTag("td").nl(); out.eTag(i+1, "tr").nl(); } out.eTag(i, "table").nl(); } @SuppressWarnings({ "rawtypes", "unchecked" }) - private void serializeCollection(HtmlSerializerSession session, HtmlWriter out, Collection c, ClassMeta<?> type, String name, BeanPropertyMeta ppMeta) throws Exception { + private void serializeCollection(HtmlSerializerSession session, HtmlWriter out, Object in, ClassMeta<?> sType, ClassMeta<?> eType, String name, BeanPropertyMeta ppMeta) throws Exception { + + ClassMeta<?> seType = sType.getElementType(); + if (seType == null) + seType = session.object(); - ClassMeta<?> elementType = type.getElementType(); - if (elementType == null) - elementType = session.object(); + Collection c = (sType.isCollection() ? (Collection)in : toList(sType.getInnerClass(), in)); int i = session.getIndent(); if (c.isEmpty()) { @@ -376,17 +433,25 @@ public class HtmlSerializer extends XmlSerializer { return; } + String type2 = null; + if (sType != eType) + type2 = sType.getResolvedDictionaryName(); + if (type2 == null) + type2 = "array"; + c = session.sort(c); + HtmlBeanPropertyMeta hbpMeta = (ppMeta == null ? null : ppMeta.getExtendedMeta(HtmlBeanPropertyMeta.class)); + String btpn = session.getBeanTypePropertyName(); + // Look at the objects to see how we're going to handle them. Check the first object to see how we're going to handle this. // If it's a map or bean, then we'll create a table. // Otherwise, we'll create a list. - String[] th = getTableHeaders(session, c, ppMeta); + String[] th = getTableHeaders(session, c, hbpMeta); if (th != null) { - out.oTag(i, "table").attr(session.getBeanTypePropertyName(), "array"); - out.append('>').nl(); + out.oTag(i, "table").attr(btpn, type2).append('>').nl(); out.sTag(i+1, "tr").nl(); for (String key : th) out.sTag(i+2, "th").append(key).eTag("th").nl(); @@ -401,21 +466,24 @@ public class HtmlSerializer extends XmlSerializer { cm = cm.getSerializedClassMeta(); } - if (cm != null && session.isAddBeanTypeProperties() && elementType.getInnerClass() != o.getClass()) - out.oTag(i+1, "tr").attr(session.getBeanTypePropertyName(), cm.getDictionaryName()).append('>').nl(); - else - out.sTag(i+1, "tr").nl(); + out.oTag(i+1, "tr"); + String typeName = (cm == null ? null : cm.getDictionaryName()); + if (typeName != null && sType.getElementType() != cm) + out.attr(btpn, typeName); + out.cTag().nl(); if (cm == null) { - serializeAnything(session, out, o, null, null, 1, null); + serializeAnything(session, out, o, null, null, 1, null, false); } else if (cm.isMap() && ! (cm.isBeanMap())) { Map m2 = session.sort((Map)o); for (String k : th) { - out.sTag(i+2, "td").nl(); - serializeAnything(session, out, m2.get(k), elementType, k, 2, null); - out.eTag(i+2, "td").nl(); + out.sTag(i+2, "td"); + ContentResult cr = serializeAnything(session, out, m2.get(k), seType, k, 2, null, false); + if (cr == CR_NORMAL) + out.i(i+2); + out.eTag("td").nl(); } } else { BeanMap m2 = null; @@ -427,9 +495,11 @@ public class HtmlSerializer extends XmlSerializer { for (String k : th) { BeanMapEntry p = m2.getProperty(k); BeanPropertyMeta pMeta = p.getMeta(); - out.sTag(i+2, "td").nl(); - serializeAnything(session, out, p.getValue(), pMeta.getClassMeta(), p.getKey().toString(), 2, pMeta); - out.eTag(i+2, "td").nl(); + out.sTag(i+2, "td"); + ContentResult cr = serializeAnything(session, out, p.getValue(), pMeta.getClassMeta(), p.getKey().toString(), 2, pMeta, false); + if (cr == CR_NORMAL) + out.i(i+2); + out.eTag("td").nl(); } } out.eTag(i+1, "tr").nl(); @@ -437,11 +507,16 @@ public class HtmlSerializer extends XmlSerializer { out.eTag(i, "table").nl(); } else { - out.sTag(i, "ul").nl(); + out.oTag(i, "ul"); + if (! type2.equals("array")) + out.attr(btpn, type2); + out.append('>').nl(); for (Object o : c) { - out.sTag(i+1, "li").nl(); - serializeAnything(session, out, o, elementType, name, 1, null); - out.eTag(i+1, "li").nl(); + out.sTag(i+1, "li"); + ContentResult cr = serializeAnything(session, out, o, seType, name, 1, null, false); + if (cr == CR_NORMAL) + out.i(i+1); + out.eTag("li").nl(); } out.eTag(i, "ul").nl(); } @@ -453,7 +528,7 @@ public class HtmlSerializer extends XmlSerializer { * 2-dimensional tables are used for collections of objects that all have the same set of property names. */ @SuppressWarnings({ "rawtypes", "unchecked" }) - private String[] getTableHeaders(SerializerSession session, Collection c, BeanPropertyMeta pMeta) throws Exception { + private String[] getTableHeaders(SerializerSession session, Collection c, HtmlBeanPropertyMeta hbpMeta) throws Exception { if (c.size() == 0) return null; c = session.sort(c); @@ -474,14 +549,14 @@ public class HtmlSerializer extends XmlSerializer { o1 = f.swap(session, o1); cm = cm.getSerializedClassMeta(); } - if (cm == null || ! (cm.isMap() || cm.isBean())) + if (cm == null || ! cm.isMapOrBean()) return null; if (cm.getInnerClass().isAnnotationPresent(HtmlLink.class)) return null; HtmlClassMeta h = cm.getExtendedMeta(HtmlClassMeta.class); - if (h.isNoTables() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isNoTables())) + if (h.isNoTables() || (hbpMeta != null && hbpMeta.isNoTables())) return null; - if (h.isNoTableHeaders() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isNoTableHeaders())) + if (h.isNoTableHeaders() || (hbpMeta != null && hbpMeta.isNoTableHeaders())) return new String[0]; if (session.canIgnoreValue(cm, null, o1)) return null; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java index cf6a3a9..5da552e 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java @@ -67,12 +67,12 @@ public class HtmlWriter extends XmlWriter { append(">"); else if (test == '\n') append("<br/>"); - else if (test == '\f') + else if (test == '\f') // XML 1.0 doesn't support formfeeds or backslashes, so we have to invent something. append("<ff/>"); else if (test == '\b') append("<bs/>"); else if (test == '\t') - append("<tb> </tb>"); + append("<tb> </tb>"); else if (Character.isISOControl(test)) append("&#" + (int) test + ";"); else @@ -258,7 +258,8 @@ public class HtmlWriter extends XmlWriter { @Override /* SerializerWriter */ public HtmlWriter cr(int depth) throws IOException { - super.cr(depth); + if (depth > 0) + super.cr(depth); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/A.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/A.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/A.java deleted file mode 100644 index b922c2d..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/A.java +++ /dev/null @@ -1,54 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import static org.apache.juneau.xml.annotation.XmlFormat.*; - -import org.apache.juneau.annotation.*; -import org.apache.juneau.xml.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-a-element'><a></a> element. - * <p> - */ -@Bean(typeName="a") -@SuppressWarnings("javadoc") -public class A extends HtmlElement { - - /** <code>name</code> attribute */ - @Xml(format=ATTR) - public String name; - - /** <code>href</code> attribute */ - @Xml(format=ATTR) - public String href; - - /** Content */ - @Xml(format=CONTENT) - public String text; - - public A setName(String name) { - this.name = name; - return this; - } - - public A setHref(String href) { - this.href = href; - return this; - } - - public A setText(String text) { - this.text = text; - return this; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Abbr.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Abbr.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Abbr.java deleted file mode 100644 index 8327f54..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Abbr.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-abbr-element'><abbr></a> element. - * <p> - */ -@Bean(typeName="abbr") -public class Abbr extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Address.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Address.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Address.java deleted file mode 100644 index 5ad7149..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Address.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/sections.html#the-address-element'><address></a> element. - * <p> - */ -@Bean(typeName="address") -public class Address extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Area.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Area.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Area.java deleted file mode 100644 index 88a3cda..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Area.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/embedded-content-0.html#the-area-element'><area></a> element. - * <p> - */ -@Bean(typeName="area") -public class Area extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Article.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Article.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Article.java deleted file mode 100644 index c477bec..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Article.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/sections.html#the-article-element'><article></a> element. - * <p> - */ -@Bean(typeName="article") -public class Article extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Aside.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Aside.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Aside.java deleted file mode 100644 index c449a3f..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Aside.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/sections.html#the-aside-element'><aside></a> element. - * <p> - */ -@Bean(typeName="aside") -public class Aside extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Audio.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Audio.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Audio.java deleted file mode 100644 index 245151f..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Audio.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/embedded-content-0.html#the-audio-element'><audio></a> element. - * <p> - */ -@Bean(typeName="audio") -public class Audio extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/B.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/B.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/B.java deleted file mode 100644 index 5c67cda..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/B.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-b-element'><b></a> element. - * <p> - */ -@Bean(typeName="b") -public class B extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Base.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Base.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Base.java deleted file mode 100644 index 8ff9f82..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Base.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/document-metadata.html#the-base-element'><base></a> element. - * <p> - */ -@Bean(typeName="base") -public class Base extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdi.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdi.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdi.java deleted file mode 100644 index 1c03e6c..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdi.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-bdi-element'><bdi></a> element. - * <p> - */ -@Bean(typeName="bdi") -public class Bdi extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdo.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdo.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdo.java deleted file mode 100644 index 6b623c2..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Bdo.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-bdo-element'><bdo></a> element. - * <p> - */ -@Bean(typeName="bdo") -public class Bdo extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Blockquote.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Blockquote.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Blockquote.java deleted file mode 100644 index 69e2357..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Blockquote.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/grouping-content.html#the-blockquote-element'><blockquote></a> element. - * <p> - */ -@Bean(typeName="blockquote") -public class Blockquote extends HtmlElement { -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Body.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Body.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Body.java deleted file mode 100644 index 44dd40f..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Body.java +++ /dev/null @@ -1,23 +0,0 @@ -// *************************************************************************************************************************** -// * 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 org.apache.juneau.html.dto.proto; - -import org.apache.juneau.annotation.*; - -/** - * DTO for an HTML <a href='https://www.w3.org/TR/html5/sections.html#the-body-element'><body></a> element. - * <p> - */ -@Bean(typeName="body") -public class Body extends HtmlElement { -}
