@Override public Person parseAuthor(Element element) { checkNotNull(element); Person author = new Person(); parseElement(element, author); return author; }
/** * Generates XML. * <p> * Designed to be used by {@link ExtensionPoint} types that reuse Person. */ @Override protected void generate(XmlWriter w, ExtensionProfile p, XmlNamespace namespace, String localName, List<Attribute> attrs, AttributeGenerator generator) throws IOException { generate(p, w, namespace, localName, attrs); }
private void parseHCard(Element element, Person author) { NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) node; if (hasClass(child, "fn")) { author.setName(child.getTextContent()); String href = child.getAttribute("href"); if (href.startsWith("mailto:") && (author.getEmail() == null)) { author.setEmail(href.substring(7)); } } else if (hasClass(child, "n")) { author.setName(child.getTextContent()); } else if (hasClass(child, "email")) { author.setEmail(child.getTextContent()); } else { parseHCard(child, author); } } } } }
/** * Creates a new hCard element for the given entry. */ static XmlElement getAuthorElement(BaseContentEntry<?> entry) { checkNotNull(entry); XmlElement element = new XmlElement("span"); element.setAttribute("class", "author"); XmlElement vcard = new XmlElement("span"); vcard.setAttribute("class", "vcard"); Person author = entry.getAuthors().get(0); String name = author.getName(); String email = author.getEmail(); if (name == null) { name = "[no name found]"; } if (email == null) { email = "[no email found]"; } if (name == null) { XmlElement link = getHyperLink("mailto:" + email, email); link.setAttribute("class", "email"); vcard.addElement(link); } else { XmlElement link = getHyperLink("mailto:" + email, name); link.setAttribute("class", "fn"); vcard.addElement(link); } return element.addElement(vcard); }
throws IOException { generateStartElement(w, elementNamespace, elementName, attributes, null); generateExtensions(w, extProfile);
/** * Adds a user-specific folder that parents this document * * @param owner the owner of the folder * @param folderName the name of the folder * @deprecated use {@link #addLink(Link)} with link relation PARENT_NAMESPACE * instead. */ @Deprecated public void addFolder(Person owner, String folderName) { String scheme = FOLDERS_NAMESPACE + "/" + owner.getEmail(); Category folderCategory = new Category(scheme, folderName, folderName); this.getCategories().add(folderCategory); }
author.generateAtom(extProfile, w, "author"); contributor.generateAtom(extProfile, w, "contributor");
author.generateRss(w, "author"); contributor.generateRss(w, "author");
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(CommentAuthor.class)) { return; } super.declareExtensions(extProfile); extProfile.declare(CommentAuthor.class, GphotoNickname.class); extProfile.declare(CommentAuthor.class, GphotoThumbnail.class); extProfile.declare(CommentAuthor.class, GphotoUsername.class); }
throws IOException { generateStartElement(w, elementNamespace, elementName, attributes, null); generateExtensions(w, extProfile);
/** * Adds a user-specific folder that parents this document * * @param owner the owner of the folder * @param folderName the name of the folder * @deprecated use {@link #addLink(Link)} with link relation PARENT_NAMESPACE * instead. */ @Deprecated public void addFolder(Person owner, String folderName) { String scheme = FOLDERS_NAMESPACE + "/" + owner.getEmail(); Category folderCategory = new Category(scheme, folderName, folderName); this.getCategories().add(folderCategory); }
author.generateAtom(extProfile, w, "author"); contributor.generateAtom(extProfile, w, "contributor");
author.generateRss(w, "author"); contributor.generateRss(w, "author");
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(CommentAuthor.class)) { return; } super.declareExtensions(extProfile); extProfile.declare(CommentAuthor.class, GphotoNickname.class); extProfile.declare(CommentAuthor.class, GphotoThumbnail.class); extProfile.declare(CommentAuthor.class, GphotoUsername.class); }
throws IOException { generateStartElement(w, elementNamespace, elementName, attributes, null); generateExtensions(w, extProfile);
/** * Adds a user-specific folder that parents this document * * @param owner the owner of the folder * @param folderName the name of the folder * @deprecated use {@link #addLink(Link)} with link relation PARENT_NAMESPACE * instead. */ @Deprecated public void addFolder(Person owner, String folderName) { String scheme = FOLDERS_NAMESPACE + "/" + owner.getEmail(); Category folderCategory = new Category(scheme, folderName, folderName); this.getCategories().add(folderCategory); }