Source code: org/intabulas/sandler/elements/impl/AuthorImpl.java
1 /**
2 * Copyright (c) 2003, Mark Lussier
3 * All rights reserved.
4 *
5 * Portions Copyright (c) 2003 by David A. Czarnecki
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * Neither the name of the "Mark Lussier" and "Sandler" nor the names of
16 * its contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 * Products derived from this software may not be called "Sandler",
19 * nor may "Sandler" appear in their name, without prior written permission of
20 * Mark Lussier
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
26 * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 package org.intabulas.sandler.elements.impl;
37
38 import org.intabulas.sandler.elements.AtomElement;
39 import org.intabulas.sandler.elements.Author;
40 import org.xmlpull.v1.XmlPullParser;
41 import org.xmlpull.v1.XmlPullParserException;
42
43 import java.io.IOException;
44
45 /**
46 * AuthorImpl
47 *
48 * @author Mark Lussier
49 * @version $Id: AuthorImpl.java,v 1.2 2003/09/09 23:44:44 intabulas Exp $
50 */
51 public class AuthorImpl extends AbstractIdentityElement implements Author, AtomElement {
52
53 public AuthorImpl() {
54 }
55
56 /**
57 * Returns a string representation of the object.
58 *
59 * @return a String representation of the object.
60 */
61 public String toString() {
62 StringBuffer buffer = new StringBuffer(HTMLTAG_START).append(ELEMENT_AUTHOR).append(HTMLTAG_CLOSE);
63 buffer.append(super.toString());
64 buffer.append(HTMLTAG_BEGIN).append(ELEMENT_AUTHOR).append(HTMLTAG_CLOSE);
65 return buffer.toString();
66
67 }
68
69 public void loadDocument(XmlPullParser parser) throws XmlPullParserException {
70 int eventType = parser.getEventType();
71 do {
72 if (eventType == XmlPullParser.START_TAG) {
73 if (parser.getName().equals(ELEMENT_NAME)) {
74 try {
75 setName(parser.nextText());
76 } catch (IOException e) {
77 e.printStackTrace();
78 }
79 } else if (parser.getName().equals(ELEMENT_EMAIL)) {
80 try {
81 setEmail(parser.nextText());
82 } catch (IOException e) {
83 e.printStackTrace();
84 }
85
86 } else if (parser.getName().equals(ELEMENT_URL)) {
87 try {
88 setUrl(parser.nextText());
89 } catch (IOException e) {
90 e.printStackTrace();
91 }
92
93 } else if (parser.getName().equals(ELEMENT_HOMEPAGE)) {
94 try {
95 setUrl(parser.nextText());
96 } catch (IOException e) {
97 e.printStackTrace();
98 }
99
100 }
101 } else if (eventType == XmlPullParser.END_TAG) {
102 }
103 try {
104 eventType = parser.next();
105 } catch (XmlPullParserException e) {
106 e.printStackTrace();
107 } catch (IOException e) {
108 e.printStackTrace();
109 }
110
111 } while (!(eventType == XmlPullParser.END_TAG && ELEMENT_AUTHOR.equals(parser.getName())));
112
113 }
114
115
116 }