diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html deleted file mode 100644 index 36e9335..0000000 --- a/doc/allclasses-frame.html +++ /dev/null @@ -1,47 +0,0 @@ - - - -
- - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/deprecated-list.html b/doc/deprecated-list.html deleted file mode 100644 index 106d034..0000000 --- a/doc/deprecated-list.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/help-doc.html b/doc/help-doc.html deleted file mode 100644 index def676d..0000000 --- a/doc/help-doc.html +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - -The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
-Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-Each annotation type has its own separate page with the following sections:
-Each enum has its own separate page with the following sections:
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-These links take you to the next or previous class, interface, package, or related page.
-These links show and hide the HTML frames. All pages are available with or without frames.
-The All Classes link shows all classes and interfaces except non-static nested types.
-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-The Constant Field Values page lists the static final fields and their values.
-Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-1.html b/doc/index-files/index-1.html deleted file mode 100644 index aa7290e..0000000 --- a/doc/index-files/index-1.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-10.html b/doc/index-files/index-10.html deleted file mode 100644 index 5446c0d..0000000 --- a/doc/index-files/index-10.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - -JSONString
interface allows a toJSONString()
- method so that a class can change the behavior of
- JSONObject.toString()
, JSONArray.toString()
, and
- JSONWriter.value(
Object)
.Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-11.html b/doc/index-files/index-11.html deleted file mode 100644 index 79a15c7..0000000 --- a/doc/index-files/index-11.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-12.html b/doc/index-files/index-12.html deleted file mode 100644 index c3c0597..0000000 --- a/doc/index-files/index-12.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-13.html b/doc/index-files/index-13.html deleted file mode 100644 index 7315d1b..0000000 --- a/doc/index-files/index-13.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-14.html b/doc/index-files/index-14.html deleted file mode 100644 index 5ef48dc..0000000 --- a/doc/index-files/index-14.html +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - -NULL
object than to use Java's null
value.Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-15.html b/doc/index-files/index-15.html deleted file mode 100644 index dd75460..0000000 --- a/doc/index-files/index-15.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-16.html b/doc/index-files/index-16.html deleted file mode 100644 index 21a7433..0000000 --- a/doc/index-files/index-16.html +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Page
object, that is returned in listsCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-17.html b/doc/index-files/index-17.html deleted file mode 100644 index 398018e..0000000 --- a/doc/index-files/index-17.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-18.html b/doc/index-files/index-18.html deleted file mode 100644 index d0e4a09..0000000 --- a/doc/index-files/index-18.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-19.html b/doc/index-files/index-19.html deleted file mode 100644 index 7aa528c..0000000 --- a/doc/index-files/index-19.html +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-2.html b/doc/index-files/index-2.html deleted file mode 100644 index 76b9a1d..0000000 --- a/doc/index-files/index-2.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-20.html b/doc/index-files/index-20.html deleted file mode 100644 index dd7e4bd..0000000 --- a/doc/index-files/index-20.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - -toJSONString
method allows a class to produce its own JSON
- serialization.Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-21.html b/doc/index-files/index-21.html deleted file mode 100644 index b03da26..0000000 --- a/doc/index-files/index-21.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-22.html b/doc/index-files/index-22.html deleted file mode 100644 index 6af7406..0000000 --- a/doc/index-files/index-22.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-23.html b/doc/index-files/index-23.html deleted file mode 100644 index da3a44a..0000000 --- a/doc/index-files/index-23.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - -XmlRpcStruct
.Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-3.html b/doc/index-files/index-3.html deleted file mode 100644 index a2e638c..0000000 --- a/doc/index-files/index-3.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-4.html b/doc/index-files/index-4.html deleted file mode 100644 index 8b53b41..0000000 --- a/doc/index-files/index-4.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-5.html b/doc/index-files/index-5.html deleted file mode 100644 index f262b25..0000000 --- a/doc/index-files/index-5.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-6.html b/doc/index-files/index-6.html deleted file mode 100644 index cc60677..0000000 --- a/doc/index-files/index-6.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-7.html b/doc/index-files/index-7.html deleted file mode 100644 index ef81a03..0000000 --- a/doc/index-files/index-7.html +++ /dev/null @@ -1,446 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-8.html b/doc/index-files/index-8.html deleted file mode 100644 index 27e6957..0000000 --- a/doc/index-files/index-8.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index-files/index-9.html b/doc/index-files/index-9.html deleted file mode 100644 index b663075..0000000 --- a/doc/index-files/index-9.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/index.html b/doc/index.html deleted file mode 100644 index f7d64eb..0000000 --- a/doc/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - -public class Author -extends XmlRpcMapped -implements StringHeader-
Modifier and Type | -Method and Description | -
---|---|
String |
-getDisplay_name()
-Display Name of the author.
- |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
String |
-getUser_id()
-User id of the author.
- |
-
String |
-getUser_login()
-Login name of the author.
- |
-
void |
-setDisplay_name(String display_name)
-Display name of the author.
- |
-
void |
-setUser_id(String user_id)
-User id of the author.
- |
-
void |
-setUser_login(String user_login)
-Login name of the author.
- |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public String getDisplay_name()-
public String getUser_id()-
public String getUser_login()-
public void setDisplay_name(String display_name)-
display_name
- the display_name to setpublic void setUser_id(String user_id)-
user_id
- the user_id to setpublic void setUser_login(String user_login)-
user_login
- the user_login to setpublic String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Blog.html b/doc/net/bican/wordpress/Blog.html deleted file mode 100644 index b85b9f0..0000000 --- a/doc/net/bican/wordpress/Blog.html +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - -public class Blog -extends XmlRpcMapped-
Modifier and Type | -Method and Description | -
---|---|
String |
-getBlogid() |
-
String |
-getBlogName() |
-
Boolean |
-getIsAdmin() |
-
String |
-getUrl() |
-
void |
-setBlogid(String blogid) |
-
void |
-setBlogName(String blogName) |
-
void |
-setIsAdmin(Boolean isAdmin) |
-
void |
-setUrl(String url) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public Boolean getIsAdmin()-
public void setIsAdmin(Boolean isAdmin)-
isAdmin
- the isAdmin to setpublic String getBlogName()-
public void setBlogName(String blogName)-
blogName
- the blogName to setCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Category.html b/doc/net/bican/wordpress/Category.html deleted file mode 100644 index c792053..0000000 --- a/doc/net/bican/wordpress/Category.html +++ /dev/null @@ -1,453 +0,0 @@ - - - - - - -public class Category -extends XmlRpcMapped -implements StringHeader-
Modifier and Type | -Method and Description | -
---|---|
String |
-getCategoryId() |
-
String |
-getCategoryName() |
-
String |
-getDescription() |
-
String |
-getHtmlUrl() |
-
String |
-getParentId() |
-
String |
-getRssUrl() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
void |
-setCategoryId(String categoryId) |
-
void |
-setCategoryName(String categoryName) |
-
void |
-setDescription(String description) |
-
void |
-setHtmlUrl(String htmlUrl) |
-
void |
-setParentId(String parentId) |
-
void |
-setRssUrl(String rssUrl) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public String getCategoryId()-
public String getCategoryName()-
public String getDescription()-
public String getHtmlUrl()-
public String getParentId()-
public void setCategoryId(String categoryId)-
categoryId
- the categoryId to setpublic void setCategoryName(String categoryName)-
categoryName
- the categoryName to setpublic void setDescription(String description)-
description
- the description to setpublic void setHtmlUrl(String htmlUrl)-
htmlUrl
- the htmlUrl to setpublic void setParentId(String parentId)-
parentId
- the parentId to setpublic String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Comment.html b/doc/net/bican/wordpress/Comment.html deleted file mode 100644 index 3aa5028..0000000 --- a/doc/net/bican/wordpress/Comment.html +++ /dev/null @@ -1,674 +0,0 @@ - - - - - - -public class Comment -extends XmlRpcMapped -implements StringHeader-
Modifier and Type | -Method and Description | -
---|---|
static Comment |
-fromFile(File file)
-Creates a comment object from file
- |
-
String |
-getAuthor_email() |
-
String |
-getAuthor_ip() |
-
String |
-getAuthor_url() |
-
String |
-getAuthor() |
-
Integer |
-getComment_id() |
-
String |
-getContent() |
-
Date |
-getDate_created_gmt() |
-
String |
-getLink() |
-
Integer |
-getParent() |
-
Integer |
-getPost_id() |
-
String |
-getPost_title() |
-
String |
-getStatus() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
Integer |
-getUser_id() |
-
void |
-setAuthor_email(String authorEmail) |
-
void |
-setAuthor_ip(String authorIp) |
-
void |
-setAuthor_url(String authorUrl) |
-
void |
-setAuthor(String author) |
-
void |
-setComment_id(Integer commentId) |
-
void |
-setContent(String content) |
-
void |
-setDate_created_gmt(Date dateCreatedGmt) |
-
void |
-setLink(String link) |
-
void |
-setParent(Integer parent) |
-
void |
-setPost_id(Integer postId) |
-
void |
-setPost_title(String postTitle) |
-
void |
-setStatus(String status) |
-
void |
-setUser_id(Integer userId) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public Date getDate_created_gmt()-
public void setDate_created_gmt(Date dateCreatedGmt)-
dateCreatedGmt
- the date_created_gmt to setpublic Integer getUser_id()-
public void setUser_id(Integer userId)-
userId
- the user_id to setpublic Integer getComment_id()-
public void setComment_id(Integer commentId)-
commentId
- the comment_id to setpublic String getContent()-
public void setContent(String content)-
content
- the content to setpublic Integer getPost_id()-
public void setPost_id(Integer postId)-
postId
- the post_id to setpublic String getPost_title()-
public void setPost_title(String postTitle)-
postTitle
- the post_title to setpublic String getAuthor_url()-
public void setAuthor_url(String authorUrl)-
authorUrl
- the author_url to setpublic String getAuthor_email()-
public void setAuthor_email(String authorEmail)-
authorEmail
- the author_email to setpublic String getAuthor_ip()-
public void setAuthor_ip(String authorIp)-
authorIp
- the author_ip to setpublic String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
public static Comment fromFile(File file) - throws FileNotFoundException, - IOException, - InvalidPostFormatException-
file
- input fileFileNotFoundException
IOException
InvalidPostFormatException
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/CommentCount.html b/doc/net/bican/wordpress/CommentCount.html deleted file mode 100644 index 85ff94b..0000000 --- a/doc/net/bican/wordpress/CommentCount.html +++ /dev/null @@ -1,397 +0,0 @@ - - - - - - -public class CommentCount -extends XmlRpcMapped -implements StringHeader-
Constructor and Description | -
---|
CommentCount() |
-
Modifier and Type | -Method and Description | -
---|---|
Integer |
-getApproved() |
-
Integer |
-getAwaiting_moderation() |
-
Integer |
-getSpam() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
Integer |
-getTotal_comments() |
-
void |
-setApproved(Integer approved) |
-
void |
-setAwaiting_moderation(Integer awaitingModeration) |
-
void |
-setSpam(Integer spam) |
-
void |
-setTotal_comments(Integer totalComments) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public CommentCount()-
public Integer getApproved()-
public void setApproved(Integer approved)-
approved
- Sets number of approved comments.public Integer getAwaiting_moderation()-
public void setAwaiting_moderation(Integer awaitingModeration)-
awaitingModeration
- Number of comments awaiting moderation.public void setSpam(Integer spam)-
spam
- Number of comments that are spampublic Integer getTotal_comments()-
public void setTotal_comments(Integer totalComments)-
totalComments
- Total number of comments.public String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/CommentStatusList.html b/doc/net/bican/wordpress/CommentStatusList.html deleted file mode 100644 index 5d2833e..0000000 --- a/doc/net/bican/wordpress/CommentStatusList.html +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - -public class CommentStatusList -extends XmlRpcMapped -implements StringHeader-
Constructor and Description | -
---|
CommentStatusList() |
-
Modifier and Type | -Method and Description | -
---|---|
String |
-getApprove() |
-
String |
-getHold() |
-
String |
-getSpam() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public CommentStatusList()-
public String getApprove()-
public String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/CustomField.html b/doc/net/bican/wordpress/CustomField.html deleted file mode 100644 index 5fa3725..0000000 --- a/doc/net/bican/wordpress/CustomField.html +++ /dev/null @@ -1,409 +0,0 @@ - - - - - - -public class CustomField -extends XmlRpcMapped -implements StringHeader, JSONConvertable-
Constructor and Description | -
---|
CustomField() |
-
Modifier and Type | -Method and Description | -
---|---|
void |
-fromJSONObject(JSONObject o)
-(non-Javadoc)
- |
-
String |
-getId() |
-
String |
-getKey() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
String |
-getValue() |
-
void |
-setId(String id) |
-
void |
-setKey(String key) |
-
void |
-setValue(String value) |
-
String |
-toString()
-(non-Javadoc)
- |
-
fromXmlRpcStruct, toOneLinerString, toXmlRpcStruct
public CustomField()-
public String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
public String toString()-
toString
in class XmlRpcMapped
XmlRpcMapped.toString()
public void fromJSONObject(JSONObject o)-
fromJSONObject
in interface JSONConvertable
o
- JSON object to get values fromJSONConvertable.fromJSONObject(org.json.JSONObject)
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/FileParser.html b/doc/net/bican/wordpress/FileParser.html deleted file mode 100644 index 4a54ea0..0000000 --- a/doc/net/bican/wordpress/FileParser.html +++ /dev/null @@ -1,292 +0,0 @@ - - - - - - -public class FileParser -extends Object-
Constructor and Description | -
---|
FileParser() |
-
Modifier and Type | -Method and Description | -
---|---|
static XmlRpcStruct |
-parseFile(BufferedReader input)
-Parses a file to create an xmlrpc compliant object
- |
-
static void |
-putVal(XmlRpcStruct s,
- String key,
- String v)
-Fills values for an xmlrpc object
- |
-
public FileParser()-
public static XmlRpcStruct parseFile(BufferedReader input) - throws IOException, - InvalidPostFormatException-
input
- reader for the fileIOException
InvalidPostFormatException
public static void putVal(XmlRpcStruct s, - String key, - String v)-
s
- xmlrpc object itselfkey
- field namev
- field valueCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/InvalidPostFormatException.html b/doc/net/bican/wordpress/InvalidPostFormatException.html deleted file mode 100644 index 11cad12..0000000 --- a/doc/net/bican/wordpress/InvalidPostFormatException.html +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - -public class InvalidPostFormatException -extends Exception-
Constructor and Description | -
---|
InvalidPostFormatException() |
-
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public InvalidPostFormatException()-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/JSONConvertable.html b/doc/net/bican/wordpress/JSONConvertable.html deleted file mode 100644 index 8e7c526..0000000 --- a/doc/net/bican/wordpress/JSONConvertable.html +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - -public interface JSONConvertable-
Modifier and Type | -Method and Description | -
---|---|
void |
-fromJSONObject(JSONObject jsonObject) |
-
void fromJSONObject(JSONObject jsonObject)-
jsonObject
- JSON object to get values fromCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Main.html b/doc/net/bican/wordpress/Main.html deleted file mode 100644 index 75e845d..0000000 --- a/doc/net/bican/wordpress/Main.html +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/MediaObject.html b/doc/net/bican/wordpress/MediaObject.html deleted file mode 100644 index 752275a..0000000 --- a/doc/net/bican/wordpress/MediaObject.html +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - -public class MediaObject -extends XmlRpcMapped-
Constructor and Description | -
---|
MediaObject() |
-
Modifier and Type | -Method and Description | -
---|---|
String |
-getFile() |
-
String |
-getId() |
-
String |
-getType() |
-
String |
-getUrl() |
-
void |
-setFile(String file) |
-
void |
-setId(String id) |
-
void |
-setType(String type) |
-
void |
-setUrl(String url) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Page.html b/doc/net/bican/wordpress/Page.html deleted file mode 100644 index 52be74d..0000000 --- a/doc/net/bican/wordpress/Page.html +++ /dev/null @@ -1,1093 +0,0 @@ - - - - - - -public class Page -extends XmlRpcMapped -implements StringHeader-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public static Page fromFile(File file) - throws IOException, - InvalidPostFormatException-
file
- file that contains the page informationIOException
- when the file cannot be readInvalidPostFormatException
- when the file format is not recognizedpublic XmlRpcArray getCategories()-
public XmlRpcArray getCustom_fields()-
public Date getDate_created_gmt()-
public Date getDateCreated()-
public String getDescription()-
public String getExcerpt()-
public Integer getMt_allow_comments()-
public Integer getMt_allow_pings()-
public String getMt_keywords()-
public String getMt_text_more()-
public Integer getPage_id()-
public String getPage_status()-
public String getPermaLink()-
public String getPost_status()-
public String getPost_type()-
public String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
public String getWp_author()-
public String getWp_author_display_name()-
public String getWp_author_id()-
public Integer getWp_page_order()-
public Integer getWp_page_parent_id()-
public String getWp_page_parent_title()-
public String getWp_password()-
public String getWp_slug()-
public void setCategories(XmlRpcArray categories)-
categories
- the categories to setpublic void setCustom_fields(XmlRpcArray custom_fields)-
custom_fields
- the custom_fields to setpublic void setDate_created_gmt(Date date_created_gmt)-
date_created_gmt
- the date_created_gmt to setpublic void setDateCreated(Date dateCreated)-
dateCreated
- the dateCreated to setpublic void setDescription(String description)-
description
- the description to setpublic void setExcerpt(String excerpt)-
excerpt
- the excerpt to setpublic void setMt_allow_comments(Integer mt_allow_comments)-
mt_allow_comments
- the mt_allow_comments to setpublic void setMt_allow_pings(Integer mt_allow_pings)-
mt_allow_pings
- the mt_allow_pings to setpublic void setMt_keywords(String mt_keywords)-
mt_keywords
- the mt_keywords to setpublic void setMt_text_more(String mt_text_more)-
mt_text_more
- to setpublic void setPage_id(Integer page_id)-
page_id
- the page_id to setpublic void setPage_status(String page_status)-
page_status
- the page_status to setpublic void setPermaLink(String permaLink)-
permaLink
- the permaLink to setpublic void setPost_status(String postStatus)-
postStatus
- the post_status to setpublic void setPost_type(String post_type)-
post_type
- the post_type to setpublic void setWp_author(String wp_author)-
wp_author
- the wp_author to setpublic void setWp_author_display_name(String wp_author_display_name)-
wp_author_display_name
- the wp_author_display_name to setpublic void setWp_author_id(String wp_author_id)-
wp_author_id
- the wp_author_id to setpublic void setWp_page_order(Integer wp_page_order)-
wp_page_order
- the wp_page_order to setpublic void setWp_page_parent_id(Integer wp_page_parent_id)-
wp_page_parent_id
- the wp_page_parent_id to setpublic void setWp_page_parent_title(String wp_page_parent_title)-
wp_page_parent_title
- the wp_page_parent_title to setpublic void setWp_password(String wp_password)-
wp_password
- the wp_password to setpublic String getWp_post_thumbnail()-
public void setWp_post_thumbnail(String wp_post_thumbnail)-
wp_post_thumbnail
- set the post thumbnail (feature image). This is the ID of the Media
- object already created with MediaObject classpublic void setWp_slug(String wp_slug)-
wp_slug
- the wp_slug to setCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/PageDefinition.html b/doc/net/bican/wordpress/PageDefinition.html deleted file mode 100644 index bc3a96c..0000000 --- a/doc/net/bican/wordpress/PageDefinition.html +++ /dev/null @@ -1,397 +0,0 @@ - - - - - - -public class PageDefinition -extends XmlRpcMapped -implements StringHeader-
Page
object, that is returned in listsConstructor and Description | -
---|
PageDefinition() |
-
Modifier and Type | -Method and Description | -
---|---|
Date |
-getDate_created_gmt() |
-
Date |
-getDateCreated() |
-
String |
-getPage_parent_id() |
-
String |
-getPage_title() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
void |
-setDate_created_gmt(Date date_created_gmt) |
-
void |
-setDateCreated(Date dateCreated) |
-
void |
-setPage_parent_id(String page_parent_id) |
-
void |
-setPage_title(String page_title) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public PageDefinition()-
public String getPage_title()-
public void setPage_title(String page_title)-
page_title
- the page_title to setpublic String getPage_parent_id()-
public void setPage_parent_id(String page_parent_id)-
page_parent_id
- the page_parent_id to setpublic Date getDateCreated()-
public void setDateCreated(Date dateCreated)-
dateCreated
- the dateCreated to setpublic Date getDate_created_gmt()-
public void setDate_created_gmt(Date date_created_gmt)-
date_created_gmt
- the date_created_gmt to setpublic String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Ping.html b/doc/net/bican/wordpress/Ping.html deleted file mode 100644 index d666bd7..0000000 --- a/doc/net/bican/wordpress/Ping.html +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - -public class Ping -extends XmlRpcMapped-
Modifier and Type | -Method and Description | -
---|---|
String |
-getPingIP() |
-
String |
-getPingTitle() |
-
String |
-getPingURL() |
-
void |
-setPingIP(String pingIP) |
-
void |
-setPingTitle(String pingTitle) |
-
void |
-setPingURL(String pingURL) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public String getPingTitle()-
public void setPingTitle(String pingTitle)-
pingTitle
- the pingTitle to setpublic String getPingURL()-
public void setPingURL(String pingURL)-
pingURL
- the pingURL to setCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/PostAndPageStatus.html b/doc/net/bican/wordpress/PostAndPageStatus.html deleted file mode 100644 index 3100c73..0000000 --- a/doc/net/bican/wordpress/PostAndPageStatus.html +++ /dev/null @@ -1,341 +0,0 @@ - - - - - - -public class PostAndPageStatus -extends XmlRpcMapped -implements StringHeader-
Constructor and Description | -
---|
PostAndPageStatus() |
-
Modifier and Type | -Method and Description | -
---|---|
String |
-getDescription() |
-
String |
-getStatus() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
void |
-setDescription(String description) |
-
void |
-setStatus(String status) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public PostAndPageStatus()-
public String getDescription()-
public void setDescription(String description)-
description
- the description to setpublic String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/StringHeader.html b/doc/net/bican/wordpress/StringHeader.html deleted file mode 100644 index feaacf4..0000000 --- a/doc/net/bican/wordpress/StringHeader.html +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - -public interface StringHeader-
Modifier and Type | -Method and Description | -
---|---|
String |
-getStringHeader() |
-
String getStringHeader()-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/User.html b/doc/net/bican/wordpress/User.html deleted file mode 100644 index 00ca8fc..0000000 --- a/doc/net/bican/wordpress/User.html +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - -public class User -extends XmlRpcMapped -implements StringHeader-
Modifier and Type | -Method and Description | -
---|---|
String |
-getFirstname() |
-
String |
-getLastname() |
-
String |
-getNickname() |
-
String |
-getStringHeader()
-(non-Javadoc)
- |
-
String |
-getUrl() |
-
Integer |
-getUserid() |
-
void |
-setFirstname(String firstname) |
-
void |
-setLastname(String lastname) |
-
void |
-setNickname(String nickname) |
-
void |
-setUrl(String url) |
-
void |
-setUserid(Integer userid) |
-
fromXmlRpcStruct, toOneLinerString, toString, toXmlRpcStruct
public String getStringHeader()-
getStringHeader
in interface StringHeader
StringHeader.getStringHeader()
public String getNickname()-
public void setNickname(String nickname)-
nickname
- the nickname to setpublic String getLastname()-
public void setLastname(String lastname)-
lastname
- the lastname to setpublic String getFirstname()-
public void setFirstname(String firstname)-
firstname
- the firstname to setCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/Wordpress.html b/doc/net/bican/wordpress/Wordpress.html deleted file mode 100644 index 33e137a..0000000 --- a/doc/net/bican/wordpress/Wordpress.html +++ /dev/null @@ -1,952 +0,0 @@ - - - - - - -Constructor and Description | -
---|
Wordpress(String username,
- String password,
- String xmlRpcUrl) |
-
Modifier and Type | -Method and Description | -
---|---|
double |
-addTwoNumbers(double number1,
- double number2) |
-
int |
-deleteCategory(int categoryId) |
-
boolean |
-deleteComment(int commentID) |
-
Boolean |
-deletePage(int post_ID,
- String publish) |
-
Boolean |
-deletePost(int post_ID,
- String publish) |
-
boolean |
-editComment(Comment comment) |
-
Boolean |
-editPage(int post_ID,
- Page page,
- String publish) |
-
Boolean |
-editPost(int post_ID,
- Page page,
- String publish) |
-
List<Author> |
-getAuthors() |
-
List<Category> |
-getCategories() |
-
Comment |
-getComment(Integer comment_id) |
-
List<Comment> |
-getComments(String status,
- Integer post_id,
- Integer number,
- Integer offset) |
-
CommentCount |
-getCommentsCount(Integer post_ID) |
-
CommentStatusList |
-getCommentStatusList() |
-
Page |
-getPage(int pageid) |
-
List<PageDefinition> |
-getPageList() |
-
List<Page> |
-getPages() |
-
List<PostAndPageStatus> |
-getPageStatusList() |
-
List<URL> |
-getPingbacks(String url) |
-
Page |
-getPost(int post_ID) |
-
List<PostAndPageStatus> |
-getPostStatusList() |
-
List<Page> |
-getRecentPosts(int num_posts) |
-
String |
-getTemplate() |
-
List<Ping> |
-getTrackbackPings(int postId) |
-
User |
-getUserInfo() |
-
List<Blog> |
-getUsersBlogs() |
-
int |
-newCategory(String name,
- String slug,
- int parentId) |
-
Integer |
-newComment(Integer post_id,
- Integer comment_parent,
- String content,
- String author,
- String author_url,
- String author_email) |
-
MediaObject |
-newMediaObject(String mimeType,
- File file,
- Boolean overwrite) |
-
String |
-newPage(Page post,
- String publish) |
-
String |
-newPost(Page page,
- boolean publish) |
-
String |
-ping(String pagelinkedfrom,
- String pagelinkedto) |
-
String |
-sayHello() |
-
boolean |
-setTemplate(String content) |
-
List<Category> |
-suggestCategories(String category,
- Integer max_results) |
-
List<String> |
-supportedMethods() |
-
List<String> |
-supportedTextFilters() |
-
public Wordpress(String username, - String password, - String xmlRpcUrl) - throws MalformedURLException-
username
- User namepassword
- PasswordxmlRpcUrl
- xmlrpc communication point, usually blogurl/xmlrpc.phpMalformedURLException
- If the URL is faultypublic double addTwoNumbers(double number1, - double number2) - throws XmlRpcFault-
number1
- First numbernumber2
- Second numberXmlRpcFault
- Generic exception for xml-rpc operationspublic Boolean deletePage(int post_ID, - String publish) - throws XmlRpcFault-
post_ID
- ID of the page to deletepublish
- Publish statusXmlRpcFault
- Generic exception for xml-rpc operationspublic Boolean deletePost(int post_ID, - String publish) - throws XmlRpcFault-
post_ID
- ID of the post to deletepublish
- Publish statusXmlRpcFault
- Generic exception for xml-rpc operationspublic Boolean editPage(int post_ID, - Page page, - String publish) - throws XmlRpcFault-
post_ID
- ID of the post to editpage
- Page informationpublish
- Publish statusXmlRpcFault
- Generic exception for xml-rpc operationspublic Boolean editPost(int post_ID, - Page page, - String publish) - throws XmlRpcFault-
post_ID
- ID of the post to editpage
- Page informationpublish
- Publish statusXmlRpcFault
- Generic exception for xml-rpc operationspublic List<Author> getAuthors() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<Category> getCategories() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic Page getPage(int pageid) - throws XmlRpcFault-
pageid
- Page IDPage
object.XmlRpcFault
- Generic exception for xml-rpc operationspublic List<PageDefinition> getPageList() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<Page> getPages() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<Ping> getTrackbackPings(int postId) - throws XmlRpcFault-
postId
- Post IDXmlRpcFault
- Generic exception for xml-rpc operationspublic List<URL> getPingbacks(String url) - throws XmlRpcFault-
url
- Url of the page queriedXmlRpcFault
- Generic exception for xml-rpc operationspublic Page getPost(int post_ID) - throws XmlRpcFault-
post_ID
- ID of the post to retrieveXmlRpcFault
- Generic exception for xml-rpc operationspublic List<Page> getRecentPosts(int num_posts) - throws XmlRpcFault-
num_posts
- Number of posts to be retrieved.XmlRpcFault
- Generic exception for xml-rpc operationspublic String getTemplate() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic User getUserInfo() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<Blog> getUsersBlogs() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic int newCategory(String name, - String slug, - int parentId) - throws XmlRpcFault-
name
- Category nameslug
- Category short nameparentId
- Parent IDXmlRpcFault
- Generic exception for xml-rpc operationspublic MediaObject newMediaObject(String mimeType, - File file, - Boolean overwrite) - throws XmlRpcFault-
mimeType
- Mime type of the filefile
- File nameoverwrite
- true/falseXmlRpcFault
- Generic exception for xml-rpc operationspublic String newPage(Page post, - String publish) - throws XmlRpcFault-
post
- Page informationpublish
- Publish statusXmlRpcFault
- Generic exception for xml-rpc operationspublic String newPost(Page page, - boolean publish) - throws XmlRpcFault-
page
- Post informationpublish
- Publish statusXmlRpcFault
- Generic exception for xml-rpc operationspublic String ping(String pagelinkedfrom, - String pagelinkedto) - throws XmlRpcFault-
pagelinkedfrom
- Sourcepagelinkedto
- DestinationXmlRpcFault
- Generic exception for xml-rpc operationspublic String sayHello() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic boolean setTemplate(String content) - throws XmlRpcFault-
content
- Content of the templateXmlRpcFault
- Generic exception for xml-rpc operationspublic List<Category> suggestCategories(String category, - Integer max_results) - throws XmlRpcFault-
category
- Category to searchmax_results
- Maximum results to returnXmlRpcFault
- Generic exception for xml-rpc operationspublic List<String> supportedMethods() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<String> supportedTextFilters() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<PostAndPageStatus> getPostStatusList() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic List<PostAndPageStatus> getPageStatusList() - throws XmlRpcFault-
XmlRpcFault
- Generic exception for xml-rpc operationspublic CommentCount getCommentsCount(Integer post_ID) - throws XmlRpcFault-
post_ID
- Blog Post IDXmlRpcFault
- Generic exception for xml-rpc operationspublic List<Comment> getComments(String status, - Integer post_id, - Integer number, - Integer offset) - throws XmlRpcFault-
status
- One of "approve", "hold", or "spam". Or, null to show all.post_id
- Filter comments by post_id, or null to not filter.number
- The number of comments to return, or null for the default (of 10)offset
- The offset into the set of comments to return, or null for 0XmlRpcFault
- Generic exception for xml-rpc operationspublic Comment getComment(Integer comment_id) - throws XmlRpcFault-
comment_id
- comment_id to fetchXmlRpcFault
- Generic exception for xml-rpc operationspublic Integer newComment(Integer post_id, - Integer comment_parent, - String content, - String author, - String author_url, - String author_email) - throws XmlRpcFault-
post_id
- Post to attach the comment to.comment_parent
- Id of the parent comment (for threading)content
- Content of commentauthor
- Author's nameauthor_url
- Author's URL (can be empty)author_email
- Author's Email AddressXmlRpcFault
- Generic exception for xml-rpc operationspublic CommentStatusList getCommentStatusList()-
public boolean deleteComment(int commentID) - throws XmlRpcFault-
commentID
- comment id to deleteXmlRpcFault
public boolean editComment(Comment comment) - throws XmlRpcFault-
comment
- XmlRpcFault
public int deleteCategory(int categoryId) - throws XmlRpcFault-
categoryId
- XmlRpcFault
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/XmlRpcMapped.html b/doc/net/bican/wordpress/XmlRpcMapped.html deleted file mode 100644 index 0efee68..0000000 --- a/doc/net/bican/wordpress/XmlRpcMapped.html +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - -public abstract class XmlRpcMapped -extends Object-
XmlRpcStruct
.Constructor and Description | -
---|
XmlRpcMapped() |
-
Modifier and Type | -Method and Description | -
---|---|
void |
-fromXmlRpcStruct(XmlRpcStruct x) |
-
String |
-toOneLinerString() |
-
String |
-toString()
-(non-Javadoc)
- |
-
XmlRpcStruct |
-toXmlRpcStruct() |
-
public XmlRpcMapped()-
public String toString()-
toString
in class Object
Object.toString()
public String toOneLinerString()-
public void fromXmlRpcStruct(XmlRpcStruct x)-
x
- XmlRpcStruct to create the object frompublic XmlRpcStruct toXmlRpcStruct()-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Author.html b/doc/net/bican/wordpress/class-use/Author.html deleted file mode 100644 index 09452dd..0000000 --- a/doc/net/bican/wordpress/class-use/Author.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
List<Author> |
-Wordpress.getAuthors() |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Blog.html b/doc/net/bican/wordpress/class-use/Blog.html deleted file mode 100644 index b52e6dd..0000000 --- a/doc/net/bican/wordpress/class-use/Blog.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
List<Blog> |
-Wordpress.getUsersBlogs() |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Category.html b/doc/net/bican/wordpress/class-use/Category.html deleted file mode 100644 index dffa709..0000000 --- a/doc/net/bican/wordpress/class-use/Category.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
List<Category> |
-Wordpress.getCategories() |
-
List<Category> |
-Wordpress.suggestCategories(String category,
- Integer max_results) |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Comment.html b/doc/net/bican/wordpress/class-use/Comment.html deleted file mode 100644 index 0d8cac4..0000000 --- a/doc/net/bican/wordpress/class-use/Comment.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
static Comment |
-Comment.fromFile(File file)
-Creates a comment object from file
- |
-
Comment |
-Wordpress.getComment(Integer comment_id) |
-
Modifier and Type | -Method and Description | -
---|---|
List<Comment> |
-Wordpress.getComments(String status,
- Integer post_id,
- Integer number,
- Integer offset) |
-
Modifier and Type | -Method and Description | -
---|---|
boolean |
-Wordpress.editComment(Comment comment) |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/CommentCount.html b/doc/net/bican/wordpress/class-use/CommentCount.html deleted file mode 100644 index 0e07677..0000000 --- a/doc/net/bican/wordpress/class-use/CommentCount.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
CommentCount |
-Wordpress.getCommentsCount(Integer post_ID) |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/CommentStatusList.html b/doc/net/bican/wordpress/class-use/CommentStatusList.html deleted file mode 100644 index d589353..0000000 --- a/doc/net/bican/wordpress/class-use/CommentStatusList.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
CommentStatusList |
-Wordpress.getCommentStatusList() |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/CustomField.html b/doc/net/bican/wordpress/class-use/CustomField.html deleted file mode 100644 index 544a635..0000000 --- a/doc/net/bican/wordpress/class-use/CustomField.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/FileParser.html b/doc/net/bican/wordpress/class-use/FileParser.html deleted file mode 100644 index 527b7dd..0000000 --- a/doc/net/bican/wordpress/class-use/FileParser.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/InvalidPostFormatException.html b/doc/net/bican/wordpress/class-use/InvalidPostFormatException.html deleted file mode 100644 index 8324661..0000000 --- a/doc/net/bican/wordpress/class-use/InvalidPostFormatException.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
static Page |
-Page.fromFile(File file)
-Generates a new page class from the given file
- |
-
static Comment |
-Comment.fromFile(File file)
-Creates a comment object from file
- |
-
static XmlRpcStruct |
-FileParser.parseFile(BufferedReader input)
-Parses a file to create an xmlrpc compliant object
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/JSONConvertable.html b/doc/net/bican/wordpress/class-use/JSONConvertable.html deleted file mode 100644 index acdb0de..0000000 --- a/doc/net/bican/wordpress/class-use/JSONConvertable.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Class and Description | -
---|---|
class |
-CustomField
-This class represents custom fields in wordpress.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Main.html b/doc/net/bican/wordpress/class-use/Main.html deleted file mode 100644 index b2df004..0000000 --- a/doc/net/bican/wordpress/class-use/Main.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/MediaObject.html b/doc/net/bican/wordpress/class-use/MediaObject.html deleted file mode 100644 index e7d92bf..0000000 --- a/doc/net/bican/wordpress/class-use/MediaObject.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
MediaObject |
-Wordpress.newMediaObject(String mimeType,
- File file,
- Boolean overwrite) |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Page.html b/doc/net/bican/wordpress/class-use/Page.html deleted file mode 100644 index a386509..0000000 --- a/doc/net/bican/wordpress/class-use/Page.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
static Page |
-Page.fromFile(File file)
-Generates a new page class from the given file
- |
-
Page |
-Wordpress.getPage(int pageid) |
-
Page |
-Wordpress.getPost(int post_ID) |
-
Modifier and Type | -Method and Description | -
---|---|
List<Page> |
-Wordpress.getPages() |
-
List<Page> |
-Wordpress.getRecentPosts(int num_posts) |
-
Modifier and Type | -Method and Description | -
---|---|
Boolean |
-Wordpress.editPage(int post_ID,
- Page page,
- String publish) |
-
Boolean |
-Wordpress.editPost(int post_ID,
- Page page,
- String publish) |
-
String |
-Wordpress.newPage(Page post,
- String publish) |
-
String |
-Wordpress.newPost(Page page,
- boolean publish) |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/PageDefinition.html b/doc/net/bican/wordpress/class-use/PageDefinition.html deleted file mode 100644 index 6da5a37..0000000 --- a/doc/net/bican/wordpress/class-use/PageDefinition.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
List<PageDefinition> |
-Wordpress.getPageList() |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Ping.html b/doc/net/bican/wordpress/class-use/Ping.html deleted file mode 100644 index 023fb80..0000000 --- a/doc/net/bican/wordpress/class-use/Ping.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
List<Ping> |
-Wordpress.getTrackbackPings(int postId) |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/PostAndPageStatus.html b/doc/net/bican/wordpress/class-use/PostAndPageStatus.html deleted file mode 100644 index 9354b1b..0000000 --- a/doc/net/bican/wordpress/class-use/PostAndPageStatus.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
List<PostAndPageStatus> |
-Wordpress.getPageStatusList() |
-
List<PostAndPageStatus> |
-Wordpress.getPostStatusList() |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/StringHeader.html b/doc/net/bican/wordpress/class-use/StringHeader.html deleted file mode 100644 index c18ae26..0000000 --- a/doc/net/bican/wordpress/class-use/StringHeader.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Class and Description | -
---|---|
class |
-Author
-Author object for a blog.
- |
-
class |
-Category
-Category object for a blog.
- |
-
class |
-Comment
-A WordPress Comment object
- |
-
class |
-CommentCount
-Comment Count object for a blog post.
- |
-
class |
-CommentStatusList
-Comment status names for the blog
- |
-
class |
-CustomField
-This class represents custom fields in wordpress.
- |
-
class |
-Page
-Page object for a blog.
- |
-
class |
-PageDefinition
-A trimmed version of
-Page object, that is returned in lists |
-
class |
-PostAndPageStatus
-Status values for posts and pages
- |
-
class |
-User
-Class that keeps user information from blogger style calls
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/User.html b/doc/net/bican/wordpress/class-use/User.html deleted file mode 100644 index e24334d..0000000 --- a/doc/net/bican/wordpress/class-use/User.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Method and Description | -
---|---|
User |
-Wordpress.getUserInfo() |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/Wordpress.html b/doc/net/bican/wordpress/class-use/Wordpress.html deleted file mode 100644 index 18a0548..0000000 --- a/doc/net/bican/wordpress/class-use/Wordpress.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/class-use/XmlRpcMapped.html b/doc/net/bican/wordpress/class-use/XmlRpcMapped.html deleted file mode 100644 index 93806a0..0000000 --- a/doc/net/bican/wordpress/class-use/XmlRpcMapped.html +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Modifier and Type | -Class and Description | -
---|---|
class |
-Author
-Author object for a blog.
- |
-
class |
-Blog
-Class that keeps the information on a blog for a user
- |
-
class |
-Category
-Category object for a blog.
- |
-
class |
-Comment
-A WordPress Comment object
- |
-
class |
-CommentCount
-Comment Count object for a blog post.
- |
-
class |
-CommentStatusList
-Comment status names for the blog
- |
-
class |
-CustomField
-This class represents custom fields in wordpress.
- |
-
class |
-MediaObject
-Media Object, as the result of an upload;
- |
-
class |
-Page
-Page object for a blog.
- |
-
class |
-PageDefinition
-A trimmed version of
-Page object, that is returned in lists |
-
class |
-Ping
-Class that hold trackback information
- |
-
class |
-PostAndPageStatus
-Status values for posts and pages
- |
-
class |
-User
-Class that keeps user information from blogger style calls
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/CliConfiguration.html b/doc/net/bican/wordpress/configuration/CliConfiguration.html deleted file mode 100644 index 59d5f1e..0000000 --- a/doc/net/bican/wordpress/configuration/CliConfiguration.html +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - -public class CliConfiguration -extends org.apache.commons.configuration.BaseConfiguration-
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
Constructor and Description | -
---|
CliConfiguration(String[] args,
- org.apache.commons.cli.Options options)
-generates the configuration in terms of arguments and options
- |
-
addPropertyDirect, clear, clearPropertyDirect, clone, containsKey, getKeys, getProperty, isEmpty
addErrorLogListener, addProperty, append, clearProperty, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setProperty, setThrowExceptionOnMissing, subset
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
public CliConfiguration(String[] args, - org.apache.commons.cli.Options options) - throws org.apache.commons.cli.ParseException-
args
- Command line argumentsoptions
- Command line optionsorg.apache.commons.cli.ParseException
- When the configuration cannot be parsedCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/PreferencesConfiguration.html b/doc/net/bican/wordpress/configuration/PreferencesConfiguration.html deleted file mode 100644 index 1a0a5f3..0000000 --- a/doc/net/bican/wordpress/configuration/PreferencesConfiguration.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - -public class PreferencesConfiguration -extends org.apache.commons.configuration.BaseConfiguration-
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
Constructor and Description | -
---|
PreferencesConfiguration(Class<?> cl) |
-
addPropertyDirect, clear, clearPropertyDirect, clone, containsKey, getKeys, getProperty, isEmpty
addErrorLogListener, addProperty, append, clearProperty, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setProperty, setThrowExceptionOnMissing, subset
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
public PreferencesConfiguration(Class<?> cl)-
cl
- Calling classCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/WpCliConfiguration.html b/doc/net/bican/wordpress/configuration/WpCliConfiguration.html deleted file mode 100644 index 3b28e35..0000000 --- a/doc/net/bican/wordpress/configuration/WpCliConfiguration.html +++ /dev/null @@ -1,286 +0,0 @@ - - - - - - -public class WpCliConfiguration -extends Object-
Constructor and Description | -
---|
WpCliConfiguration(String[] args,
- org.apache.commons.cli.Options options,
- Class<?> cl) |
-
public WpCliConfiguration(String[] args, - org.apache.commons.cli.Options options, - Class<?> cl) - throws org.apache.commons.cli.ParseException-
args
- Command line argumentsoptions
- Command line optionscl
- Calling classorg.apache.commons.cli.ParseException
- When the configuration cannot be parsedpublic boolean hasOption(String key)-
key
- Option key to checktrue
if the configuration contains the keypublic String getOptionValue(String key)-
key
- Option key to retrieveCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/class-use/CliConfiguration.html b/doc/net/bican/wordpress/configuration/class-use/CliConfiguration.html deleted file mode 100644 index f707640..0000000 --- a/doc/net/bican/wordpress/configuration/class-use/CliConfiguration.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/class-use/PreferencesConfiguration.html b/doc/net/bican/wordpress/configuration/class-use/PreferencesConfiguration.html deleted file mode 100644 index 85e277b..0000000 --- a/doc/net/bican/wordpress/configuration/class-use/PreferencesConfiguration.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/class-use/WpCliConfiguration.html b/doc/net/bican/wordpress/configuration/class-use/WpCliConfiguration.html deleted file mode 100644 index 20b0106..0000000 --- a/doc/net/bican/wordpress/configuration/class-use/WpCliConfiguration.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/package-frame.html b/doc/net/bican/wordpress/configuration/package-frame.html deleted file mode 100644 index 2f02372..0000000 --- a/doc/net/bican/wordpress/configuration/package-frame.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -Class | -Description | -
---|---|
CliConfiguration | -
- Implement a simple CLI configuration in apache commons configuration style
- |
-
PreferencesConfiguration | -- |
WpCliConfiguration | -
- A composite configuration class that combines preferences and command line.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/package-tree.html b/doc/net/bican/wordpress/configuration/package-tree.html deleted file mode 100644 index 0df6c4d..0000000 --- a/doc/net/bican/wordpress/configuration/package-tree.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/configuration/package-use.html b/doc/net/bican/wordpress/configuration/package-use.html deleted file mode 100644 index 453a2eb..0000000 --- a/doc/net/bican/wordpress/configuration/package-use.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/example/Main.html b/doc/net/bican/wordpress/example/Main.html deleted file mode 100644 index b5ffe15..0000000 --- a/doc/net/bican/wordpress/example/Main.html +++ /dev/null @@ -1,270 +0,0 @@ - - - - - - -public static void main(String[] args) - throws MalformedURLException, - XmlRpcFault-
args
- MalformedURLException
XmlRpcFault
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/example/class-use/Main.html b/doc/net/bican/wordpress/example/class-use/Main.html deleted file mode 100644 index 4f7455e..0000000 --- a/doc/net/bican/wordpress/example/class-use/Main.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/example/package-frame.html b/doc/net/bican/wordpress/example/package-frame.html deleted file mode 100644 index 702ce22..0000000 --- a/doc/net/bican/wordpress/example/package-frame.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - -Class | -Description | -
---|---|
Main | -
- Example implementation
-
- Run this as java net.bican.wordpress.example.Main <username>
- <password> <xmlrpc-url> for your blog.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/example/package-tree.html b/doc/net/bican/wordpress/example/package-tree.html deleted file mode 100644 index b659644..0000000 --- a/doc/net/bican/wordpress/example/package-tree.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/example/package-use.html b/doc/net/bican/wordpress/example/package-use.html deleted file mode 100644 index 9b47fb8..0000000 --- a/doc/net/bican/wordpress/example/package-use.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/package-frame.html b/doc/net/bican/wordpress/package-frame.html deleted file mode 100644 index 513aeee..0000000 --- a/doc/net/bican/wordpress/package-frame.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - -Interface | -Description | -
---|---|
JSONConvertable | -
- Interface for objects that can be modified via JSON objects.
- |
-
StringHeader | -
- Interface for supplying a header for tabular output in toString()
- |
-
Class | -Description | -
---|---|
Author | -
- Author object for a blog.
- |
-
Blog | -
- Class that keeps the information on a blog for a user
- |
-
Category | -
- Category object for a blog.
- |
-
Comment | -
- A WordPress Comment object
- |
-
CommentCount | -
- Comment Count object for a blog post.
- |
-
CommentStatusList | -
- Comment status names for the blog
- |
-
CustomField | -
- This class represents custom fields in wordpress.
- |
-
FileParser | -
- Static methods for parsing files
- |
-
Main | -
- Main Application class for the command line interface.
- |
-
MediaObject | -
- Media Object, as the result of an upload;
- |
-
Page | -
- Page object for a blog.
- |
-
PageDefinition | -
- A trimmed version of
-Page object, that is returned in lists |
-
Ping | -
- Class that hold trackback information
- |
-
PostAndPageStatus | -
- Status values for posts and pages
- |
-
User | -
- Class that keeps user information from blogger style calls
- |
-
Wordpress | -
- The utility class that links xmlrpc calls to Java functions.
- |
-
XmlRpcMapped | -
- An object that has the capabilites of converting to/from
-
-XmlRpcStruct . |
-
Exception | -Description | -
---|---|
InvalidPostFormatException | -
- Exception that is triggered via invalid input
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/package-tree.html b/doc/net/bican/wordpress/package-tree.html deleted file mode 100644 index 92d64e9..0000000 --- a/doc/net/bican/wordpress/package-tree.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/net/bican/wordpress/package-use.html b/doc/net/bican/wordpress/package-use.html deleted file mode 100644 index 207d5a0..0000000 --- a/doc/net/bican/wordpress/package-use.html +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
Class and Description | -
---|
Author
- Author object for a blog.
- |
-
Blog
- Class that keeps the information on a blog for a user
- |
-
Category
- Category object for a blog.
- |
-
Comment
- A WordPress Comment object
- |
-
CommentCount
- Comment Count object for a blog post.
- |
-
CommentStatusList
- Comment status names for the blog
- |
-
InvalidPostFormatException
- Exception that is triggered via invalid input
- |
-
JSONConvertable
- Interface for objects that can be modified via JSON objects.
- |
-
MediaObject
- Media Object, as the result of an upload;
- |
-
Page
- Page object for a blog.
- |
-
PageDefinition
- A trimmed version of
-Page object, that is returned in lists |
-
Ping
- Class that hold trackback information
- |
-
PostAndPageStatus
- Status values for posts and pages
- |
-
StringHeader
- Interface for supplying a header for tabular output in toString()
- |
-
User
- Class that keeps user information from blogger style calls
- |
-
XmlRpcMapped
- An object that has the capabilites of converting to/from
-
-XmlRpcStruct . |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/JSONArray.html b/doc/org/json/JSONArray.html deleted file mode 100644 index 6842ea1..0000000 --- a/doc/org/json/JSONArray.html +++ /dev/null @@ -1,1301 +0,0 @@ - - - - - - -public class JSONArray -extends Object-
get
and opt
- methods for accessing the values by index, and put
methods for
- adding or replacing values. The values can be any of these types:
- Boolean
, JSONArray
, JSONObject
,
- Number
, String
, or the
- JSONObject.NULL object
.
-
- The constructor can convert a JSON text into a Java object. The
- toString
method converts to JSON text.
-
- A get
method returns a value if one can be found, and throws an
- exception if one cannot be found. An opt
method returns a
- default value instead of throwing an exception, and so is useful for
- obtaining optional values.
-
- The generic get()
and opt()
methods return an
- object which you can cast or query for type. There are also typed
- get
and opt
methods that do type checking and type
- coercion for you.
-
- The texts produced by the toString
methods strictly conform to
- JSON syntax rules. The constructors are more forgiving in the texts they will
- accept:
-
,
(comma) may appear just
- before the closing bracket.null
value will be inserted when there is ,
- (comma) elision.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and
- if they are not the reserved words true
, false
, or
- null
.;
(semicolon) as
- well as by ,
(comma).0x-
(hex) prefix.Constructor and Description | -
---|
JSONArray()
-Construct an empty JSONArray.
- |
-
JSONArray(Collection collection)
-Construct a JSONArray from a Collection.
- |
-
JSONArray(JSONTokener x)
-Construct a JSONArray from a JSONTokener.
- |
-
JSONArray(Object array)
-Construct a JSONArray from an array
- |
-
JSONArray(String source)
-Construct a JSONArray from a source JSON text.
- |
-
Modifier and Type | -Method and Description | -
---|---|
Object |
-get(int index)
-Get the object value associated with an index.
- |
-
boolean |
-getBoolean(int index)
-Get the boolean value associated with an index.
- |
-
double |
-getDouble(int index)
-Get the double value associated with an index.
- |
-
int |
-getInt(int index)
-Get the int value associated with an index.
- |
-
JSONArray |
-getJSONArray(int index)
-Get the JSONArray associated with an index.
- |
-
JSONObject |
-getJSONObject(int index)
-Get the JSONObject associated with an index.
- |
-
long |
-getLong(int index)
-Get the long value associated with an index.
- |
-
String |
-getString(int index)
-Get the string associated with an index.
- |
-
boolean |
-isNull(int index)
-Determine if the value is null.
- |
-
String |
-join(String separator)
-Make a string from the contents of this JSONArray.
- |
-
int |
-length()
-Get the number of elements in the JSONArray, included nulls.
- |
-
Object |
-opt(int index)
-Get the optional object value associated with an index.
- |
-
boolean |
-optBoolean(int index)
-Get the optional boolean value associated with an index.
- |
-
boolean |
-optBoolean(int index,
- boolean defaultValue)
-Get the optional boolean value associated with an index.
- |
-
double |
-optDouble(int index)
-Get the optional double value associated with an index.
- |
-
double |
-optDouble(int index,
- double defaultValue)
-Get the optional double value associated with an index.
- |
-
int |
-optInt(int index)
-Get the optional int value associated with an index.
- |
-
int |
-optInt(int index,
- int defaultValue)
-Get the optional int value associated with an index.
- |
-
JSONArray |
-optJSONArray(int index)
-Get the optional JSONArray associated with an index.
- |
-
JSONObject |
-optJSONObject(int index)
-Get the optional JSONObject associated with an index.
- |
-
long |
-optLong(int index)
-Get the optional long value associated with an index.
- |
-
long |
-optLong(int index,
- long defaultValue)
-Get the optional long value associated with an index.
- |
-
String |
-optString(int index)
-Get the optional string value associated with an index.
- |
-
String |
-optString(int index,
- String defaultValue)
-Get the optional string associated with an index.
- |
-
JSONArray |
-put(boolean value)
-Append a boolean value.
- |
-
JSONArray |
-put(Collection value)
-Put a value in the JSONArray, where the value will be a JSONArray which is
- produced from a Collection.
- |
-
JSONArray |
-put(double value)
-Append a double value.
- |
-
JSONArray |
-put(int value)
-Append an int value.
- |
-
JSONArray |
-put(int index,
- boolean value)
-Put or replace a boolean value in the JSONArray.
- |
-
JSONArray |
-put(int index,
- Collection value)
-Put a value in the JSONArray, where the value will be a JSONArray which is
- produced from a Collection.
- |
-
JSONArray |
-put(int index,
- double value)
-Put or replace a double value.
- |
-
JSONArray |
-put(int index,
- int value)
-Put or replace an int value.
- |
-
JSONArray |
-put(int index,
- long value)
-Put or replace a long value.
- |
-
JSONArray |
-put(int index,
- Map value)
-Put a value in the JSONArray, where the value will be a JSONObject which is
- produced from a Map.
- |
-
JSONArray |
-put(int index,
- Object value)
-Put or replace an object value in the JSONArray.
- |
-
JSONArray |
-put(long value)
-Append an long value.
- |
-
JSONArray |
-put(Map value)
-Put a value in the JSONArray, where the value will be a JSONObject which is
- produced from a Map.
- |
-
JSONArray |
-put(Object value)
-Append an object value.
- |
-
Object |
-remove(int index)
-Remove an index and close the hole.
- |
-
JSONObject |
-toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
String |
-toString()
-Make a JSON text of this JSONArray.
- |
-
String |
-toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONArray.
- |
-
Writer |
-write(Writer writer)
-Write the contents of the JSONArray as JSON text to a writer.
- |
-
public JSONArray()-
public JSONArray(JSONTokener x) - throws JSONException-
x
- A JSONTokenerJSONException
- If there is a syntax error.public JSONArray(String source) - throws JSONException-
source
- A string that begins with [
(left
- bracket) and ends with ]
(right
- bracket).JSONException
- If there is a syntax error.public JSONArray(Collection collection)-
collection
- A Collection.public JSONArray(Object array) - throws JSONException-
array
- TODOJSONException
- If not an array.public Object get(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If there is no value for the index.public boolean getBoolean(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If there is no value for the index or if the value is
- not convertable to boolean.public double getDouble(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If the key is not found or if the value cannot be
- converted to a number.public int getInt(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If the key is not found or if the value cannot be
- converted to a number. if the value cannot be converted to a
- number.public JSONArray getJSONArray(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If there is no value for the index. or if the value
- is not a JSONArraypublic JSONObject getJSONObject(int index) - throws JSONException-
index
- subscriptJSONException
- If there is no value for the index or if the value is
- not a JSONObjectpublic long getLong(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If the key is not found or if the value cannot be
- converted to a number.public String getString(int index) - throws JSONException-
index
- The index must be between 0 and length() - 1.JSONException
- If there is no value for the index.public boolean isNull(int index)-
index
- The index must be between 0 and length() - 1.public String join(String separator) - throws JSONException-
separator
string is inserted between each element. Warning:
- This method assumes that the data structure is acyclical.separator
- A string that will be inserted between the elements.JSONException
- If the array contains an invalid number.public int length()-
public Object opt(int index)-
index
- The index must be between 0 and length() - 1.public boolean optBoolean(int index)-
index
- The index must be between 0 and length() - 1.public boolean optBoolean(int index, - boolean defaultValue)-
index
- The index must be between 0 and length() - 1.defaultValue
- A boolean default.public double optDouble(int index)-
index
- The index must be between 0 and length() - 1.public double optDouble(int index, - double defaultValue)-
index
- subscriptdefaultValue
- The default value.public int optInt(int index)-
index
- The index must be between 0 and length() - 1.public int optInt(int index, - int defaultValue)-
index
- The index must be between 0 and length() - 1.defaultValue
- The default value.public JSONArray optJSONArray(int index)-
index
- subscriptpublic JSONObject optJSONObject(int index)-
index
- The index must be between 0 and length() - 1.public long optLong(int index)-
index
- The index must be between 0 and length() - 1.public long optLong(int index, - long defaultValue)-
index
- The index must be between 0 and length() - 1.defaultValue
- The default value.public String optString(int index)-
index
- The index must be between 0 and length() - 1.public String optString(int index, - String defaultValue)-
index
- The index must be between 0 and length() - 1.defaultValue
- The default value.public JSONArray put(boolean value)-
value
- A boolean value.public JSONArray put(Collection value)-
value
- A Collection value.public JSONArray put(double value) - throws JSONException-
value
- A double value.JSONException
- if the value is not finite.public JSONArray put(int value)-
value
- An int value.public JSONArray put(long value)-
value
- A long value.public JSONArray put(Map value)-
value
- A Map value.public JSONArray put(Object value)-
value
- An object value. The value should be a Boolean, Double,
- Integer, JSONArray, JSONObject, Long, or String, or the
- JSONObject.NULL object.public JSONArray put(int index, - boolean value) - throws JSONException-
index
- The subscript.value
- A boolean value.JSONException
- If the index is negative.public JSONArray put(int index, - Collection value) - throws JSONException-
index
- The subscript.value
- A Collection value.JSONException
- If the index is negative or if the value is not
- finite.public JSONArray put(int index, - double value) - throws JSONException-
index
- The subscript.value
- A double value.JSONException
- If the index is negative or if the value is not
- finite.public JSONArray put(int index, - int value) - throws JSONException-
index
- The subscript.value
- An int value.JSONException
- If the index is negative.public JSONArray put(int index, - long value) - throws JSONException-
index
- The subscript.value
- A long value.JSONException
- If the index is negative.public JSONArray put(int index, - Map value) - throws JSONException-
index
- The subscript.value
- The Map value.JSONException
- If the index is negative or if the the value is an
- invalid number.public JSONArray put(int index, - Object value) - throws JSONException-
index
- The subscript.value
- The value to put into the array. The value should be a
- Boolean, Double, Integer, JSONArray, JSONObject, Long, or String,
- or the JSONObject.NULL object.JSONException
- If the index is negative or if the the value is an
- invalid number.public Object remove(int index)-
index
- The index of the element to be removed.public JSONObject toJSONObject(JSONArray names) - throws JSONException-
names
- A JSONArray containing a list of key strings. These will be
- paired with the values.JSONException
- If any of the names are null.public String toString()-
- Warning: This method assumes that the data structure is acyclical.
public String toString(int indentFactor) - throws JSONException-
indentFactor
- The number of spaces to add to each level of
- indentation.[
(left
- bracket) and ending with ]
(right
- bracket).JSONException
public Writer write(Writer writer) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
writer
- TODOJSONException
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/JSONException.html b/doc/org/json/JSONException.html deleted file mode 100644 index 847dd42..0000000 --- a/doc/org/json/JSONException.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - -public class JSONException -extends Exception-
Constructor and Description | -
---|
JSONException(String message)
-Constructs a JSONException with an explanatory message.
- |
-
JSONException(Throwable t) |
-
Modifier and Type | -Method and Description | -
---|---|
Throwable |
-getCause()
-(non-Javadoc)
- |
-
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public JSONException(String message)-
message
- Detail about the reason for the exception.public JSONException(Throwable t)-
t
- TODOCopyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/JSONObject.html b/doc/org/json/JSONObject.html deleted file mode 100644 index f778521..0000000 --- a/doc/org/json/JSONObject.html +++ /dev/null @@ -1,1574 +0,0 @@ - - - - - - -public class JSONObject -extends Object-
get
and opt
methods for accessing the
- values by name, and put
methods for adding or replacing values
- by name. The values can be any of these types: Boolean
,
- JSONArray
, JSONObject
, Number
,
- String
, or the JSONObject.NULL
object. A JSONObject
- constructor can be used to convert an external form JSON text into an
- internal form whose values can be retrieved with the get
and
- opt
methods, or to convert values into a JSON text using the
- put
and toString
methods. A get
method
- returns a value if one can be found, and throws an exception if one cannot be
- found. An opt
method returns a default value instead of throwing
- an exception, and so is useful for obtaining optional values.
-
- The generic get()
and opt()
methods return an
- object, which you can cast or query for type. There are also typed
- get
and opt
methods that do type checking and type
- coercion for you.
-
- The put
methods adds values to an object. For example,
-
-
- myString = new JSONObject().put("JSON", "Hello, World!").toString(); -- - produces the string
{"JSON": "Hello, World"}
.
-
- The texts produced by the toString
methods strictly conform to
- the JSON syntax rules. The constructors are more forgiving in the texts they
- will accept:
-
,
(comma) may appear just
- before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and
- if they are not the reserved words true
, false
, or
- null
.=
or =>
as well as by
- :
.;
(semicolon) as
- well as by ,
(comma).0-
(octal) or 0x-
- (hex) prefix.Modifier and Type | -Field and Description | -
---|---|
static Object |
-NULL
-It is sometimes more convenient and less ambiguous to have a
-
-NULL object than to use Java's null value. |
-
Constructor and Description | -
---|
JSONObject()
-Construct an empty JSONObject.
- |
-
JSONObject(JSONObject jo,
- String[] names)
-Construct a JSONObject from a subset of another JSONObject.
- |
-
JSONObject(JSONTokener x)
-Construct a JSONObject from a JSONTokener.
- |
-
JSONObject(Map map)
-Construct a JSONObject from a Map.
- |
-
JSONObject(Object bean)
-Construct a JSONObject from an Object using bean getters.
- |
-
JSONObject(Object object,
- String[] names)
-Construct a JSONObject from an Object, using reflection to find the public
- members.
- |
-
JSONObject(String source)
-Construct a JSONObject from a source JSON text string.
- |
-
Modifier and Type | -Method and Description | -
---|---|
JSONObject |
-accumulate(String key,
- Object value)
-Accumulate values under a key.
- |
-
JSONObject |
-append(String key,
- Object value)
-Append values to the array under a key.
- |
-
static String |
-doubleToString(double d)
-Produce a string from a double.
- |
-
Object |
-get(String key)
-Get the value object associated with a key.
- |
-
boolean |
-getBoolean(String key)
-Get the boolean value associated with a key.
- |
-
double |
-getDouble(String key)
-Get the double value associated with a key.
- |
-
int |
-getInt(String key)
-Get the int value associated with a key.
- |
-
JSONArray |
-getJSONArray(String key)
-Get the JSONArray value associated with a key.
- |
-
JSONObject |
-getJSONObject(String key)
-Get the JSONObject value associated with a key.
- |
-
long |
-getLong(String key)
-Get the long value associated with a key.
- |
-
static String[] |
-getNames(JSONObject jo)
-Get an array of field names from a JSONObject.
- |
-
static String[] |
-getNames(Object object)
-Get an array of field names from an Object.
- |
-
String |
-getString(String key)
-Get the string associated with a key.
- |
-
boolean |
-has(String key)
-Determine if the JSONObject contains a specific key.
- |
-
JSONObject |
-increment(String key)
-Increment a property of a JSONObject.
- |
-
boolean |
-isNull(String key)
-Determine if the value associated with the key is null or if there is no
- value.
- |
-
Iterator |
-keys()
-Get an enumeration of the keys of the JSONObject.
- |
-
int |
-length()
-Get the number of keys stored in the JSONObject.
- |
-
JSONArray |
-names()
-Produce a JSONArray containing the names of the elements of this
- JSONObject.
- |
-
static String |
-numberToString(Number n)
-Produce a string from a Number.
- |
-
Object |
-opt(String key)
-Get an optional value associated with a key.
- |
-
boolean |
-optBoolean(String key)
-Get an optional boolean associated with a key.
- |
-
boolean |
-optBoolean(String key,
- boolean defaultValue)
-Get an optional boolean associated with a key.
- |
-
double |
-optDouble(String key)
-Get an optional double associated with a key, or NaN if there is no such
- key or if its value is not a number.
- |
-
double |
-optDouble(String key,
- double defaultValue)
-Get an optional double associated with a key, or the defaultValue if there
- is no such key or if its value is not a number.
- |
-
int |
-optInt(String key)
-Get an optional int value associated with a key, or zero if there is no
- such key or if the value is not a number.
- |
-
int |
-optInt(String key,
- int defaultValue)
-Get an optional int value associated with a key, or the default if there is
- no such key or if the value is not a number.
- |
-
JSONArray |
-optJSONArray(String key)
-Get an optional JSONArray associated with a key.
- |
-
JSONObject |
-optJSONObject(String key)
-Get an optional JSONObject associated with a key.
- |
-
long |
-optLong(String key)
-Get an optional long value associated with a key, or zero if there is no
- such key or if the value is not a number.
- |
-
long |
-optLong(String key,
- long defaultValue)
-Get an optional long value associated with a key, or the default if there
- is no such key or if the value is not a number.
- |
-
String |
-optString(String key)
-Get an optional string associated with a key.
- |
-
String |
-optString(String key,
- String defaultValue)
-Get an optional string associated with a key.
- |
-
JSONObject |
-put(String key,
- boolean value)
-Put a key/boolean pair in the JSONObject.
- |
-
JSONObject |
-put(String key,
- Collection value)
-Put a key/value pair in the JSONObject, where the value will be a JSONArray
- which is produced from a Collection.
- |
-
JSONObject |
-put(String key,
- double value)
-Put a key/double pair in the JSONObject.
- |
-
JSONObject |
-put(String key,
- int value)
-Put a key/int pair in the JSONObject.
- |
-
JSONObject |
-put(String key,
- long value)
-Put a key/long pair in the JSONObject.
- |
-
JSONObject |
-put(String key,
- Map value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONObject which is produced from a Map.
- |
-
JSONObject |
-put(String key,
- Object value)
-Put a key/value pair in the JSONObject.
- |
-
JSONObject |
-putOnce(String key,
- Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null, and only if there is not already a member with that
- name.
- |
-
JSONObject |
-putOpt(String key,
- Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null.
- |
-
static String |
-quote(String string)
-Produce a string in double quotes with backslash sequences in all the right
- places.
- |
-
Object |
-remove(String key)
-Remove a name and its value, if present.
- |
-
Iterator |
-sortedKeys()
-Get an enumeration of the keys of the JSONObject.
- |
-
static Object |
-stringToValue(String s)
-Try to convert a string into a number, boolean, or null.
- |
-
JSONArray |
-toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
String |
-toString()
-Make a JSON text of this JSONObject.
- |
-
String |
-toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONObject.
- |
-
Writer |
-write(Writer writer)
-Write the contents of the JSONObject as JSON text to a writer.
- |
-
public JSONObject()-
public JSONObject(JSONObject jo, - String[] names)-
jo
- A JSONObject.names
- An array of strings.public JSONObject(JSONTokener x) - throws JSONException-
x
- A JSONTokener object containing the source string.JSONException
- If there is a syntax error in the source string or a
- duplicated key.public JSONObject(Map map)-
map
- A map object that can be used to initialize the contents of the
- JSONObject.public JSONObject(Object bean)-
"get"
or "is"
- followed by an uppercase letter, the method is invoked, and a key and the
- value returned from the getter method are put into the new JSONObject.
-
- The key is formed by removing the "get"
or "is"
- prefix. If the second remaining character is not upper case, then the first
- character is converted to lower case.
-
- For example, if an object has a method named "getName"
, and if
- the result of calling object.getName()
is
- "Larry Fine"
, then the JSONObject will contain
- "name": "Larry Fine"
.bean
- An object that has getter methods that should be used to make a
- JSONObject.public JSONObject(Object object, - String[] names)-
object
- An object that has fields that should be used to make a
- JSONObject.names
- An array of strings, the names of the fields to be obtained
- from the object.public JSONObject(String source) - throws JSONException-
source
- A string beginning with {
(left
- brace) and ending with }
(right
- brace).JSONException
- If there is a syntax error in the source string or
- a duplicated key.public JSONObject accumulate(String key, - Object value) - throws JSONException-
key
- A key string.value
- An object to be accumulated under the key.JSONException
- If the value is an invalid number or if the key is
- null.public JSONObject append(String key, - Object value) - throws JSONException-
key
- A key string.value
- An object to be accumulated under the key.JSONException
- If the key is null or if the current value associated
- with the key is not a JSONArray.public static String doubleToString(double d)-
d
- A double.public Object get(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found.public boolean getBoolean(String key) - throws JSONException-
key
- A key string.JSONException
- if the value is not a Boolean or the String "true" or
- "false".public double getDouble(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found or if the value is not a
- Number object and cannot be converted to a number.public int getInt(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found or if the value cannot be
- converted to an integer.public JSONArray getJSONArray(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found or if the value is not a
- JSONArray.public JSONObject getJSONObject(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found or if the value is not a
- JSONObject.public long getLong(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found or if the value cannot be
- converted to a long.public static String[] getNames(JSONObject jo)-
jo
- TODOpublic static String[] getNames(Object object)-
object
- TODOpublic String getString(String key) - throws JSONException-
key
- A key string.JSONException
- if the key is not found.public boolean has(String key)-
key
- A key string.public JSONObject increment(String key) - throws JSONException-
key
- A key string.JSONException
- If there is already a property with this name that is
- not an Integer, Long, Double, or Float.public boolean isNull(String key)-
key
- A key string.public Iterator keys()-
public int length()-
public JSONArray names()-
public static String numberToString(Number n) - throws JSONException-
n
- A NumberJSONException
- If n is a non-finite number.public Object opt(String key)-
key
- A key string.public boolean optBoolean(String key)-
key
- A key string.public boolean optBoolean(String key, - boolean defaultValue)-
key
- A key string.defaultValue
- The default.public double optDouble(String key)-
key
- A string which is the key.public double optDouble(String key, - double defaultValue)-
key
- A key string.defaultValue
- The default.public int optInt(String key)-
key
- A key string.public int optInt(String key, - int defaultValue)-
key
- A key string.defaultValue
- The default.public JSONArray optJSONArray(String key)-
key
- A key string.public JSONObject optJSONObject(String key)-
key
- A key string.public long optLong(String key)-
key
- A key string.public long optLong(String key, - long defaultValue)-
key
- A key string.defaultValue
- The default.public String optString(String key)-
key
- A key string.public String optString(String key, - String defaultValue)-
key
- A key string.defaultValue
- The default.public JSONObject put(String key, - boolean value) - throws JSONException-
key
- A key string.value
- A boolean which is the value.JSONException
- If the key is null.public JSONObject put(String key, - Collection value) - throws JSONException-
key
- A key string.value
- A Collection value.JSONException
public JSONObject put(String key, - double value) - throws JSONException-
key
- A key string.value
- A double which is the value.JSONException
- If the key is null or if the number is invalid.public JSONObject put(String key, - int value) - throws JSONException-
key
- A key string.value
- An int which is the value.JSONException
- If the key is null.public JSONObject put(String key, - long value) - throws JSONException-
key
- A key string.value
- A long which is the value.JSONException
- If the key is null.public JSONObject put(String key, - Map value) - throws JSONException-
key
- A key string.value
- A Map value.JSONException
public JSONObject put(String key, - Object value) - throws JSONException-
key
- A key string.value
- An object which is the value. It should be of one of these
- types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
- String, or the JSONObject.NULL object.JSONException
- If the value is non-finite number or if the key is
- null.public JSONObject putOnce(String key, - Object value) - throws JSONException-
key
- value
- JSONException
- if the key is a duplicatepublic JSONObject putOpt(String key, - Object value) - throws JSONException-
key
- A key string.value
- An object which is the value. It should be of one of these
- types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
- String, or the JSONObject.NULL object.JSONException
- If the value is a non-finite number.public static String quote(String string)-
string
- A Stringpublic Object remove(String key)-
key
- The name to be removed.public Iterator sortedKeys()-
public static Object stringToValue(String s)-
s
- A String.public JSONArray toJSONArray(JSONArray names) - throws JSONException-
names
- A JSONArray containing a list of key strings. This determines
- the sequence of the values in the result.JSONException
- If any of the values are non-finite numbers.public String toString()-
- Warning: This method assumes that the data structure is acyclical.
public String toString(int indentFactor) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
indentFactor
- The number of spaces to add to each level of
- indentation.{
(left
- brace) and ending with }
(right
- brace).JSONException
- If the object contains an invalid number.public Writer write(Writer writer) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
writer
- TODOJSONException
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/JSONString.html b/doc/org/json/JSONString.html deleted file mode 100644 index bdf3847..0000000 --- a/doc/org/json/JSONString.html +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - -public interface JSONString-
JSONString
interface allows a toJSONString()
- method so that a class can change the behavior of
- JSONObject.toString()
, JSONArray.toString()
, and
- JSONWriter.value(
Object)
. The
- toJSONString
method will be used instead of the default behavior
- of using the Object's toString()
method and quoting the result.Modifier and Type | -Method and Description | -
---|---|
String |
-toJSONString()
-The
-toJSONString method allows a class to produce its own JSON
- serialization. |
-
String toJSONString()-
toJSONString
method allows a class to produce its own JSON
- serialization.Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/JSONTokener.html b/doc/org/json/JSONTokener.html deleted file mode 100644 index a42ed74..0000000 --- a/doc/org/json/JSONTokener.html +++ /dev/null @@ -1,585 +0,0 @@ - - - - - - -public class JSONTokener -extends Object-
Constructor and Description | -
---|
JSONTokener(Reader reader)
-Construct a JSONTokener from a reader.
- |
-
JSONTokener(String s)
-Construct a JSONTokener from a string.
- |
-
Modifier and Type | -Method and Description | -
---|---|
void |
-back()
-Back up one character.
- |
-
static int |
-dehexchar(char c)
-Get the hex value of a character (base16).
- |
-
boolean |
-end() |
-
boolean |
-more()
-Determine if the source string still contains characters that next() can
- consume.
- |
-
char |
-next()
-Get the next character in the source string.
- |
-
char |
-next(char c)
-Consume the next character, and check that it matches a specified
- character.
- |
-
String |
-next(int n)
-Get the next n characters.
- |
-
char |
-nextClean()
-Get the next char in the string, skipping whitespace.
- |
-
String |
-nextString(char quote)
-Return the characters up to the next close quote character.
- |
-
String |
-nextTo(char d)
-Get the text up but not including the specified character or the end of
- line, whichever comes first.
- |
-
String |
-nextTo(String delimiters)
-Get the text up but not including one of the specified delimiter characters
- or the end of line, whichever comes first.
- |
-
Object |
-nextValue()
-Get the next value.
- |
-
char |
-skipTo(char to)
-Skip characters until the next character is the requested character.
- |
-
JSONException |
-syntaxError(String message)
-Make a JSONException to signal a syntax error.
- |
-
String |
-toString()
-Make a printable string of this JSONTokener.
- |
-
public JSONTokener(Reader reader)-
reader
- A reader.public JSONTokener(String s)-
s
- A source string.public void back() - throws JSONException-
JSONException
public static int dehexchar(char c)-
c
- A character between '0' and '9' or between 'A' and 'F' or between
- 'a' and 'f'.public boolean end()-
public boolean more() - throws JSONException-
JSONException
public char next() - throws JSONException-
JSONException
public char next(char c) - throws JSONException-
c
- The character to match.JSONException
- if the character does not match.public String next(int n) - throws JSONException-
n
- The number of characters to take.JSONException
- Substring bounds error if there are not n characters
- remaining in the source string.public char nextClean() - throws JSONException-
JSONException
public String nextString(char quote) - throws JSONException-
quote
- The quoting character, either "
(double
- quote) or '
(single quote).JSONException
- Unterminated string.public String nextTo(char d) - throws JSONException-
d
- A delimiter character.JSONException
public String nextTo(String delimiters) - throws JSONException-
delimiters
- A set of delimiter characters.JSONException
public Object nextValue() - throws JSONException-
JSONException
- If syntax error.public char skipTo(char to) - throws JSONException-
to
- A character to skip to.JSONException
public JSONException syntaxError(String message)-
message
- The error message.Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/class-use/JSONArray.html b/doc/org/json/class-use/JSONArray.html deleted file mode 100644 index 2d6df36..0000000 --- a/doc/org/json/class-use/JSONArray.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
org.json | -- |
Modifier and Type | -Method and Description | -
---|---|
JSONArray |
-JSONArray.getJSONArray(int index)
-Get the JSONArray associated with an index.
- |
-
JSONArray |
-JSONObject.getJSONArray(String key)
-Get the JSONArray value associated with a key.
- |
-
JSONArray |
-JSONObject.names()
-Produce a JSONArray containing the names of the elements of this
- JSONObject.
- |
-
JSONArray |
-JSONArray.optJSONArray(int index)
-Get the optional JSONArray associated with an index.
- |
-
JSONArray |
-JSONObject.optJSONArray(String key)
-Get an optional JSONArray associated with a key.
- |
-
JSONArray |
-JSONArray.put(boolean value)
-Append a boolean value.
- |
-
JSONArray |
-JSONArray.put(Collection value)
-Put a value in the JSONArray, where the value will be a JSONArray which is
- produced from a Collection.
- |
-
JSONArray |
-JSONArray.put(double value)
-Append a double value.
- |
-
JSONArray |
-JSONArray.put(int value)
-Append an int value.
- |
-
JSONArray |
-JSONArray.put(int index,
- boolean value)
-Put or replace a boolean value in the JSONArray.
- |
-
JSONArray |
-JSONArray.put(int index,
- Collection value)
-Put a value in the JSONArray, where the value will be a JSONArray which is
- produced from a Collection.
- |
-
JSONArray |
-JSONArray.put(int index,
- double value)
-Put or replace a double value.
- |
-
JSONArray |
-JSONArray.put(int index,
- int value)
-Put or replace an int value.
- |
-
JSONArray |
-JSONArray.put(int index,
- long value)
-Put or replace a long value.
- |
-
JSONArray |
-JSONArray.put(int index,
- Map value)
-Put a value in the JSONArray, where the value will be a JSONObject which is
- produced from a Map.
- |
-
JSONArray |
-JSONArray.put(int index,
- Object value)
-Put or replace an object value in the JSONArray.
- |
-
JSONArray |
-JSONArray.put(long value)
-Append an long value.
- |
-
JSONArray |
-JSONArray.put(Map value)
-Put a value in the JSONArray, where the value will be a JSONObject which is
- produced from a Map.
- |
-
JSONArray |
-JSONArray.put(Object value)
-Append an object value.
- |
-
JSONArray |
-JSONObject.toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
Modifier and Type | -Method and Description | -
---|---|
JSONArray |
-JSONObject.toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
JSONObject |
-JSONArray.toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/class-use/JSONException.html b/doc/org/json/class-use/JSONException.html deleted file mode 100644 index 7bcf82f..0000000 --- a/doc/org/json/class-use/JSONException.html +++ /dev/null @@ -1,562 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
org.json | -- |
Modifier and Type | -Method and Description | -
---|---|
JSONException |
-JSONTokener.syntaxError(String message)
-Make a JSONException to signal a syntax error.
- |
-
Modifier and Type | -Method and Description | -
---|---|
JSONObject |
-JSONObject.accumulate(String key,
- Object value)
-Accumulate values under a key.
- |
-
JSONObject |
-JSONObject.append(String key,
- Object value)
-Append values to the array under a key.
- |
-
void |
-JSONTokener.back()
-Back up one character.
- |
-
Object |
-JSONArray.get(int index)
-Get the object value associated with an index.
- |
-
Object |
-JSONObject.get(String key)
-Get the value object associated with a key.
- |
-
boolean |
-JSONArray.getBoolean(int index)
-Get the boolean value associated with an index.
- |
-
boolean |
-JSONObject.getBoolean(String key)
-Get the boolean value associated with a key.
- |
-
double |
-JSONArray.getDouble(int index)
-Get the double value associated with an index.
- |
-
double |
-JSONObject.getDouble(String key)
-Get the double value associated with a key.
- |
-
int |
-JSONArray.getInt(int index)
-Get the int value associated with an index.
- |
-
int |
-JSONObject.getInt(String key)
-Get the int value associated with a key.
- |
-
JSONArray |
-JSONArray.getJSONArray(int index)
-Get the JSONArray associated with an index.
- |
-
JSONArray |
-JSONObject.getJSONArray(String key)
-Get the JSONArray value associated with a key.
- |
-
JSONObject |
-JSONArray.getJSONObject(int index)
-Get the JSONObject associated with an index.
- |
-
JSONObject |
-JSONObject.getJSONObject(String key)
-Get the JSONObject value associated with a key.
- |
-
long |
-JSONArray.getLong(int index)
-Get the long value associated with an index.
- |
-
long |
-JSONObject.getLong(String key)
-Get the long value associated with a key.
- |
-
String |
-JSONArray.getString(int index)
-Get the string associated with an index.
- |
-
String |
-JSONObject.getString(String key)
-Get the string associated with a key.
- |
-
JSONObject |
-JSONObject.increment(String key)
-Increment a property of a JSONObject.
- |
-
String |
-JSONArray.join(String separator)
-Make a string from the contents of this JSONArray.
- |
-
boolean |
-JSONTokener.more()
-Determine if the source string still contains characters that next() can
- consume.
- |
-
char |
-JSONTokener.next()
-Get the next character in the source string.
- |
-
char |
-JSONTokener.next(char c)
-Consume the next character, and check that it matches a specified
- character.
- |
-
String |
-JSONTokener.next(int n)
-Get the next n characters.
- |
-
char |
-JSONTokener.nextClean()
-Get the next char in the string, skipping whitespace.
- |
-
String |
-JSONTokener.nextString(char quote)
-Return the characters up to the next close quote character.
- |
-
String |
-JSONTokener.nextTo(char d)
-Get the text up but not including the specified character or the end of
- line, whichever comes first.
- |
-
String |
-JSONTokener.nextTo(String delimiters)
-Get the text up but not including one of the specified delimiter characters
- or the end of line, whichever comes first.
- |
-
Object |
-JSONTokener.nextValue()
-Get the next value.
- |
-
static String |
-JSONObject.numberToString(Number n)
-Produce a string from a Number.
- |
-
JSONArray |
-JSONArray.put(double value)
-Append a double value.
- |
-
JSONArray |
-JSONArray.put(int index,
- boolean value)
-Put or replace a boolean value in the JSONArray.
- |
-
JSONArray |
-JSONArray.put(int index,
- Collection value)
-Put a value in the JSONArray, where the value will be a JSONArray which is
- produced from a Collection.
- |
-
JSONArray |
-JSONArray.put(int index,
- double value)
-Put or replace a double value.
- |
-
JSONArray |
-JSONArray.put(int index,
- int value)
-Put or replace an int value.
- |
-
JSONArray |
-JSONArray.put(int index,
- long value)
-Put or replace a long value.
- |
-
JSONArray |
-JSONArray.put(int index,
- Map value)
-Put a value in the JSONArray, where the value will be a JSONObject which is
- produced from a Map.
- |
-
JSONArray |
-JSONArray.put(int index,
- Object value)
-Put or replace an object value in the JSONArray.
- |
-
JSONObject |
-JSONObject.put(String key,
- boolean value)
-Put a key/boolean pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- Collection value)
-Put a key/value pair in the JSONObject, where the value will be a JSONArray
- which is produced from a Collection.
- |
-
JSONObject |
-JSONObject.put(String key,
- double value)
-Put a key/double pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- int value)
-Put a key/int pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- long value)
-Put a key/long pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- Map value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONObject which is produced from a Map.
- |
-
JSONObject |
-JSONObject.put(String key,
- Object value)
-Put a key/value pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.putOnce(String key,
- Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null, and only if there is not already a member with that
- name.
- |
-
JSONObject |
-JSONObject.putOpt(String key,
- Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null.
- |
-
char |
-JSONTokener.skipTo(char to)
-Skip characters until the next character is the requested character.
- |
-
JSONArray |
-JSONObject.toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
JSONObject |
-JSONArray.toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
String |
-JSONObject.toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONObject.
- |
-
String |
-JSONArray.toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONArray.
- |
-
Writer |
-JSONObject.write(Writer writer)
-Write the contents of the JSONObject as JSON text to a writer.
- |
-
Writer |
-JSONArray.write(Writer writer)
-Write the contents of the JSONArray as JSON text to a writer.
- |
-
Constructor and Description | -
---|
JSONArray(JSONTokener x)
-Construct a JSONArray from a JSONTokener.
- |
-
JSONArray(Object array)
-Construct a JSONArray from an array
- |
-
JSONArray(String source)
-Construct a JSONArray from a source JSON text.
- |
-
JSONObject(JSONTokener x)
-Construct a JSONObject from a JSONTokener.
- |
-
JSONObject(String source)
-Construct a JSONObject from a source JSON text string.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/class-use/JSONObject.html b/doc/org/json/class-use/JSONObject.html deleted file mode 100644 index 613d187..0000000 --- a/doc/org/json/class-use/JSONObject.html +++ /dev/null @@ -1,329 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
org.json | -- |
Modifier and Type | -Method and Description | -
---|---|
void |
-JSONConvertable.fromJSONObject(JSONObject jsonObject) |
-
void |
-CustomField.fromJSONObject(JSONObject o)
-(non-Javadoc)
- |
-
Modifier and Type | -Method and Description | -
---|---|
JSONObject |
-JSONObject.accumulate(String key,
- Object value)
-Accumulate values under a key.
- |
-
JSONObject |
-JSONObject.append(String key,
- Object value)
-Append values to the array under a key.
- |
-
JSONObject |
-JSONArray.getJSONObject(int index)
-Get the JSONObject associated with an index.
- |
-
JSONObject |
-JSONObject.getJSONObject(String key)
-Get the JSONObject value associated with a key.
- |
-
JSONObject |
-JSONObject.increment(String key)
-Increment a property of a JSONObject.
- |
-
JSONObject |
-JSONArray.optJSONObject(int index)
-Get the optional JSONObject associated with an index.
- |
-
JSONObject |
-JSONObject.optJSONObject(String key)
-Get an optional JSONObject associated with a key.
- |
-
JSONObject |
-JSONObject.put(String key,
- boolean value)
-Put a key/boolean pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- Collection value)
-Put a key/value pair in the JSONObject, where the value will be a JSONArray
- which is produced from a Collection.
- |
-
JSONObject |
-JSONObject.put(String key,
- double value)
-Put a key/double pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- int value)
-Put a key/int pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- long value)
-Put a key/long pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(String key,
- Map value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONObject which is produced from a Map.
- |
-
JSONObject |
-JSONObject.put(String key,
- Object value)
-Put a key/value pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.putOnce(String key,
- Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null, and only if there is not already a member with that
- name.
- |
-
JSONObject |
-JSONObject.putOpt(String key,
- Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null.
- |
-
JSONObject |
-JSONArray.toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
Modifier and Type | -Method and Description | -
---|---|
static String[] |
-JSONObject.getNames(JSONObject jo)
-Get an array of field names from a JSONObject.
- |
-
Constructor and Description | -
---|
JSONObject(JSONObject jo,
- String[] names)
-Construct a JSONObject from a subset of another JSONObject.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/class-use/JSONString.html b/doc/org/json/class-use/JSONString.html deleted file mode 100644 index e567134..0000000 --- a/doc/org/json/class-use/JSONString.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/class-use/JSONTokener.html b/doc/org/json/class-use/JSONTokener.html deleted file mode 100644 index 082fb47..0000000 --- a/doc/org/json/class-use/JSONTokener.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
org.json | -- |
Constructor and Description | -
---|
JSONArray(JSONTokener x)
-Construct a JSONArray from a JSONTokener.
- |
-
JSONObject(JSONTokener x)
-Construct a JSONObject from a JSONTokener.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/package-frame.html b/doc/org/json/package-frame.html deleted file mode 100644 index 2747134..0000000 --- a/doc/org/json/package-frame.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - -Interface | -Description | -
---|---|
JSONString | -
- The
-JSONString interface allows a toJSONString()
- method so that a class can change the behavior of
- JSONObject.toString() , JSONArray.toString() , and
- JSONWriter.value( Object) . |
-
Class | -Description | -
---|---|
JSONArray | -
- A JSONArray is an ordered sequence of values.
- |
-
JSONObject | -
- A JSONObject is an unordered collection of name/value pairs.
- |
-
JSONTokener | -
- A JSONTokener takes a source string and extracts characters and tokens from
- it.
- |
-
Exception | -Description | -
---|---|
JSONException | -
- The JSONException is thrown by the JSON.org classes when things are amiss.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/package-tree.html b/doc/org/json/package-tree.html deleted file mode 100644 index 4b45993..0000000 --- a/doc/org/json/package-tree.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/org/json/package-use.html b/doc/org/json/package-use.html deleted file mode 100644 index aead4a4..0000000 --- a/doc/org/json/package-use.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - -Package | -Description | -
---|---|
net.bican.wordpress | -- |
org.json | -- |
Class and Description | -
---|
JSONObject
- A JSONObject is an unordered collection of name/value pairs.
- |
-
Class and Description | -
---|
JSONArray
- A JSONArray is an ordered sequence of values.
- |
-
JSONException
- The JSONException is thrown by the JSON.org classes when things are amiss.
- |
-
JSONObject
- A JSONObject is an unordered collection of name/value pairs.
- |
-
JSONTokener
- A JSONTokener takes a source string and extracts characters and tokens from
- it.
- |
-
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/overview-frame.html b/doc/overview-frame.html deleted file mode 100644 index 888004e..0000000 --- a/doc/overview-frame.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - -- - diff --git a/doc/overview-summary.html b/doc/overview-summary.html deleted file mode 100644 index c19bc40..0000000 --- a/doc/overview-summary.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - -
Package | -Description | -
---|---|
net.bican.wordpress | -- |
net.bican.wordpress.configuration | -- |
net.bican.wordpress.example | -- |
org.json | -- |
Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/overview-tree.html b/doc/overview-tree.html deleted file mode 100644 index acc46b2..0000000 --- a/doc/overview-tree.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/package-list b/doc/package-list deleted file mode 100644 index ccefa53..0000000 --- a/doc/package-list +++ /dev/null @@ -1,4 +0,0 @@ -net.bican.wordpress -net.bican.wordpress.configuration -net.bican.wordpress.example -org.json diff --git a/doc/resources/background.gif b/doc/resources/background.gif deleted file mode 100644 index f471940..0000000 Binary files a/doc/resources/background.gif and /dev/null differ diff --git a/doc/resources/tab.gif b/doc/resources/tab.gif deleted file mode 100644 index 1a73a83..0000000 Binary files a/doc/resources/tab.gif and /dev/null differ diff --git a/doc/resources/titlebar.gif b/doc/resources/titlebar.gif deleted file mode 100644 index 17443b3..0000000 Binary files a/doc/resources/titlebar.gif and /dev/null differ diff --git a/doc/resources/titlebar_end.gif b/doc/resources/titlebar_end.gif deleted file mode 100644 index 3ad78d4..0000000 Binary files a/doc/resources/titlebar_end.gif and /dev/null differ diff --git a/doc/serialized-form.html b/doc/serialized-form.html deleted file mode 100644 index 5954950..0000000 --- a/doc/serialized-form.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - -Copyright © 2012-2015 Can Bican. All Rights Reserved.
- - diff --git a/doc/src-html/net/bican/wordpress/Author.html b/doc/src-html/net/bican/wordpress/Author.html deleted file mode 100644 index 47b2a17..0000000 --- a/doc/src-html/net/bican/wordpress/Author.html +++ /dev/null @@ -1,162 +0,0 @@ - - - -001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Author object for a blog. -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class Author extends XmlRpcMapped implements StringHeader { -020 String display_name; -021 -022 String user_id; -023 -024 String user_login; -025 -026 /** -027 * Display Name of the author. -028 * -029 * @return the display_name -030 */ -031 public String getDisplay_name() { -032 return this.display_name; -033 } -034 -035 /** -036 * User id of the author. -037 * -038 * @return the user_id -039 */ -040 public String getUser_id() { -041 return this.user_id; -042 } -043 -044 /** -045 * Login name of the author. -046 * -047 * @return the user_login -048 */ -049 public String getUser_login() { -050 return this.user_login; -051 } -052 -053 /** -054 * Display name of the author. -055 * -056 * @param display_name the display_name to set -057 */ -058 public void setDisplay_name(String display_name) { -059 this.display_name = display_name; -060 } -061 -062 /** -063 * User id of the author. -064 * -065 * @param user_id the user_id to set -066 */ -067 public void setUser_id(String user_id) { -068 this.user_id = user_id; -069 } -070 -071 /** -072 * Login name of the author. -073 * -074 * @param user_login the user_login to set -075 */ -076 public void setUser_login(String user_login) { -077 this.user_login = user_login; -078 } -079 -080 /** -081 * (non-Javadoc) -082 * -083 * @see net.bican.wordpress.StringHeader#getStringHeader() -084 */ -085 @Override -086 @SuppressWarnings("nls") -087 public String getStringHeader() { -088 return "User_id:User_login:display_name"; -089 } -090} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Class that keeps the information on a blog for a user -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class Blog extends XmlRpcMapped { -020 Boolean isAdmin; -021 -022 String url; -023 -024 String blogid; -025 -026 String blogName; -027 -028 /** -029 * @return the isAdmin -030 */ -031 public Boolean getIsAdmin() { -032 return this.isAdmin; -033 } -034 -035 /** -036 * @param isAdmin the isAdmin to set -037 */ -038 public void setIsAdmin(Boolean isAdmin) { -039 this.isAdmin = isAdmin; -040 } -041 -042 /** -043 * @return the url -044 */ -045 public String getUrl() { -046 return this.url; -047 } -048 -049 /** -050 * @param url the url to set -051 */ -052 public void setUrl(String url) { -053 this.url = url; -054 } -055 -056 /** -057 * @return the blogid -058 */ -059 public String getBlogid() { -060 return this.blogid; -061 } -062 -063 /** -064 * @param blogid the blogid to set -065 */ -066 public void setBlogid(String blogid) { -067 this.blogid = blogid; -068 } -069 -070 /** -071 * @return the blogName -072 */ -073 public String getBlogName() { -074 return this.blogName; -075 } -076 -077 /** -078 * @param blogName the blogName to set -079 */ -080 public void setBlogName(String blogName) { -081 this.blogName = blogName; -082 } -083} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Category object for a blog. -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class Category extends XmlRpcMapped implements StringHeader { -020 String categoryId = null; -021 -022 String categoryName = null; -023 -024 String description = null; -025 -026 String htmlUrl = null; -027 -028 String parentId = null; -029 -030 String rssUrl = null; -031 -032 /** -033 * @return the categoryId -034 */ -035 public String getCategoryId() { -036 return this.categoryId; -037 } -038 -039 /** -040 * @return the categoryName -041 */ -042 public String getCategoryName() { -043 return this.categoryName; -044 } -045 -046 /** -047 * @return the description -048 */ -049 public String getDescription() { -050 return this.description; -051 } -052 -053 /** -054 * @return the htmlUrl -055 */ -056 public String getHtmlUrl() { -057 return this.htmlUrl; -058 } -059 -060 /** -061 * @return the parentId -062 */ -063 public String getParentId() { -064 return this.parentId; -065 } -066 -067 /** -068 * @return the rssUrl -069 */ -070 public String getRssUrl() { -071 return this.rssUrl; -072 } -073 -074 /** -075 * @param categoryId the categoryId to set -076 */ -077 public void setCategoryId(String categoryId) { -078 this.categoryId = categoryId; -079 } -080 -081 /** -082 * @param categoryName the categoryName to set -083 */ -084 public void setCategoryName(String categoryName) { -085 this.categoryName = categoryName; -086 } -087 -088 /** -089 * @param description the description to set -090 */ -091 public void setDescription(String description) { -092 this.description = description; -093 } -094 -095 /** -096 * @param htmlUrl the htmlUrl to set -097 */ -098 public void setHtmlUrl(String htmlUrl) { -099 this.htmlUrl = htmlUrl; -100 } -101 -102 /** -103 * @param parentId the parentId to set -104 */ -105 public void setParentId(String parentId) { -106 this.parentId = parentId; -107 } -108 -109 /** -110 * @param rssUrl the rssUrl to set -111 */ -112 public void setRssUrl(String rssUrl) { -113 this.rssUrl = rssUrl; -114 } -115 -116 /** -117 * (non-Javadoc) -118 * -119 * @see net.bican.wordpress.StringHeader#getStringHeader() -120 */ -121 @Override -122 @SuppressWarnings("nls") -123 public String getStringHeader() { -124 final String TAB = ":"; -125 return "Category Id" + TAB + "Category Name" + TAB + "Description" + TAB -126 + "Html Url" + TAB + "Parent Id" + TAB + "Rss Url"; -127 } -128} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.io.BufferedReader; -013import java.io.File; -014import java.io.FileNotFoundException; -015import java.io.FileReader; -016import java.io.IOException; -017import java.util.Date; -018 -019import redstone.xmlrpc.XmlRpcStruct; -020 -021/** -022 * A WordPress Comment object -023 * -024 * @author Fred Potter <fpoptter@gmail.com> -025 * -026 */ -027public class Comment extends XmlRpcMapped implements StringHeader { -028 -029 Date date_created_gmt; -030 -031 Integer user_id; -032 -033 Integer comment_id; -034 -035 Integer parent; -036 -037 String status; -038 -039 String content; -040 -041 String link; -042 -043 Integer post_id; -044 -045 String post_title; -046 -047 String author; -048 -049 String author_url; -050 -051 String author_email; -052 -053 String author_ip; -054 -055 /** -056 * @return the date_created_gmt -057 */ -058 public Date getDate_created_gmt() { -059 return this.date_created_gmt; -060 } -061 -062 /** -063 * @param dateCreatedGmt the date_created_gmt to set -064 */ -065 public void setDate_created_gmt(Date dateCreatedGmt) { -066 this.date_created_gmt = dateCreatedGmt; -067 } -068 -069 /** -070 * @return the user_id -071 */ -072 public Integer getUser_id() { -073 return this.user_id; -074 } -075 -076 /** -077 * @param userId the user_id to set -078 */ -079 public void setUser_id(Integer userId) { -080 this.user_id = userId; -081 } -082 -083 /** -084 * @return the comment_id -085 */ -086 public Integer getComment_id() { -087 return this.comment_id; -088 } -089 -090 /** -091 * @param commentId the comment_id to set -092 */ -093 public void setComment_id(Integer commentId) { -094 this.comment_id = commentId; -095 } -096 -097 /** -098 * @return the parent -099 */ -100 public Integer getParent() { -101 return this.parent; -102 } -103 -104 /** -105 * @param parent the parent to set -106 */ -107 public void setParent(Integer parent) { -108 this.parent = parent; -109 } -110 -111 /** -112 * @return the status -113 */ -114 public String getStatus() { -115 return this.status; -116 } -117 -118 /** -119 * @param status the status to set -120 */ -121 public void setStatus(String status) { -122 this.status = status; -123 } -124 -125 /** -126 * @return the content -127 */ -128 public String getContent() { -129 return this.content; -130 } -131 -132 /** -133 * @param content the content to set -134 */ -135 public void setContent(String content) { -136 this.content = content; -137 } -138 -139 /** -140 * @return the link -141 */ -142 public String getLink() { -143 return this.link; -144 } -145 -146 /** -147 * @param link the link to set -148 */ -149 public void setLink(String link) { -150 this.link = link; -151 } -152 -153 /** -154 * @return the post_id -155 */ -156 public Integer getPost_id() { -157 return this.post_id; -158 } -159 -160 /** -161 * @param postId the post_id to set -162 */ -163 public void setPost_id(Integer postId) { -164 this.post_id = postId; -165 } -166 -167 /** -168 * @return the post_title -169 */ -170 public String getPost_title() { -171 return this.post_title; -172 } -173 -174 /** -175 * @param postTitle the post_title to set -176 */ -177 public void setPost_title(String postTitle) { -178 this.post_title = postTitle; -179 } -180 -181 /** -182 * @return the author -183 */ -184 public String getAuthor() { -185 return this.author; -186 } -187 -188 /** -189 * @param author the author to set -190 */ -191 public void setAuthor(String author) { -192 this.author = author; -193 } -194 -195 /** -196 * @return the author_url -197 */ -198 public String getAuthor_url() { -199 return this.author_url; -200 } -201 -202 /** -203 * @param authorUrl the author_url to set -204 */ -205 public void setAuthor_url(String authorUrl) { -206 this.author_url = authorUrl; -207 } -208 -209 /** -210 * @return the author_email -211 */ -212 public String getAuthor_email() { -213 return this.author_email; -214 } -215 -216 /** -217 * @param authorEmail the author_email to set -218 */ -219 public void setAuthor_email(String authorEmail) { -220 this.author_email = authorEmail; -221 } -222 -223 /** -224 * @return the author_ip -225 */ -226 public String getAuthor_ip() { -227 return this.author_ip; -228 } -229 -230 /** -231 * @param authorIp the author_ip to set -232 */ -233 public void setAuthor_ip(String authorIp) { -234 this.author_ip = authorIp; -235 } -236 -237 /** -238 * (non-Javadoc) -239 * -240 * @see net.bican.wordpress.StringHeader#getStringHeader() -241 */ -242 @Override -243 @SuppressWarnings("nls") -244 public String getStringHeader() { -245 final String TAB = ":"; -246 return "Date Created GMT" + TAB + "User Id" + TAB + "Comment Id" + TAB -247 + "Parent" + TAB + "Status" + TAB + "Content" + TAB + "Link" + TAB -248 + "Post Id" + TAB + "Post Title" + TAB + "Author" + TAB + "Author URL " -249 + TAB + "Author Email" + TAB + "Author IP"; -250 } -251 -252 /** -253 * -254 * Creates a comment object from file -255 * -256 * @param file input file -257 * @return new Comment object -258 * @throws FileNotFoundException -259 * @throws IOException -260 * @throws InvalidPostFormatException -261 */ -262 public static Comment fromFile(File file) throws FileNotFoundException, -263 IOException, InvalidPostFormatException { -264 XmlRpcStruct c = FileParser.parseFile(new BufferedReader(new FileReader( -265 file))); -266 Comment result = new Comment(); -267 result.fromXmlRpcStruct(c); -268 return result; -269 } -270} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * Comment Count object for a blog post. -014 * -015 * @author Fred Potter <fpoptter@gmail.com> -016 * -017 */ -018public class CommentCount extends XmlRpcMapped implements StringHeader { -019 -020 Integer approved; -021 Integer awaiting_moderation; -022 Integer spam; -023 Integer total_comments; -024 -025 /** -026 * @return Number of approved comments. -027 */ -028 public Integer getApproved() { -029 return this.approved; -030 } -031 -032 /** -033 * @param approved Sets number of approved comments. -034 */ -035 public void setApproved(Integer approved) { -036 this.approved = approved; -037 } -038 -039 /** -040 * @return Number of comments awaiting moderation -041 */ -042 public Integer getAwaiting_moderation() { -043 return this.awaiting_moderation; -044 } -045 -046 /** -047 * @param awaitingModeration Number of comments awaiting moderation. -048 */ -049 public void setAwaiting_moderation(Integer awaitingModeration) { -050 this.awaiting_moderation = awaitingModeration; -051 } -052 -053 /** -054 * @return Number of comments marked as spam. -055 */ -056 public Integer getSpam() { -057 return this.spam; -058 } -059 -060 /** -061 * @param spam Number of comments that are spam -062 */ -063 public void setSpam(Integer spam) { -064 this.spam = spam; -065 } -066 -067 /** -068 * @return Total number of comments -069 */ -070 public Integer getTotal_comments() { -071 return this.total_comments; -072 } -073 -074 /** -075 * @param totalComments Total number of comments. -076 */ -077 public void setTotal_comments(Integer totalComments) { -078 this.total_comments = totalComments; -079 } -080 -081 /** -082 * (non-Javadoc) -083 * -084 * @see net.bican.wordpress.StringHeader#getStringHeader() -085 */ -086 @Override -087 @SuppressWarnings("nls") -088 public String getStringHeader() { -089 final String TAB = ":"; -090 return "Approved" + TAB + "Awaiting Moderation" + TAB + "Spam" + TAB -091 + "Total Comments"; -092 } -093 -094 -095} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Comment status names for the blog -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class CommentStatusList extends XmlRpcMapped implements StringHeader { -020 -021 String hold; -022 -023 String approve; -024 -025 String spam; -026 -027 /** -028 * @return hold description -029 */ -030 public String getHold() { -031 return this.hold; -032 } -033 -034 /** -035 * @return approved description -036 */ -037 public String getApprove() { -038 return this.approve; -039 } -040 -041 /** -042 * @return spam description -043 */ -044 public String getSpam() { -045 return this.spam; -046 } -047 -048 /** -049 * (non-Javadoc) -050 * @see net.bican.wordpress.StringHeader#getStringHeader() -051 */ -052 @Override -053 @SuppressWarnings("nls") -054 public String getStringHeader() { -055 final String TAB = ":"; -056 return "Name" + TAB + "Description"; -057 } -058 -059} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import org.json.JSONException; -013import org.json.JSONObject; -014 -015/** -016 * This class represents custom fields in wordpress. -017 * -018 * @author alok -019 * -020 */ -021public class CustomField extends XmlRpcMapped implements StringHeader, -022 JSONConvertable { -023 String id = null; -024 -025 String key = null; -026 -027 String value = null; -028 -029 /** -030 * (non-Javadoc) -031 * -032 * @see net.bican.wordpress.StringHeader#getStringHeader() -033 */ -034 @Override -035 @SuppressWarnings("nls") -036 public String getStringHeader() { -037 final String TAB = ":"; -038 return "Id" + TAB + "Key" + TAB + "Value"; -039 } -040 -041 /** -042 * (non-Javadoc) -043 * -044 * @see net.bican.wordpress.XmlRpcMapped#toString() -045 */ -046 @SuppressWarnings("nls") -047 @Override -048 public String toString() { -049 JSONObject o = new JSONObject(); -050 try { -051 o.put("id", this.getId()); -052 o.put("key", this.getKey()); -053 o.put("value", this.getValue()); -054 } catch (JSONException e) { -055 // TODO Auto-generated catch block -056 e.printStackTrace(); -057 } -058 return o.toString(); -059 } -060 -061 /** -062 * @return id of custom field -063 */ -064 public String getId() { -065 return this.id; -066 } -067 -068 /** -069 * @param id -070 */ -071 public void setId(String id) { -072 this.id = id; -073 } -074 -075 /** -076 * @return key of custom field -077 */ -078 public String getKey() { -079 return this.key; -080 } -081 -082 /** -083 * @param key -084 */ -085 public void setKey(String key) { -086 this.key = key; -087 } -088 -089 /** -090 * @return value of custom field -091 */ -092 public String getValue() { -093 return this.value; -094 } -095 -096 /** -097 * @param value -098 */ -099 public void setValue(String value) { -100 this.value = value; -101 } -102 -103 /** -104 * -105 * (non-Javadoc) -106 * -107 * @see net.bican.wordpress.JSONConvertable#fromJSONObject(org.json.JSONObject) -108 * -109 */ -110 @Override -111 @SuppressWarnings("nls") -112 public void fromJSONObject(JSONObject o) { -113 try { -114 this.setId(o.getString("id")); -115 } catch (JSONException e) { -116 this.setId(null); -117 } -118 try { -119 this.setKey(o.getString("key")); -120 } catch (JSONException e) { -121 this.setKey(null); -122 } -123 try { -124 this.setValue(o.getString("value")); -125 } catch (JSONException e) { -126 this.setValue(null); -127 } -128 } -129 -130} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.io.BufferedReader; -013import java.io.IOException; -014import java.util.regex.Matcher; -015import java.util.regex.Pattern; -016 -017import org.json.JSONArray; -018import org.json.JSONException; -019 -020import redstone.xmlrpc.XmlRpcArray; -021import redstone.xmlrpc.XmlRpcStruct; -022 -023/** -024 * -025 * Static methods for parsing files -026 * -027 * @author Can Bican <can@bican.net> -028 * -029 */ -030public class FileParser { -031 -032 /** -033 * -034 * Parses a file to create an xmlrpc compliant object -035 * -036 * @param input -037 * reader for the file -038 * @return New xmlrpc object -039 * @throws IOException -040 * @throws InvalidPostFormatException -041 */ -042 @SuppressWarnings("nls") -043 public static XmlRpcStruct parseFile(BufferedReader input) -044 throws IOException, InvalidPostFormatException { -045 XmlRpcStruct p = new XmlRpcStruct(); -046 String line; -047 String prevKey = null; -048 String prevValue = null; -049 Pattern keyPattern; -050 keyPattern = Pattern.compile("^[\\d\\w_]+:", Pattern.CASE_INSENSITIVE -051 | Pattern.UNICODE_CASE); -052 while ((line = input.readLine()) != null) { -053 if ((!"".equals(line)) && (!line.startsWith("#"))) { -054 Matcher m = keyPattern.matcher(line); -055 if (m.find()) { -056 if (prevKey != null) { -057 FileParser.putVal(p, prevKey, prevValue); -058 } -059 String[] vals = line.split(":", 2); -060 prevKey = vals[0]; -061 prevValue = vals[1]; -062 } else { -063 if (prevValue != null) { -064 prevValue += line; -065 } else { -066 throw new InvalidPostFormatException(); -067 } -068 } -069 } -070 } -071 if (prevKey != null) -072 FileParser.putVal(p, prevKey, prevValue); -073 return p; -074 } -075 -076 /** -077 * -078 * Fills values for an xmlrpc object -079 * -080 * @param s -081 * xmlrpc object itself -082 * @param key -083 * field name -084 * @param v -085 * field value -086 */ -087 @SuppressWarnings({ "unchecked", "rawtypes", "nls" }) -088 public static void putVal(XmlRpcStruct s, String key, String v) { -089 String value = v.trim(); -090 if (value.startsWith("[")) { -091 try { -092 JSONArray jArr = new JSONArray(value); -093 if (jArr.length() > 0) { -094 Class cType = jArr.get(0).getClass(); -095 XmlRpcArray vals = new XmlRpcArray(); -096 if (cType == String.class) { -097 for (int i = 0; i < jArr.length(); i++) { -098 vals.add(jArr.getString(i)); -099 } -100 } else { -101 String className = FileParser.getClassName(key); -102 Class<?> cl = Class.forName(className); -103 for (int i = 0; i < jArr.length(); i++) { -104 JSONConvertable o = (JSONConvertable) cl.newInstance(); -105 o.fromJSONObject(jArr.getJSONObject(i)); -106 vals.add(o); -107 } -108 } -109 s.put(key, vals); -110 } -111 } catch (JSONException e) { -112 // TODO Auto-generated catch block -113 e.printStackTrace(); -114 } catch (ClassNotFoundException e) { -115 // TODO Auto-generated catch block -116 e.printStackTrace(); -117 } catch (InstantiationException e) { -118 // TODO Auto-generated catch block -119 e.printStackTrace(); -120 } catch (IllegalAccessException e) { -121 // TODO Auto-generated catch block -122 e.printStackTrace(); -123 } -124 } else { -125 if (!"null".equalsIgnoreCase(value)) { -126 s.put(key, value); -127 } -128 } -129 } -130 -131 @SuppressWarnings("nls") -132 static String getClassName(String key) { -133 String className = key; -134 while (className.contains("_")) { -135 int pos = className.indexOf("_"); -136 Character ch = Character.valueOf(className.charAt(pos + 1)); -137 char chNew = Character.toUpperCase(ch.charValue()); -138 className = className.replaceFirst("_" + ch, chNew + ""); -139 } -140 className = className.replaceFirst("s$", ""); -141 Character ch = Character.valueOf(className.charAt(0)); -142 char chNew = Character.toUpperCase(ch.charValue()); -143 className = className.replaceFirst("^" + ch, chNew + ""); -144 return "net.bican.wordpress." + className; -145 } -146 -147} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Exception that is triggered via invalid input -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class InvalidPostFormatException extends Exception { -020 -021 private static final long serialVersionUID = 1L; -022 -023 // just a default exception -024} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import org.json.JSONObject; -013 -014/** -015 * -016 * Interface for objects that can be modified via JSON objects. -017 * -018 * @author Can Bican <can@bican.net> -019 * -020 */ -021public interface JSONConvertable { -022 /** -023 * @param jsonObject JSON object to get values from -024 */ -025 public void fromJSONObject(JSONObject jsonObject); -026} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.io.File; -013import java.io.FileNotFoundException; -014import java.io.IOException; -015import java.net.MalformedURLException; -016import java.util.List; -017 -018import javax.activation.MimetypesFileTypeMap; -019 -020import net.bican.wordpress.configuration.WpCliConfiguration; -021 -022import org.apache.commons.cli.HelpFormatter; -023import org.apache.commons.cli.Options; -024import org.apache.commons.cli.ParseException; -025 -026import redstone.xmlrpc.XmlRpcFault; -027 -028/** -029 * -030 * Main Application class for the command line interface. -031 * -032 * @author Can Bican <can@bican.net> -033 * -034 */ -035public class Main { -036 /** -037 * @param args -038 * execute with "-?" for an explanation of args -039 * @throws ParseException -040 * When the command line options cannot be parsed -041 */ -042 @SuppressWarnings({ "nls", "boxing" }) -043 public static void main(String[] args) throws ParseException { -044 try { -045 Options options = new Options(); -046 options.addOption("?", "help", false, "Print usage information"); -047 options.addOption("h", "url", true, "Specify the url to xmlrpc.php"); -048 options.addOption("u", "user", true, "User name"); -049 options.addOption("p", "pass", true, "Password"); -050 options.addOption("a", "authors", false, "Get author list"); -051 options.addOption("s", "slug", true, "Slug for categories"); -052 options.addOption("pi", "parentid", true, "Parent id for categories"); -053 options.addOption("oi", "postid", true, "Post id for pages and posts"); -054 options.addOption("c", "categories", false, "Get category list"); -055 options.addOption("cn", "newcategory", true, -056 "New category (uses --slug and --parentid)"); -057 options.addOption("cr", "deletecategory", true, -058 "Delete category <category_id>"); -059 options.addOption("pg", "pages", false, "Get page list (full)"); -060 options.addOption("pl", "pagelist", false, "Get page list"); -061 options.addOption("ps", "page", true, "Get page"); -062 options.addOption("pn", "newpage", true, -063 "New page from file <arg> (needs --publish)"); -064 options.addOption("pe", "editpage", true, -065 "Edit page (needs --postid and --publish"); -066 options.addOption("pd", "deletepage", true, -067 "Delete page (needs --publish)"); -068 options.addOption("l", "publish", true, -069 "Publish status for \"new\" options"); -070 options.addOption("us", "userinfo", false, "Get user information"); -071 options.addOption("or", "recentposts", true, "Get recent posts"); -072 options.addOption("os", "getpost", true, "Get post"); -073 options.addOption("on", "newpost", true, -074 "New post from file <arg> (needs --publish)"); -075 options.addOption("oe", "editpost", true, -076 "Edit post (needs --postid and --publish"); -077 options.addOption("od", "deletepost", true, -078 "Delete post (needs --publish)"); -079 options.addOption("sm", "supportedmethods", false, -080 "List supported methods"); -081 options.addOption("st", "supportedfilters", false, -082 "List supported text filters"); -083 options.addOption("mn", "newmedia", true, -084 "New media file (uses --overwrite)"); -085 options.addOption("ov", "overwrite", false, -086 "Allow overwrite in uploading new media"); -087 options.addOption("so", "supportedstatus", false, -088 "Print supported page and post status values"); -089 options.addOption("cs", "commentstatus", false, -090 "Print comment status names for the blog"); -091 options.addOption("cc", "commentcount", true, -092 "Get comment count for a post (-1 for all posts)"); -093 options.addOption("ca", "newcomment", true, "New comment from file"); -094 options.addOption("cd", "deletecomment", true, "Delete comment"); -095 options.addOption("ce", "editcomment", true, "Edit comment from file"); -096 options.addOption("cg", "getcomment", true, "Get comment"); -097 options.addOption("ct", "getcomments", true, "Get comments for the post"); -098 options.addOption("cs", "commentstatus", true, -099 "Comment status (for --getcomments)"); -100 options.addOption("co", "commentoffset", true, -101 "Comment offset # (for --getcomments)"); -102 options.addOption("cm", "commentnumber", true, -103 "Comment # (for --getcomments)"); -104 try { -105 WpCliConfiguration config = new WpCliConfiguration(args, options, -106 Main.class); -107 if (config.hasOption("help")) { -108 showHelp(options); -109 } else if ((!config.hasOption("url")) || (!config.hasOption("user")) -110 || (!config.hasOption("pass"))) { -111 System.err.println("Specify --user, --pass and --url"); -112 } else { -113 try { -114 Wordpress wp = new Wordpress(config.getOptionValue("user"), -115 config.getOptionValue("pass"), config.getOptionValue("url")); -116 if (config.hasOption("authors")) { -117 printList(wp.getAuthors(), Author.class, true); -118 } else if (config.hasOption("categories")) { -119 printList(wp.getCategories(), Category.class, true); -120 } else if (config.hasOption("deletecategory")) { -121 Integer category_id = Integer.valueOf(config -122 .getOptionValue("deletecategory")); -123 int r = wp.deleteCategory(category_id); -124 System.out.println(r); -125 } else if (config.hasOption("newcategory")) { -126 String slug = config.getOptionValue("slug"); -127 Integer parentId = getInteger("parentid", config); -128 if (slug == null) -129 slug = ""; -130 if (parentId == null) -131 parentId = 0; -132 System.out.println(wp.newCategory( -133 config.getOptionValue("newcategory"), slug, parentId)); -134 } else if (config.hasOption("pages")) { -135 printList(wp.getPages(), Page.class, false); -136 } else if (config.hasOption("pagelist")) { -137 printList(wp.getPageList(), PageDefinition.class, false); -138 } else if (config.hasOption("page")) { -139 printItem(wp.getPage(getInteger("page", config)), Page.class); -140 } else if (config.hasOption("userinfo")) { -141 printItem(wp.getUserInfo(), User.class); -142 } else if (config.hasOption("recentposts")) { -143 printList(wp.getRecentPosts(getInteger("recentposts", config)), -144 Page.class, false); -145 } else if (config.hasOption("getpost")) { -146 printItem(wp.getPost(getInteger("getpost", config)), Page.class); -147 } else if (config.hasOption("supportedmethods")) { -148 printList(wp.supportedMethods(), String.class, false); -149 } else if (config.hasOption("supportedfilters")) { -150 printList(wp.supportedTextFilters(), String.class, false); -151 } else if (config.hasOption("newpage")) { -152 if (!config.hasOption("publish")) { -153 showHelp(options); -154 } else { -155 System.out.println(wp.newPage( -156 Page.fromFile(new File(config.getOptionValue("newpage"))), -157 config.getOptionValue("publish"))); -158 } -159 } else if (config.hasOption("editpage")) { -160 edit(options, config, wp, "editpage", true); -161 } else if (config.hasOption("editpost")) { -162 edit(options, config, wp, "editpost", false); -163 } else if (config.hasOption("deletepage")) { -164 delete(options, config, wp, "deletepage", true); -165 } else if (config.hasOption("deletepost")) { -166 delete(options, config, wp, "deletepost", false); -167 } else if (config.hasOption("newpost")) { -168 if (!config.hasOption("publish")) { -169 showHelp(options); -170 } else { -171 System.out.println(wp.newPost( -172 Page.fromFile(new File(config.getOptionValue("newpost"))), -173 Boolean.valueOf(config.getOptionValue("publish")))); -174 } -175 } else if (config.hasOption("newmedia")) { -176 String fileName = config.getOptionValue("newmedia"); -177 File file = new File(fileName); -178 String mimeType = new MimetypesFileTypeMap().getContentType(file); -179 Boolean overwrite = Boolean.FALSE; -180 if (config.hasOption("overwrite")) -181 overwrite = Boolean.TRUE; -182 MediaObject result = wp.newMediaObject(mimeType, file, overwrite); -183 if (result != null) { -184 System.out.println(result); -185 } -186 } else if (config.hasOption("supportedstatus")) { -187 System.out.println("Recognized status values for posts:"); -188 printList(wp.getPostStatusList(), PostAndPageStatus.class, true); -189 System.out.println("\nRecognized status values for pages:"); -190 printList(wp.getPageStatusList(), PostAndPageStatus.class, true); -191 } else if (config.hasOption("commentstatus")) { -192 showCommentStatus(wp); -193 } else if (config.hasOption("commentcount")) { -194 showCommentCount(config, wp); -195 } else if (config.hasOption("newcomment")) { -196 editComment(wp, config.getOptionValue("newcomment"), "newcomment"); -197 } else if (config.hasOption("editcomment")) { -198 editComment(wp, config.getOptionValue("editcomment"), -199 "editcomment"); -200 } else if (config.hasOption("deletecomment")) { -201 System.err.println(Integer.valueOf(config -202 .getOptionValue("deletecomment"))); -203 deleteComment(wp, -204 Integer.valueOf(config.getOptionValue("deletecomment"))); -205 } else if (config.hasOption("getcomment")) { -206 printComment(wp, -207 Integer.valueOf(config.getOptionValue("getcomment"))); -208 } else if (config.hasOption("getcomments")) { -209 Integer postID = Integer.valueOf(config -210 .getOptionValue("getcomments")); -211 String commentStatus = config.getOptionValue("commentstatus"); -212 Integer commentOffset; -213 try { -214 commentOffset = Integer.valueOf(config -215 .getOptionValue("commentoffset")); -216 } catch (NumberFormatException e) { -217 commentOffset = null; -218 } -219 Integer commentNumber; -220 try { -221 commentNumber = Integer.valueOf(config -222 .getOptionValue("commentnumber")); -223 } catch (Exception e) { -224 commentNumber = null; -225 } -226 printComments(wp, postID, commentStatus, commentOffset, -227 commentNumber); -228 } else { -229 showHelp(options); -230 } -231 } catch (MalformedURLException e) { -232 System.err.println("URL \"" + config.getOptionValue("url") -233 + "\" is invalid, reason is: " + e.getLocalizedMessage()); -234 } catch (IOException e) { -235 System.err.println("Can't read from file, reason is: " -236 + e.getLocalizedMessage()); -237 } catch (InvalidPostFormatException e) { -238 System.err.println("Input format is invalid."); -239 } -240 } -241 } catch (ParseException e) { -242 System.err.println("Can't process command line arguments, reason is: " -243 + e.getLocalizedMessage()); -244 } -245 } catch (XmlRpcFault e) { -246 String reason = e.getLocalizedMessage(); -247 System.err.println("Operation failed, reason is: " + reason); -248 } -249 } -250 -251 @SuppressWarnings("nls") -252 private static void printComments(Wordpress wp, Integer postID, -253 String commentStatus, Integer commentOffset, Integer commentNumber) -254 throws XmlRpcFault { -255 List<Comment> r = wp.getComments(commentStatus, postID, commentNumber, -256 commentOffset); -257 for (Comment comment : r) { -258 System.out.println("--- BEGIN COMMENT"); -259 System.out.println(comment); -260 System.out.println("--- END COMMENT"); -261 } -262 } -263 -264 private static void printComment(Wordpress wp, Integer commentID) -265 throws XmlRpcFault { -266 Comment r = wp.getComment(commentID); -267 System.out.println(r); -268 } -269 -270 @SuppressWarnings("nls") -271 private static void deleteComment(Wordpress wp, int commentID) -272 throws XmlRpcFault { -273 boolean result = wp.deleteComment(commentID); -274 if (result) -275 System.out.println("Comment deleted."); -276 else -277 System.out.println("Comment not deleted"); -278 } -279 -280 @SuppressWarnings({ "nls", "boxing" }) -281 private static void editComment(Wordpress wp, String fileName, -282 String operation) throws XmlRpcFault, FileNotFoundException, IOException, -283 InvalidPostFormatException { -284 Comment comment = Comment.fromFile(new File(fileName)); -285 System.err.println(comment.getPost_id()); -286 System.err.println(comment.getContent()); -287 if (operation.equals("newcomment")) { -288 Integer r = wp.newComment(comment.getPost_id(), comment.getParent(), -289 comment.getContent(), comment.getAuthor(), comment.getAuthor_url(), -290 comment.getAuthor_email()); -291 System.err.println("Comment ID: " + r); -292 } else if (operation.equals("editcomment")) { -293 Boolean r = wp.editComment(comment); -294 if (r) -295 System.err.println("Comment edited."); -296 else -297 System.err.println("Comment not edited."); -298 } -299 } -300 -301 @SuppressWarnings("nls") -302 private static void showCommentCount(WpCliConfiguration config, Wordpress wp) { -303 Integer post_ID = getInteger("commentcount", config); -304 try { -305 CommentCount result = wp.getCommentsCount(post_ID); -306 System.out.println(result); -307 } catch (XmlRpcFault e) { -308 String reason = e.getLocalizedMessage(); -309 System.err.println("Operation failed, reason is: " + reason); -310 } -311 } -312 -313 private static void showCommentStatus(Wordpress wp) { -314 printItem(wp.getCommentStatusList(), CommentStatusList.class); -315 } -316 -317 @SuppressWarnings({ "nls", "boxing" }) -318 private static void delete(Options options, WpCliConfiguration config, -319 Wordpress wp, String opt, boolean deletePage) throws XmlRpcFault { -320 Integer post_ID = getInteger(opt, config); -321 String publish = config.getOptionValue("publish"); -322 if ((publish != null) && (post_ID != null)) { -323 if (deletePage) { -324 System.out.println(wp.deletePage(post_ID, publish)); -325 } else { -326 System.out.println(wp.deletePost(post_ID, publish)); -327 } -328 } else { -329 showHelp(options); -330 } -331 } -332 -333 @SuppressWarnings({ "nls", "boxing" }) -334 private static void edit(Options options, WpCliConfiguration config, -335 Wordpress wp, String opt, boolean isPage) throws IOException, -336 InvalidPostFormatException, XmlRpcFault { -337 Integer post_ID = getInteger("postid", config); -338 String publish = config.getOptionValue("publish"); -339 Page page = Page.fromFile(new File(config.getOptionValue(opt))); -340 if ((publish != null) && (post_ID != null)) { -341 Boolean result = false; -342 if (isPage) { -343 result = wp.editPage(post_ID, page, publish); -344 } else { -345 result = wp.editPost(post_ID, page, publish); -346 } -347 System.out.println(result); -348 } else { -349 showHelp(options); -350 } -351 } -352 -353 private static Integer getInteger(String c, WpCliConfiguration config) { -354 Integer post_ID = null; -355 try { -356 post_ID = Integer.valueOf(config.getOptionValue(c)); -357 } catch (NumberFormatException e) { -358 // leave it null -359 } -360 return post_ID; -361 } -362 -363 @SuppressWarnings("nls") -364 private static void showHelp(Options options) { -365 HelpFormatter help = new HelpFormatter(); -366 help.printHelp(" ", options); -367 } -368 -369 private static void printItem(Object o, Class<?> cl) { -370 cl.cast(o); -371 System.out.println(((StringHeader) o).getStringHeader()); -372 System.out.println(o); -373 } -374 -375 private static void printList(List<?> r, Class<?> cl, boolean oneLiner) { -376 boolean headerPrinted = false; -377 for (Object o : r) { -378 cl.cast(o); -379 if (!headerPrinted) { -380 if ((!(o instanceof String)) && (oneLiner)) { -381 System.out.println(((StringHeader) o).getStringHeader()); -382 } -383 headerPrinted = true; -384 } -385 if (oneLiner) { -386 System.out.println(((XmlRpcMapped) o).toOneLinerString()); -387 } else { -388 System.out.println(o); -389 } -390 } -391 } -392} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Media Object, as the result of an upload; -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class MediaObject extends XmlRpcMapped { -020 String url; -021 -022 String file; -023 -024 String type; -025 -026 String id; -027 -028 /** -029 * @return the ID of the Media Object -030 */ -031 public String getId(){ -032 return id; -033 } -034 -035 /** -036 * @param set the ID of the Media Object -037 */ -038 public void setId(String id){ -039 this.id = id; -040 } -041 -042 /** -043 * @return the url -044 */ -045 public String getUrl() { -046 return this.url; -047 } -048 -049 /** -050 * @param url the url to set -051 */ -052 public void setUrl(String url) { -053 this.url = url; -054 } -055 -056 /** -057 * @return the file -058 */ -059 public String getFile() { -060 return this.file; -061 } -062 -063 /** -064 * @param file the file to set -065 */ -066 public void setFile(String file) { -067 this.file = file; -068 } -069 -070 /** -071 * @return the type -072 */ -073 public String getType() { -074 return this.type; -075 } -076 -077 /** -078 * @param type the type to set -079 */ -080 public void setType(String type) { -081 this.type = type; -082 } -083} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.io.BufferedReader; -013import java.io.File; -014import java.io.FileReader; -015import java.io.IOException; -016import java.util.Date; -017 -018import redstone.xmlrpc.XmlRpcArray; -019import redstone.xmlrpc.XmlRpcStruct; -020 -021/** -022 * -023 * Page object for a blog. -024 * -025 * @author Can Bican <can@bican.net> -026 * -027 */ -028public class Page extends XmlRpcMapped implements StringHeader { -029 /** -030 * -031 * Generates a new page class from the given file -032 * -033 * @param file file that contains the page information -034 * @return new Page object -035 * @throws IOException when the file cannot be read -036 * @throws InvalidPostFormatException when the file format is not recognized -037 */ -038 public static Page fromFile(File file) throws IOException, -039 InvalidPostFormatException { -040 BufferedReader input = new BufferedReader(new FileReader(file)); -041 XmlRpcStruct page = FileParser.parseFile(input); -042 Page result = new Page(); -043 result.fromXmlRpcStruct(page); -044 return result; -045 } -046 -047 XmlRpcArray categories; -048 -049 XmlRpcArray custom_fields; -050 -051 Date date_created_gmt; -052 -053 Date dateCreated; -054 -055 String description; -056 -057 String link; -058 -059 Integer mt_allow_comments; -060 -061 Integer mt_allow_pings; -062 -063 String mt_excerpt; -064 -065 String mt_keywords; -066 -067 String mt_text_more; -068 -069 Integer page_id; -070 -071 String page_status; -072 -073 String permaLink; -074 -075 String post_status; -076 -077 String post_type; -078 -079 Integer postid; -080 -081 String title; -082 -083 String userid; -084 -085 String wp_author; -086 -087 String wp_author_display_name; -088 -089 String wp_author_id; -090 -091 Integer wp_page_order; -092 -093 Integer wp_page_parent_id; -094 -095 String wp_page_parent_title; -096 -097 String wp_password; -098 -099 String wp_post_thumbnail; -100 -101 String wp_slug; -102 -103 /** -104 * @return the categories -105 */ -106 public XmlRpcArray getCategories() { -107 return this.categories; -108 } -109 -110 /** -111 * @return the custom_fields -112 */ -113 public XmlRpcArray getCustom_fields() { -114 return this.custom_fields; -115 } -116 -117 /** -118 * @return the date_created_gmt -119 */ -120 public Date getDate_created_gmt() { -121 return this.date_created_gmt; -122 } -123 -124 /** -125 * @return the dateCreated -126 */ -127 public Date getDateCreated() { -128 return this.dateCreated; -129 } -130 -131 /** -132 * @return the description -133 */ -134 public String getDescription() { -135 return this.description; -136 } -137 -138 /** -139 * @return the excerpt -140 */ -141 public String getExcerpt() { -142 return this.mt_excerpt; -143 } -144 -145 /** -146 * @return the link -147 */ -148 public String getLink() { -149 return this.link; -150 } -151 -152 /** -153 * @return the mt_allow_comments -154 */ -155 public Integer getMt_allow_comments() { -156 return this.mt_allow_comments; -157 } -158 -159 /** -160 * @return the mt_allow_pings -161 */ -162 public Integer getMt_allow_pings() { -163 return this.mt_allow_pings; -164 } -165 -166 /** -167 * @return the mt_keywords -168 */ -169 public String getMt_keywords() { -170 return this.mt_keywords; -171 } -172 -173 /** -174 * @return text_more -175 */ -176 public String getMt_text_more() { -177 return this.mt_text_more; -178 } -179 -180 /** -181 * @return the page_id -182 */ -183 public Integer getPage_id() { -184 return this.page_id; -185 } -186 -187 /** -188 * @return the page_status -189 */ -190 public String getPage_status() { -191 return this.page_status; -192 } -193 -194 /** -195 * @return the permaLink -196 */ -197 public String getPermaLink() { -198 return this.permaLink; -199 } -200 -201 /** -202 * @return the post_status -203 */ -204 public String getPost_status() { -205 return this.post_status; -206 } -207 -208 /** -209 * @return the post_type -210 */ -211 public String getPost_type() { -212 return this.post_type; -213 } -214 -215 /** -216 * @return the postid -217 */ -218 public Integer getPostid() { -219 return this.postid; -220 } -221 -222 /** -223 * (non-Javadoc) -224 * -225 * @see net.bican.wordpress.StringHeader#getStringHeader() -226 */ -227 @Override -228 @SuppressWarnings("nls") -229 public String getStringHeader() { -230 return ""; // this is not a tabulated list -231 } -232 -233 /** -234 * @return the title -235 */ -236 public String getTitle() { -237 return this.title; -238 } -239 -240 /** -241 * @return the userid -242 */ -243 public String getUserid() { -244 return this.userid; -245 } -246 -247 /** -248 * @return the wp_author -249 */ -250 public String getWp_author() { -251 return this.wp_author; -252 } -253 -254 /** -255 * @return the wp_author_display_name -256 */ -257 public String getWp_author_display_name() { -258 return this.wp_author_display_name; -259 } -260 -261 /** -262 * @return the wp_author_id -263 */ -264 public String getWp_author_id() { -265 return this.wp_author_id; -266 } -267 -268 /** -269 * @return the wp_page_order -270 */ -271 public Integer getWp_page_order() { -272 return this.wp_page_order; -273 } -274 -275 /** -276 * @return the wp_page_parent_id -277 */ -278 public Integer getWp_page_parent_id() { -279 return this.wp_page_parent_id; -280 } -281 -282 /** -283 * @return the wp_page_parent_title -284 */ -285 public String getWp_page_parent_title() { -286 return this.wp_page_parent_title; -287 } -288 -289 /** -290 * @return the wp_password -291 */ -292 public String getWp_password() { -293 return this.wp_password; -294 } -295 -296 /** -297 * @return the wp_slug -298 */ -299 public String getWp_slug() { -300 return this.wp_slug; -301 } -302 -303 /** -304 * @param categories the categories to set -305 */ -306 public void setCategories(XmlRpcArray categories) { -307 this.categories = categories; -308 } -309 -310 /** -311 * @param custom_fields the custom_fields to set -312 */ -313 public void setCustom_fields(XmlRpcArray custom_fields) { -314 this.custom_fields = custom_fields; -315 } -316 -317 /** -318 * @param date_created_gmt the date_created_gmt to set -319 */ -320 public void setDate_created_gmt(Date date_created_gmt) { -321 this.date_created_gmt = date_created_gmt; -322 // one of dateCreated() and date_created_gmt() has to be null -323 // or the behavior when two of them are different is undefined -324 if (this.date_created_gmt != null) -325 this.dateCreated = null; -326 } -327 -328 /** -329 * @param dateCreated the dateCreated to set -330 */ -331 public void setDateCreated(Date dateCreated) { -332 this.dateCreated = dateCreated; -333 // one of dateCreated() and date_created_gmt() has to be null -334 // or the behavior when two of them are different is undefined -335 if (this.dateCreated != null) -336 this.date_created_gmt = null; -337 } -338 -339 /** -340 * @param description the description to set -341 */ -342 public void setDescription(String description) { -343 this.description = description; -344 } -345 -346 /** -347 * @param excerpt the excerpt to set -348 */ -349 public void setExcerpt(String excerpt) { -350 this.mt_excerpt = excerpt; -351 } -352 -353 /** -354 * @param link the link to set -355 */ -356 public void setLink(String link) { -357 this.link = link; -358 } -359 -360 /** -361 * @param mt_allow_comments the mt_allow_comments to set -362 */ -363 public void setMt_allow_comments(Integer mt_allow_comments) { -364 this.mt_allow_comments = mt_allow_comments; -365 } -366 -367 /** -368 * @param mt_allow_pings the mt_allow_pings to set -369 */ -370 public void setMt_allow_pings(Integer mt_allow_pings) { -371 this.mt_allow_pings = mt_allow_pings; -372 } -373 -374 /** -375 * @param mt_keywords the mt_keywords to set -376 */ -377 public void setMt_keywords(String mt_keywords) { -378 this.mt_keywords = mt_keywords; -379 } -380 -381 /** -382 * @param mt_text_more to set -383 */ -384 public void setMt_text_more(String mt_text_more) { -385 this.mt_text_more = mt_text_more; -386 } -387 -388 /** -389 * @param page_id the page_id to set -390 */ -391 public void setPage_id(Integer page_id) { -392 this.page_id = page_id; -393 } -394 -395 /** -396 * @param page_status the page_status to set -397 */ -398 public void setPage_status(String page_status) { -399 this.page_status = page_status; -400 } -401 -402 /** -403 * @param permaLink the permaLink to set -404 */ -405 public void setPermaLink(String permaLink) { -406 this.permaLink = permaLink; -407 } -408 -409 /** -410 * @param postStatus the post_status to set -411 */ -412 public void setPost_status(String postStatus) { -413 this.post_status = postStatus; -414 } -415 -416 /** -417 * @param post_type the post_type to set -418 */ -419 public void setPost_type(String post_type) { -420 this.post_type = post_type; -421 } -422 -423 /** -424 * @param postid the postid to set -425 */ -426 public void setPostid(Integer postid) { -427 this.postid = postid; -428 } -429 -430 /** -431 * @param title the title to set -432 */ -433 public void setTitle(String title) { -434 this.title = title; -435 } -436 -437 /** -438 * @param userid the userid to set -439 */ -440 public void setUserid(String userid) { -441 this.userid = userid; -442 } -443 -444 /** -445 * @param wp_author the wp_author to set -446 */ -447 public void setWp_author(String wp_author) { -448 this.wp_author = wp_author; -449 } -450 -451 /** -452 * @param wp_author_display_name the wp_author_display_name to set -453 */ -454 public void setWp_author_display_name(String wp_author_display_name) { -455 this.wp_author_display_name = wp_author_display_name; -456 } -457 -458 /** -459 * @param wp_author_id the wp_author_id to set -460 */ -461 public void setWp_author_id(String wp_author_id) { -462 this.wp_author_id = wp_author_id; -463 } -464 -465 /** -466 * @param wp_page_order the wp_page_order to set -467 */ -468 public void setWp_page_order(Integer wp_page_order) { -469 this.wp_page_order = wp_page_order; -470 } -471 -472 /** -473 * @param wp_page_parent_id the wp_page_parent_id to set -474 */ -475 public void setWp_page_parent_id(Integer wp_page_parent_id) { -476 this.wp_page_parent_id = wp_page_parent_id; -477 } -478 -479 /** -480 * @param wp_page_parent_title the wp_page_parent_title to set -481 */ -482 public void setWp_page_parent_title(String wp_page_parent_title) { -483 this.wp_page_parent_title = wp_page_parent_title; -484 } -485 -486 /** -487 * @param wp_password the wp_password to set -488 */ -489 public void setWp_password(String wp_password) { -490 this.wp_password = wp_password; -491 } -492 -493 /** -494 * @return thumbnail ID. This is the ID of the MediaObject in Wordpress -495 */ -496 public String getWp_post_thumbnail() { -497 return wp_post_thumbnail; -498 } -499 -500 /** -501 * @param wp_post_thumbnail set the post thumbnail (feature image). This is the ID of the Media -502 * object already created with MediaObject class -503 */ -504 public void setWp_post_thumbnail(String wp_post_thumbnail) { -505 this.wp_post_thumbnail = wp_post_thumbnail; -506 } -507 -508 /** -509 * @param wp_slug the wp_slug to set -510 */ -511 public void setWp_slug(String wp_slug) { -512 this.wp_slug = wp_slug; -513 } -514} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.util.Date; -013 -014/** -015 * -016 * A trimmed version of <code>Page</code> object, that is returned in lists -017 * -018 * @author Can Bican <can@bican.net> -019 * -020 */ -021public class PageDefinition extends XmlRpcMapped implements StringHeader { -022 String page_title; -023 -024 String page_parent_id; -025 -026 Date dateCreated; -027 -028 Date date_created_gmt; -029 -030 /** -031 * @return the page_title -032 */ -033 public String getPage_title() { -034 return this.page_title; -035 } -036 -037 /** -038 * @param page_title the page_title to set -039 */ -040 public void setPage_title(String page_title) { -041 this.page_title = page_title; -042 } -043 -044 /** -045 * @return the page_parent_id -046 */ -047 public String getPage_parent_id() { -048 return this.page_parent_id; -049 } -050 -051 /** -052 * @param page_parent_id the page_parent_id to set -053 */ -054 public void setPage_parent_id(String page_parent_id) { -055 this.page_parent_id = page_parent_id; -056 } -057 -058 /** -059 * @return the dateCreated -060 */ -061 public Date getDateCreated() { -062 return this.dateCreated; -063 } -064 -065 /** -066 * @param dateCreated the dateCreated to set -067 */ -068 public void setDateCreated(Date dateCreated) { -069 this.dateCreated = dateCreated; -070 } -071 -072 /** -073 * @return the date_created_gmt -074 */ -075 public Date getDate_created_gmt() { -076 return this.date_created_gmt; -077 } -078 -079 /** -080 * @param date_created_gmt the date_created_gmt to set -081 */ -082 public void setDate_created_gmt(Date date_created_gmt) { -083 this.date_created_gmt = date_created_gmt; -084 } -085 -086 /** -087 * (non-Javadoc) -088 * -089 * @see net.bican.wordpress.StringHeader#getStringHeader() -090 */ -091 @Override -092 @SuppressWarnings("nls") -093 public String getStringHeader() { -094 final String TAB = ":"; -095 return "Date Created" + TAB + "Date Created(GMT)" + TAB + "Parent ID" + TAB -096 + "Page Title"; -097 } -098 -099} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Class that hold trackback information -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class Ping extends XmlRpcMapped { -020 String pingTitle; -021 -022 String pingURL; -023 -024 String pingIP; -025 -026 /** -027 * @return the pingTitle -028 */ -029 public String getPingTitle() { -030 return this.pingTitle; -031 } -032 -033 /** -034 * @param pingTitle the pingTitle to set -035 */ -036 public void setPingTitle(String pingTitle) { -037 this.pingTitle = pingTitle; -038 } -039 -040 /** -041 * @return the pingURL -042 */ -043 public String getPingURL() { -044 return this.pingURL; -045 } -046 -047 /** -048 * @param pingURL the pingURL to set -049 */ -050 public void setPingURL(String pingURL) { -051 this.pingURL = pingURL; -052 } -053 -054 /** -055 * @return the pingIP -056 */ -057 public String getPingIP() { -058 return this.pingIP; -059 } -060 -061 /** -062 * @param pingIP the pingIP to set -063 */ -064 public void setPingIP(String pingIP) { -065 this.pingIP = pingIP; -066 } -067} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Status values for posts and pages -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class PostAndPageStatus extends XmlRpcMapped implements StringHeader { -020 String status; -021 -022 String description; -023 -024 /** -025 * @return the status -026 */ -027 public String getStatus() { -028 return this.status; -029 } -030 -031 /** -032 * @param status the status to set -033 */ -034 public void setStatus(String status) { -035 this.status = status; -036 } -037 -038 /** -039 * @return the description -040 */ -041 public String getDescription() { -042 return this.description; -043 } -044 -045 /** -046 * @param description the description to set -047 */ -048 public void setDescription(String description) { -049 this.description = description; -050 } -051 -052 /** -053 * -054 * (non-Javadoc) -055 * -056 * @see net.bican.wordpress.StringHeader#getStringHeader() -057 */ -058 @Override -059 @SuppressWarnings("nls") -060 public String getStringHeader() { -061 return ""; -062 } -063} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Interface for supplying a header for tabular output in toString() -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public interface StringHeader { -020 /** -021 * @return Header list -022 */ -023 public String getStringHeader(); -024} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012/** -013 * -014 * Class that keeps user information from blogger style calls -015 * -016 * @author Can Bican <can@bican.net> -017 * -018 */ -019public class User extends XmlRpcMapped implements StringHeader { -020 String nickname; -021 -022 Integer userid; -023 -024 String url; -025 -026 String lastname; -027 -028 String firstname; -029 -030 /** -031 * (non-Javadoc) -032 * -033 * @see net.bican.wordpress.StringHeader#getStringHeader() -034 */ -035 @Override -036 @SuppressWarnings("nls") -037 public String getStringHeader() { -038 final String TAB = ":"; -039 return "First name" + TAB + "Last name" + TAB + "Nick name" + TAB + "Url" -040 + TAB + "User ID"; -041 } -042 -043 /** -044 * @return the nickname -045 */ -046 public String getNickname() { -047 return this.nickname; -048 } -049 -050 /** -051 * @param nickname the nickname to set -052 */ -053 public void setNickname(String nickname) { -054 this.nickname = nickname; -055 } -056 -057 /** -058 * @return the userid -059 */ -060 public Integer getUserid() { -061 return this.userid; -062 } -063 -064 /** -065 * @param userid the userid to set -066 */ -067 public void setUserid(Integer userid) { -068 this.userid = userid; -069 } -070 -071 /** -072 * @return the url -073 */ -074 public String getUrl() { -075 return this.url; -076 } -077 -078 /** -079 * @param url the url to set -080 */ -081 public void setUrl(String url) { -082 this.url = url; -083 } -084 -085 /** -086 * @return the lastname -087 */ -088 public String getLastname() { -089 return this.lastname; -090 } -091 -092 /** -093 * @param lastname the lastname to set -094 */ -095 public void setLastname(String lastname) { -096 this.lastname = lastname; -097 } -098 -099 /** -100 * @return the firstname -101 */ -102 public String getFirstname() { -103 return this.firstname; -104 } -105 -106 /** -107 * @param firstname the firstname to set -108 */ -109 public void setFirstname(String firstname) { -110 this.firstname = firstname; -111 } -112 -113} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.io.File; -013import java.io.FileInputStream; -014import java.io.FileNotFoundException; -015import java.io.IOException; -016import java.io.InputStream; -017import java.net.MalformedURLException; -018import java.net.URL; -019import java.util.ArrayList; -020import java.util.List; -021 -022import redstone.xmlrpc.XmlRpcArray; -023import redstone.xmlrpc.XmlRpcFault; -024import redstone.xmlrpc.XmlRpcProxy; -025import redstone.xmlrpc.XmlRpcStruct; -026 -027interface BloggerBridge { -028 /** -029 * @param blogid -030 * Blog id, not used in wordpress -031 * @param username -032 * User name -033 * @param password -034 * Password -035 * @param post_ID -036 * Page ID to delete -037 * @param publish -038 * Publish status -039 * @return result of deletion -040 * @throws XmlRpcFault -041 */ -042 Boolean deletePost(Integer blogid, Integer post_ID, String username, -043 String password, String publish) throws XmlRpcFault; -044 -045 /** -046 * @param placeHolder -047 * No reference about what it is in xmlrpc.php, but it's not used -048 * @param blogid -049 * Blog id, not used in wordpress -050 * @param username -051 * User name -052 * @param password -053 * Password -054 * @param template -055 * Template, not used in wordpress -056 * @return Template page -057 * @throws XmlRpcFault -058 */ -059 String getTemplate(Integer placeHolder, Integer blogid, String username, -060 String password, String template) throws XmlRpcFault; -061 -062 /** -063 * @param placeHolder -064 * No reference about what it is in xmlrpc.php, but it's not used -065 * @param username -066 * User name -067 * @param password -068 * Password -069 * @return User information -070 * @throws XmlRpcFault -071 */ -072 XmlRpcStruct getUserInfo(Integer placeHolder, String username, String password) -073 throws XmlRpcFault; -074 -075 /** -076 * @param placeHolder -077 * No reference about what it is in xmlrpc.php, but it's not used -078 * @param username -079 * User name -080 * @param password -081 * Password -082 * @return Blog that user has -083 * @throws XmlRpcFault -084 */ -085 XmlRpcArray getUsersBlogs(Integer placeHolder, String username, -086 String password) throws XmlRpcFault; -087 -088 /** -089 * @param placeHolder -090 * No reference about what it is in xmlrpc.php, but it's not used -091 * @param blogid -092 * Blog id, not used in wordpress -093 * @param username -094 * User name -095 * @param password -096 * Password -097 * @param content -098 * Content of the template -099 * @param template -100 * Template, not used in wordpress -101 * @return Result of the operation -102 * @throws XmlRpcFault -103 */ -104 Boolean setTemplate(Integer placeHolder, Integer blogid, String username, -105 String password, String content, String template) throws XmlRpcFault; -106} -107 -108interface DemoBridge { -109 /** -110 * @param number1 -111 * first number -112 * @param number2 -113 * second number -114 * @return addition of the arguments -115 * @throws XmlRpcFault -116 */ -117 Double addTwoNumbers(Double number1, Double number2) throws XmlRpcFault; -118 -119 /** -120 * @return A very important message -121 * @throws XmlRpcFault -122 */ -123 String sayHello() throws XmlRpcFault; -124} -125 -126interface MetaWebLogBridge { -127 /** -128 * @param post_ID -129 * ID of the post to edit -130 * @param username -131 * User name -132 * @param password -133 * Password -134 * @param post -135 * Page information -136 * @param publish -137 * Post status -138 * @return result of edit -139 * @throws XmlRpcFault -140 */ -141 Boolean editPost(Integer post_ID, String username, String password, -142 XmlRpcStruct post, String publish) throws XmlRpcFault; -143 -144 /** -145 * @param post_ID -146 * ID of the post to retrieve -147 * @param username -148 * User name -149 * @param password -150 * Password -151 * @return Page information -152 * @throws XmlRpcFault -153 */ -154 XmlRpcStruct getPost(Integer post_ID, String username, String password) -155 throws XmlRpcFault; -156 -157 /** -158 * @param blogid -159 * Blog id (not used in wordpress) -160 * @param username -161 * User name -162 * @param password -163 * Password -164 * @param num_posts -165 * Number of posts to retrieve -166 * @return List of pages -167 * @throws XmlRpcFault -168 */ -169 XmlRpcArray getRecentPosts(Integer blogid, String username, String password, -170 Integer num_posts) throws XmlRpcFault; -171 -172 /** -173 * @param blogid -174 * Blog id (not used in wordpress) -175 * @param username -176 * User name -177 * @param password -178 * Password -179 * @param data -180 * Data Structure (type,bits,overwrite) -181 * @return result of the upload -182 * @throws XmlRpcFault -183 */ -184 XmlRpcStruct newMediaObject(Integer blogid, String username, String password, -185 XmlRpcStruct data) throws XmlRpcFault; -186 -187 /** -188 * @param blogid -189 * Blog id (not used in wordpress) -190 * @param username -191 * User name -192 * @param password -193 * Password -194 * @param post -195 * Post structure -196 * @param publish -197 * Publish status -198 * @return post id -199 * @throws XmlRpcFault -200 */ -201 String newPost(Integer blogid, String username, String password, -202 XmlRpcStruct post, Boolean publish) throws XmlRpcFault; -203} -204 -205interface MovableTypeBridge { -206 /** -207 * @return List of methods the server supports -208 * @throws XmlRpcFault -209 */ -210 XmlRpcArray supportedMethods() throws XmlRpcFault; -211 -212 /** -213 * @return List of supported text filters -214 * @throws XmlRpcFault -215 */ -216 XmlRpcArray supportedTextFilters() throws XmlRpcFault; -217 -218 /** -219 * @param PostId -220 * Post id -221 * @return List of trackbacks for the post -222 * @throws XmlRpcFault -223 */ -224 XmlRpcArray getTrackbackPings(Integer PostId) throws XmlRpcFault; -225} -226 -227interface PingbackBridge { -228 /** -229 * @param pagelinkedfrom -230 * Source -231 * @param pagelinkedto -232 * Destination -233 * @return response string -234 * @throws XmlRpcFault -235 */ -236 String ping(String pagelinkedfrom, String pagelinkedto) throws XmlRpcFault; -237} -238 -239interface PingbackExtensionsBridge { -240 /** -241 * @param url -242 * url of the page queried -243 * @return Array of URLs -244 * @throws XmlRpcFault -245 */ -246 XmlRpcArray getPingbacks(String url) throws XmlRpcFault; -247} -248 -249/** -250 * -251 * The utility class that links xmlrpc calls to Java functions. -252 * -253 * @author Can Bican <can@bican.net> -254 * -255 */ -256public class Wordpress { -257 -258 private static byte[] getBytesFromFile(File file) { -259 byte[] result = null; -260 InputStream is = null; -261 try { -262 is = new FileInputStream(file); -263 -264 // Get the size of the file -265 long length = file.length(); -266 -267 // You cannot create an array using a long type. -268 // It needs to be an int type. -269 // Before converting to an int type, check -270 // to ensure that file is not larger than Integer.MAX_VALUE. -271 if (length > Integer.MAX_VALUE) { -272 // File is too large -273 } -274 -275 // Create the byte array to hold the data -276 byte[] bytes = new byte[(int) length]; -277 -278 // Read in the bytes -279 int offset = 0; -280 int numRead = 0; -281 while (offset < bytes.length -282 && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { -283 offset += numRead; -284 } -285 -286 // Ensure all the bytes have been read in -287 if (offset < bytes.length) { -288 throw new IOException( -289 "Could not completely read file " + file.getName()); //$NON-NLS-1$ -290 } -291 result = bytes; -292 } catch (FileNotFoundException e) { -293 e.printStackTrace(); -294 } catch (IOException e) { -295 e.printStackTrace(); -296 } finally { -297 if (is != null) -298 try { -299 is.close(); -300 } catch (IOException e) { -301 e.printStackTrace(); -302 } -303 } -304 return result; -305 } -306 -307 private BloggerBridge blogger; -308 -309 private DemoBridge demo = null; -310 -311 private MovableTypeBridge mt = null; -312 -313 private MetaWebLogBridge mw = null; -314 -315 private String password = null; -316 -317 private PingbackBridge pingback = null; -318 -319 private PingbackExtensionsBridge pingbackExt = null; -320 -321 private String username = null; -322 -323 private WordpressBridge wp = null; -324 -325 private String xmlRpcUrl = null; -326 -327 @SuppressWarnings("unused") -328 private Wordpress() { -329 // no default constructor - class needs username, password and url -330 } -331 -332 /** -333 * @param username -334 * User name -335 * @param password -336 * Password -337 * @param xmlRpcUrl -338 * xmlrpc communication point, usually blogurl/xmlrpc.php -339 * @throws MalformedURLException -340 * If the URL is faulty -341 */ -342 public Wordpress(String username, String password, String xmlRpcUrl) -343 throws MalformedURLException { -344 this.username = username; -345 this.password = password; -346 this.xmlRpcUrl = xmlRpcUrl; -347 initMetaWebLog(); -348 } -349 -350 /** -351 * @param number1 -352 * First number -353 * @param number2 -354 * Second number -355 * @return addition of two numbers -356 * @throws XmlRpcFault -357 * Generic exception for xml-rpc operations -358 */ -359 @SuppressWarnings("boxing") -360 public double addTwoNumbers(double number1, double number2) -361 throws XmlRpcFault { -362 return this.demo.addTwoNumbers(number1, number2); -363 } -364 -365 /** -366 * @param post_ID -367 * ID of the page to delete -368 * @param publish -369 * Publish status -370 * @return Result of deletion -371 * @throws XmlRpcFault -372 * Generic exception for xml-rpc operations -373 */ -374 @SuppressWarnings("boxing") -375 public Boolean deletePage(int post_ID, String publish) throws XmlRpcFault { -376 return this.wp.deletePage(0, this.username, this.password, -377 Integer.valueOf(post_ID), publish); -378 } -379 -380 /** -381 * @param post_ID -382 * ID of the post to delete -383 * @param publish -384 * Publish status -385 * @return result of deletion -386 * @throws XmlRpcFault -387 * Generic exception for xml-rpc operations -388 */ -389 @SuppressWarnings("boxing") -390 public Boolean deletePost(int post_ID, String publish) throws XmlRpcFault { -391 return this.blogger.deletePost(0, post_ID, this.username, this.password, -392 publish); -393 } -394 -395 /** -396 * @param post_ID -397 * ID of the post to edit -398 * @param page -399 * Page information -400 * @param publish -401 * Publish status -402 * @return Result of edit -403 * @throws XmlRpcFault -404 * Generic exception for xml-rpc operations -405 */ -406 @SuppressWarnings("boxing") -407 public Boolean editPage(int post_ID, Page page, String publish) -408 throws XmlRpcFault { -409 XmlRpcStruct post = page.toXmlRpcStruct(); -410 return this.wp.editPage(0, post_ID, this.username, this.password, post, -411 publish); -412 } -413 -414 /** -415 * @param post_ID -416 * ID of the post to edit -417 * @param page -418 * Page information -419 * @param publish -420 * Publish status -421 * @return result of edit -422 * @throws XmlRpcFault -423 * Generic exception for xml-rpc operations -424 */ -425 @SuppressWarnings("boxing") -426 public Boolean editPost(int post_ID, Page page, String publish) -427 throws XmlRpcFault { -428 XmlRpcStruct post = page.toXmlRpcStruct(); -429 return this.mw.editPost(post_ID, this.username, this.password, post, -430 publish); -431 } -432 -433 @SuppressWarnings({ "rawtypes", "unchecked", "static-method" }) -434 private List fillFromXmlRpcArray(XmlRpcArray r, Class cl) { -435 List result = null; -436 try { -437 result = new ArrayList(); -438 for (Object o : r) { -439 XmlRpcMapped n = (XmlRpcMapped) cl.newInstance(); -440 if (o instanceof String) { -441 result.add(o); -442 } else { -443 n.fromXmlRpcStruct((XmlRpcStruct) o); -444 } -445 result.add(n); -446 } -447 } catch (InstantiationException e) { -448 e.printStackTrace(); -449 } catch (IllegalAccessException e) { -450 e.printStackTrace(); -451 } -452 return result; -453 } -454 -455 @SuppressWarnings("static-method") -456 private List<String> fromStringArray(XmlRpcArray r) { -457 List<String> result; -458 result = new ArrayList<String>(); -459 for (Object object : r) { -460 result.add((String) object); -461 } -462 return result; -463 } -464 -465 /** -466 * @return List of authors -467 * @throws XmlRpcFault -468 * Generic exception for xml-rpc operations -469 */ -470 @SuppressWarnings("unchecked") -471 public List<Author> getAuthors() throws XmlRpcFault { -472 XmlRpcArray r = this.wp.getAuthors(0, this.username, this.password); -473 return fillFromXmlRpcArray(r, Author.class); -474 } -475 -476 /** -477 * @return List of categories -478 * @throws XmlRpcFault -479 * Generic exception for xml-rpc operations -480 */ -481 @SuppressWarnings("unchecked") -482 public List<Category> getCategories() throws XmlRpcFault { -483 XmlRpcArray r = this.wp.getCategories(0, this.username, this.password); -484 return fillFromXmlRpcArray(r, Category.class); -485 } -486 -487 /** -488 * @param pageid -489 * Page ID -490 * @return The <code>Page</code> object. -491 * @throws XmlRpcFault -492 * Generic exception for xml-rpc operations -493 */ -494 @SuppressWarnings("boxing") -495 public Page getPage(int pageid) throws XmlRpcFault { -496 XmlRpcStruct r = this.wp.getPage(0, pageid, this.username, this.password); -497 Page result = new Page(); -498 result.fromXmlRpcStruct(r); -499 return result; -500 } -501 -502 /** -503 * @return List of Pages, short format -504 * @throws XmlRpcFault -505 * Generic exception for xml-rpc operations -506 */ -507 @SuppressWarnings({ "unchecked", "boxing" }) -508 public List<PageDefinition> getPageList() throws XmlRpcFault { -509 XmlRpcArray r = this.wp.getPageList(0, this.username, this.password); -510 return fillFromXmlRpcArray(r, PageDefinition.class); -511 } -512 -513 /** -514 * @return List of Pages, in full format -515 * @throws XmlRpcFault -516 * Generic exception for xml-rpc operations -517 */ -518 @SuppressWarnings({ "unchecked", "boxing" }) -519 public List<Page> getPages() throws XmlRpcFault { -520 XmlRpcArray r = this.wp.getPages(0, this.username, this.password); -521 return fillFromXmlRpcArray(r, Page.class); -522 } -523 -524 /** -525 * @param postId -526 * Post ID -527 * @return Trackbacks for the post -528 * @throws XmlRpcFault -529 * Generic exception for xml-rpc operations -530 */ -531 @SuppressWarnings({ "unchecked", "boxing" }) -532 public List<Ping> getTrackbackPings(int postId) throws XmlRpcFault { -533 XmlRpcArray r = this.mt.getTrackbackPings(postId); -534 return fillFromXmlRpcArray(r, Ping.class); -535 } -536 -537 /** -538 * @param url -539 * Url of the page queried -540 * @return List of URLs -541 * @throws XmlRpcFault -542 * Generic exception for xml-rpc operations -543 */ -544 public List<URL> getPingbacks(String url) throws XmlRpcFault { -545 List<URL> result = null; -546 try { -547 XmlRpcArray r = this.pingbackExt.getPingbacks(url); -548 result = new ArrayList<URL>(); -549 for (Object rec : r) { -550 result.add(new URL((String) rec)); -551 } -552 } catch (MalformedURLException e) { -553 e.printStackTrace(); -554 } -555 return result; -556 } -557 -558 /** -559 * @param post_ID -560 * ID of the post to retrieve -561 * @return Page information -562 * @throws XmlRpcFault -563 * Generic exception for xml-rpc operations -564 */ -565 @SuppressWarnings("boxing") -566 public Page getPost(int post_ID) throws XmlRpcFault { -567 XmlRpcStruct r = this.mw.getPost(post_ID, this.username, this.password); -568 Page result = new Page(); -569 result.fromXmlRpcStruct(r); -570 return result; -571 } -572 -573 /** -574 * @param num_posts -575 * Number of posts to be retrieved. -576 * @return List of pages. -577 * @throws XmlRpcFault -578 * Generic exception for xml-rpc operations -579 */ -580 @SuppressWarnings({ "unchecked", "boxing" }) -581 public List<Page> getRecentPosts(int num_posts) throws XmlRpcFault { -582 XmlRpcArray r = this.mw.getRecentPosts(0, this.username, this.password, -583 num_posts); -584 return fillFromXmlRpcArray(r, Page.class); -585 } -586 -587 /** -588 * @return Template page -589 * @throws XmlRpcFault -590 * Generic exception for xml-rpc operations -591 */ -592 @SuppressWarnings({ "boxing", "nls" }) -593 public String getTemplate() throws XmlRpcFault { -594 return this.blogger.getTemplate(0, 0, this.username, this.password, ""); -595 } -596 -597 /** -598 * @return The user information -599 * @throws XmlRpcFault -600 * Generic exception for xml-rpc operations -601 */ -602 @SuppressWarnings("boxing") -603 public User getUserInfo() throws XmlRpcFault { -604 XmlRpcStruct r = this.blogger.getUserInfo(0, this.username, this.password); -605 User result = new User(); -606 result.fromXmlRpcStruct(r); -607 return result; -608 } -609 -610 /** -611 * @return List of blogs the user has (only one in wordpress case) -612 * @throws XmlRpcFault -613 * Generic exception for xml-rpc operations -614 */ -615 @SuppressWarnings({ "unchecked", "boxing" }) -616 public List<Blog> getUsersBlogs() throws XmlRpcFault { -617 XmlRpcArray r = this.blogger.getUsersBlogs(0, this.username, this.password); -618 return fillFromXmlRpcArray(r, Blog.class); -619 } -620 -621 @SuppressWarnings("nls") -622 private void initMetaWebLog() throws MalformedURLException { -623 final URL url = new URL(this.xmlRpcUrl); -624 this.wp = (WordpressBridge) XmlRpcProxy.createProxy(url, "wp", -625 new Class[] { WordpressBridge.class }, true); -626 this.mw = (MetaWebLogBridge) XmlRpcProxy.createProxy(url, "metaWeblog", -627 new Class[] { MetaWebLogBridge.class }, true); -628 this.mt = (MovableTypeBridge) XmlRpcProxy.createProxy(url, "mt", -629 new Class[] { MovableTypeBridge.class }, true); -630 this.demo = (DemoBridge) XmlRpcProxy.createProxy(url, "demo", -631 new Class[] { DemoBridge.class }, true); -632 this.pingback = (PingbackBridge) XmlRpcProxy.createProxy(url, "pingback", -633 new Class[] { PingbackBridge.class }, true); -634 this.blogger = (BloggerBridge) XmlRpcProxy.createProxy(url, "blogger", -635 new Class[] { BloggerBridge.class }, true); -636 this.pingbackExt = (PingbackExtensionsBridge) XmlRpcProxy.createProxy(url, -637 "pingback.extensions", new Class[] { PingbackExtensionsBridge.class }, -638 true); -639 } -640 -641 /** -642 * @param name -643 * Category name -644 * @param slug -645 * Category short name -646 * @param parentId -647 * Parent ID -648 * @return New category id -649 * @throws XmlRpcFault -650 * Generic exception for xml-rpc operations -651 */ -652 @SuppressWarnings({ "unchecked", "nls", "boxing" }) -653 public int newCategory(String name, String slug, int parentId) -654 throws XmlRpcFault { -655 XmlRpcStruct h = new XmlRpcStruct(); -656 h.put("name", name); -657 h.put("slug", slug); -658 h.put("parent_id", parentId); -659 return this.wp.newCategory(0, this.username, this.password, h); -660 } -661 -662 /** -663 * @param mimeType -664 * Mime type of the file -665 * @param file -666 * File name -667 * @param overwrite -668 * true/false -669 * @return new object location -670 * @throws XmlRpcFault -671 * Generic exception for xml-rpc operations -672 */ -673 @SuppressWarnings("boxing") -674 public MediaObject newMediaObject(String mimeType, File file, -675 Boolean overwrite) throws XmlRpcFault { -676 Attachment att = new Attachment(); -677 att.setType(mimeType); -678 att.setOverwrite(overwrite); -679 att.setName(file.getName()); -680 att.setBits(getBytesFromFile(file)); -681 XmlRpcStruct d = att.toXmlRpcStruct(); -682 XmlRpcStruct r = this.mw.newMediaObject(0, this.username, this.password, d); -683 MediaObject result = new MediaObject(); -684 result.fromXmlRpcStruct(r); -685 return result; -686 } -687 -688 /** -689 * @param post -690 * Page information -691 * @param publish -692 * Publish status -693 * @return Post ID -694 * @throws XmlRpcFault -695 * Generic exception for xml-rpc operations -696 */ -697 @SuppressWarnings("boxing") -698 public String newPage(Page post, String publish) throws XmlRpcFault { -699 return this.wp.newPage(0, this.username, this.password, -700 post.toXmlRpcStruct(), publish); -701 } -702 -703 /** -704 * @param page -705 * Post information -706 * @param publish -707 * Publish status -708 * @return Post id -709 * @throws XmlRpcFault -710 * Generic exception for xml-rpc operations -711 */ -712 @SuppressWarnings("boxing") -713 public String newPost(Page page, boolean publish) throws XmlRpcFault { -714 return this.mw.newPost(0, this.username, this.password, -715 page.toXmlRpcStruct(), publish); -716 } -717 -718 /** -719 * @param pagelinkedfrom -720 * Source -721 * @param pagelinkedto -722 * Destination -723 * @return response for ping -724 * @throws XmlRpcFault -725 * Generic exception for xml-rpc operations -726 */ -727 public String ping(String pagelinkedfrom, String pagelinkedto) -728 throws XmlRpcFault { -729 return this.pingback.ping(pagelinkedfrom, pagelinkedto); -730 } -731 -732 /** -733 * @return A very important message -734 * @throws XmlRpcFault -735 * Generic exception for xml-rpc operations -736 */ -737 public String sayHello() throws XmlRpcFault { -738 return this.demo.sayHello(); -739 } -740 -741 /** -742 * @param content -743 * Content of the template -744 * @return Result of the operation -745 * @throws XmlRpcFault -746 * Generic exception for xml-rpc operations -747 */ -748 @SuppressWarnings({ "boxing", "nls" }) -749 public boolean setTemplate(String content) throws XmlRpcFault { -750 return this.blogger.setTemplate(0, 0, this.username, this.password, -751 content, ""); -752 } -753 -754 /** -755 * @param category -756 * Category to search -757 * @param max_results -758 * Maximum results to return -759 * @return List of suggested categories -760 * @throws XmlRpcFault -761 * Generic exception for xml-rpc operations -762 */ -763 @SuppressWarnings("static-method") -764 public List<Category> suggestCategories(String category, Integer max_results) -765 throws XmlRpcFault { -766 throw new UnsupportedOperationException(); // couldn't quite figure out the -767 // response. -768 } -769 -770 /** -771 * @return List of supported methods -772 * @throws XmlRpcFault -773 * Generic exception for xml-rpc operations -774 */ -775 public List<String> supportedMethods() throws XmlRpcFault { -776 return fromStringArray(this.mt.supportedMethods()); -777 } -778 -779 /** -780 * @return List of supported text filters -781 * @throws XmlRpcFault -782 * Generic exception for xml-rpc operations -783 */ -784 public List<String> supportedTextFilters() throws XmlRpcFault { -785 return fromStringArray(this.mt.supportedTextFilters()); -786 } -787 -788 /** -789 * @return List of supported post status values -790 * @throws XmlRpcFault -791 * Generic exception for xml-rpc operations -792 */ -793 @SuppressWarnings("boxing") -794 public List<PostAndPageStatus> getPostStatusList() throws XmlRpcFault { -795 return processKeyValList(this.wp.getPostStatusList(0, this.username, -796 this.password)); -797 } -798 -799 /** -800 * @return List of supported page status values -801 * @throws XmlRpcFault -802 * Generic exception for xml-rpc operations -803 */ -804 @SuppressWarnings("boxing") -805 public List<PostAndPageStatus> getPageStatusList() throws XmlRpcFault { -806 return processKeyValList(this.wp.getPageStatusList(0, this.username, -807 this.password)); -808 } -809 -810 @SuppressWarnings({ "static-method", "nls" }) -811 private List<PostAndPageStatus> processKeyValList(XmlRpcStruct r) { -812 String response = r.toString(); -813 response = response.replaceAll("[{}]", "").replaceAll(", *", ","); -814 String[] responses = response.split(","); -815 List<PostAndPageStatus> result = new ArrayList<PostAndPageStatus>(); -816 for (String rp : responses) { -817 String[] keyval = rp.split("="); -818 PostAndPageStatus pp = new PostAndPageStatus(); -819 pp.setStatus(keyval[0]); -820 pp.setDescription(keyval[1]); -821 result.add(pp); -822 } -823 return result; -824 } -825 -826 /** -827 * @param post_ID -828 * Blog Post ID -829 * @return Number of comments (approved, spam, otherwise) -830 * @throws XmlRpcFault -831 * Generic exception for xml-rpc operations -832 */ -833 @SuppressWarnings("boxing") -834 public CommentCount getCommentsCount(Integer post_ID) throws XmlRpcFault { -835 XmlRpcStruct struct; -836 if (post_ID != -1) -837 struct = this.wp -838 .getCommentCount(0, this.username, this.password, post_ID); -839 else -840 struct = this.wp.getCommentCount(0, this.username, this.password); -841 CommentCount cc = new CommentCount(); -842 cc.fromXmlRpcStruct(struct); -843 return cc; -844 } -845 -846 /** -847 * -848 * @param status -849 * One of "approve", "hold", or "spam". Or, null to show all. -850 * @param post_id -851 * Filter comments by post_id, or null to not filter. -852 * @param number -853 * The number of comments to return, or null for the default (of 10) -854 * @param offset -855 * The offset into the set of comments to return, or null for 0 -856 * @return A list of Comment objects -857 * @throws XmlRpcFault -858 * Generic exception for xml-rpc operations -859 */ -860 @SuppressWarnings({ "unchecked", "nls", "boxing" }) -861 public List<Comment> getComments(String status, Integer post_id, -862 Integer number, Integer offset) throws XmlRpcFault { -863 -864 XmlRpcStruct filter = new XmlRpcStruct(); -865 -866 if (status != null) { -867 filter.put("status", status); -868 } -869 -870 if (post_id != null) { -871 filter.put("post_id", post_id); -872 } -873 -874 if (number != null) { -875 filter.put("number", number); -876 } -877 -878 if (offset != null) { -879 filter.put("offset", offset); -880 } -881 -882 XmlRpcArray r = this.wp -883 .getComments(0, this.username, this.password, filter); -884 return fillFromXmlRpcArray(r, Comment.class); -885 } -886 -887 /** -888 * @param comment_id -889 * comment_id to fetch -890 * @return A Comment object -891 * @throws XmlRpcFault -892 * Generic exception for xml-rpc operations -893 */ -894 @SuppressWarnings("boxing") -895 public Comment getComment(Integer comment_id) throws XmlRpcFault { -896 XmlRpcStruct struct = this.wp.getComment(0, this.username, this.password, -897 comment_id); -898 -899 Comment comment = new Comment(); -900 comment.fromXmlRpcStruct(struct); -901 -902 return comment; -903 } -904 -905 /** -906 * @param post_id -907 * Post to attach the comment to. -908 * @param comment_parent -909 * Id of the parent comment (for threading) -910 * @param content -911 * Content of comment -912 * @param author -913 * Author's name -914 * @param author_url -915 * Author's URL (can be empty) -916 * @param author_email -917 * Author's Email Address -918 * @return the id for the newly created comment. -919 * @throws XmlRpcFault -920 * Generic exception for xml-rpc operations -921 */ -922 @SuppressWarnings({ "unchecked", "nls", "boxing" }) -923 public Integer newComment(Integer post_id, Integer comment_parent, -924 String content, String author, String author_url, String author_email) -925 throws XmlRpcFault { -926 -927 XmlRpcStruct comment = new XmlRpcStruct(); -928 -929 if (comment_parent != null) { -930 comment.put("comment_parent", comment_parent); -931 } -932 -933 comment.put("content", content); -934 if (author != null) -935 comment.put("author", author); -936 if (author_url != null) -937 comment.put("author_url", author_url); -938 if (author_email != null) -939 comment.put("author_email", author_email); -940 -941 Integer comment_id = this.wp.newComment(0, this.username, this.password, -942 post_id, comment); -943 -944 return comment_id; -945 } -946 -947 /** -948 * @return the comment status list -949 */ -950 public CommentStatusList getCommentStatusList() { -951 XmlRpcStruct csl = this.wp.getCommentStatusList(0, this.username, -952 this.password); -953 CommentStatusList result = new CommentStatusList(); -954 result.fromXmlRpcStruct(csl); -955 return result; -956 } -957 -958 /** -959 * @param commentID -960 * comment id to delete -961 * @return result of the operation -962 * @throws XmlRpcFault -963 */ -964 @SuppressWarnings("boxing") -965 public boolean deleteComment(int commentID) throws XmlRpcFault { -966 return this.wp.deleteComment(0, this.username, this.password, commentID); -967 } -968 -969 /** -970 * @param comment -971 * @return Result of the operation -972 * @throws XmlRpcFault -973 */ -974 @SuppressWarnings("boxing") -975 public boolean editComment(Comment comment) throws XmlRpcFault { -976 Boolean r = this.wp.editComment(0, this.username, this.password, -977 comment.getComment_id(), comment); -978 return r; -979 } -980 -981 /** -982 * @param categoryId -983 * @return Result of the operation -984 * @throws XmlRpcFault -985 */ -986 @SuppressWarnings("boxing") -987 public int deleteCategory(int categoryId) throws XmlRpcFault { -988 Object r = this.wp.deleteCategory(0, this.username, this.password, -989 categoryId); -990 if (r instanceof Boolean) -991 return 0; -992 return (Integer) r; -993 } -994} -995 -996interface WordpressBridge { -997 -998 Boolean editComment(Integer blogid, String username, String password, -999 Integer comment_id, Comment comment) throws XmlRpcFault; -1000 -1001 Object deleteCategory(Integer blogid, String username, String password, -1002 Integer category_id); -1003 -1004 Boolean deleteComment(Integer blogid, String username, String password, -1005 Integer comment_id) throws XmlRpcFault; -1006 -1007 /** -1008 * @param blogid -1009 * Blog id, not used in wordpress -1010 * @param username -1011 * User name -1012 * @param password -1013 * Password -1014 * @param post_ID -1015 * ID of the post to delete -1016 * @param publish -1017 * Publish status -1018 * @return Result of deletion-- -1019 * @throws XmlRpcFault -1020 */ -1021 Boolean deletePage(Integer blogid, String username, String password, -1022 Integer post_ID, String publish) throws XmlRpcFault; -1023 -1024 XmlRpcStruct getCommentStatusList(int i, String username, String password); -1025 -1026 /** -1027 * @param blogid -1028 * Blog id, not used in wordpress -1029 * @param post_ID -1030 * ID of the post to edit -1031 * @param username -1032 * User name -1033 * @param password -1034 * Password -1035 * @param post -1036 * Post information -1037 * @param publish -1038 * Publish status -1039 * @return Result of edit -1040 * @throws XmlRpcFault -1041 */ -1042 Boolean editPage(Integer blogid, Integer post_ID, String username, -1043 String password, XmlRpcStruct post, String publish) throws XmlRpcFault; -1044 -1045 /** -1046 * @param blogid -1047 * Blog id, not used in wordpress -1048 * @param username -1049 * User name -1050 * @param password -1051 * Password -1052 * @return Array of Authors -1053 * @throws XmlRpcFault -1054 */ -1055 XmlRpcArray getAuthors(int blogid, String username, String password) -1056 throws XmlRpcFault; -1057 -1058 /** -1059 * @param blogid -1060 * Blog id, not used in wordpress -1061 * @param username -1062 * User name -1063 * @param password -1064 * Password -1065 * @return Array of categories -1066 * @throws XmlRpcFault -1067 */ -1068 XmlRpcArray getCategories(int blogid, String username, String password) -1069 throws XmlRpcFault; -1070 -1071 /** -1072 * @param blogid -1073 * Blog id, not used in wordpress -1074 * @param pageid -1075 * Page id -1076 * @param username -1077 * User name -1078 * @param password -1079 * Password -1080 * @return Page information -1081 * @throws XmlRpcFault -1082 */ -1083 XmlRpcStruct getPage(Integer blogid, Integer pageid, String username, -1084 String password) throws XmlRpcFault; -1085 -1086 /** -1087 * @param blogid -1088 * Blog id, not used in wordpress -1089 * @param username -1090 * User name -1091 * @param password -1092 * Password -1093 * @return Array of Pages -1094 * @throws XmlRpcFault -1095 */ -1096 XmlRpcArray getPageList(Integer blogid, String username, String password) -1097 throws XmlRpcFault; -1098 -1099 /** -1100 * @param blogid -1101 * Blog id, not used in wordpress -1102 * @param username -1103 * User name -1104 * @param password -1105 * Password -1106 * @return Array of Pages -1107 * @throws XmlRpcFault -1108 */ -1109 XmlRpcArray getPages(Integer blogid, String username, String password) -1110 throws XmlRpcFault; -1111 -1112 /** -1113 * @param blogid -1114 * Blog id, not used in wordpress -1115 * @param username -1116 * User name -1117 * @param password -1118 * Password -1119 * @param category -1120 * Category information -1121 * @return new category id -1122 * @throws XmlRpcFault -1123 */ -1124 Integer newCategory(Integer blogid, String username, String password, -1125 XmlRpcStruct category) throws XmlRpcFault; -1126 -1127 /** -1128 * @param blogid -1129 * Blog id, not used in wordpress -1130 * @param username -1131 * User name -1132 * @param password -1133 * Password -1134 * @param post -1135 * Page information -1136 * @param publish -1137 * Publish status -1138 * @return Post ID -1139 * @throws XmlRpcFault -1140 */ -1141 String newPage(Integer blogid, String username, String password, -1142 XmlRpcStruct post, String publish) throws XmlRpcFault; -1143 -1144 /** -1145 * @param blogid -1146 * Blog id, not used in wordpress -1147 * @param username -1148 * User name -1149 * @param password -1150 * Password -1151 * @param category -1152 * Category to search -1153 * @param max_results -1154 * Maximum results to return -1155 * @return List of suggested categories -1156 * @throws XmlRpcFault -1157 */ -1158 XmlRpcArray suggestCategories(Integer blogid, String username, -1159 String password, String category, Integer max_results) throws XmlRpcFault; -1160 -1161 XmlRpcStruct getPostStatusList(Integer blogid, String username, -1162 String password) throws XmlRpcFault; -1163 -1164 XmlRpcStruct getPageStatusList(Integer blogid, String username, -1165 String password) throws XmlRpcFault; -1166 -1167 XmlRpcStruct getCommentCount(Integer blogid, String username, -1168 String password, Integer post_ID) throws XmlRpcFault; -1169 -1170 XmlRpcStruct getCommentCount(Integer blogid, String username, String password) -1171 throws XmlRpcFault; -1172 -1173 XmlRpcArray getComments(Integer blogid, String username, String password, -1174 XmlRpcStruct filter) throws XmlRpcFault; -1175 -1176 XmlRpcStruct getComment(Integer blogid, String username, String password, -1177 Integer comment_id) throws XmlRpcFault; -1178 -1179 Integer newComment(Integer blogid, String username, String password, -1180 Integer post_id, XmlRpcStruct comment) throws XmlRpcFault; -1181 -1182} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress; -011 -012import java.lang.reflect.Field; -013import java.text.ParseException; -014import java.text.SimpleDateFormat; -015import java.util.Date; -016 -017import redstone.xmlrpc.XmlRpcStruct; -018 -019/** -020 * -021 * An object that has the capabilites of converting to/from -022 * <code>XmlRpcStruct</code>. -023 * -024 * @author Can Bican <can@bican.net> -025 * -026 */ -027public abstract class XmlRpcMapped { -028 -029 @SuppressWarnings("nls") -030 private static final SimpleDateFormat sdf = new SimpleDateFormat( -031 "yyyyMMdd'T'HH:mm:ss"); -032 -033 /** -034 * (non-Javadoc) -035 * -036 * @param recordDelimiter How to delimit records -037 * @param fieldDelimiter How to delimit the key/value pairs -038 * @param showFieldName Whether to show field name or not -039 * -040 * @see java.lang.Object#toString() -041 */ -042 @SuppressWarnings("nls") -043 private String toGenericString(String recordDelimiter, String fieldDelimiter, -044 boolean showFieldName) { -045 String result = null; -046 try { -047 result = ""; -048 Field[] f = this.getClass().getDeclaredFields(); -049 for (Field field : f) { -050 Class<?> fType = field.getType(); -051 if (showFieldName) -052 result += field.getName() + fieldDelimiter; -053 if (fType == Date.class) { -054 result += sdf.format(field.get(this)); -055 } else { -056 result += field.get(this); -057 } -058 result += recordDelimiter; -059 } -060 } catch (IllegalAccessException e) { -061 // ignore and skip output -062 } -063 return result; -064 } -065 -066 /** -067 * (non-Javadoc) -068 * -069 * @see java.lang.Object#toString() -070 */ -071 @SuppressWarnings("nls") -072 @Override -073 public String toString() { -074 return toGenericString("\n", ":", true); -075 } -076 -077 /** -078 * @return Something similar to toString() but in one line -079 */ -080 @SuppressWarnings("nls") -081 public String toOneLinerString() { -082 return toGenericString(":", "", false).replaceAll(":$", ""); -083 } -084 -085 /** -086 * @param x XmlRpcStruct to create the object from -087 */ -088 @SuppressWarnings("nls") -089 public void fromXmlRpcStruct(XmlRpcStruct x) { -090 Field[] f = this.getClass().getDeclaredFields(); -091 String k = null; -092 Object v = null; -093 for (Field field : f) { -094 try { -095 k = field.getName(); -096 v = x.get(k); -097 Class<?> kType = field.getType(); -098 if (v != null) { -099 if (kType == Integer.class) { -100 if (v.getClass() != Integer.class) { -101 Integer vInt = Integer.valueOf((String) v); -102 field.set(this, vInt); -103 } else { -104 field.set(this, v); -105 } -106 } else if (kType == Date.class) { -107 try { -108 if (v.getClass() != Date.class) { -109 Date vDate = sdf.parse((String) v); -110 field.set(this, vDate); -111 } else { -112 field.set(this, v); -113 } -114 } catch (ParseException e) { -115 throw new IllegalArgumentException(e); -116 } -117 } else { -118 field.set(this, v); -119 } -120 } -121 } catch (IllegalArgumentException e) { -122 try { -123 System.err.println("Warning: value \"" + v + "\" is invalid for \"" -124 + k + "\", setting it to \"null\""); -125 field.set(this, null); -126 } catch (IllegalAccessException e1) { -127 System.err.println(field.getName() + ":" + field.getType() + ":" -128 + x.get(field.getName())); -129 e1.printStackTrace(); -130 } -131 } catch (IllegalAccessException e) { -132 e.printStackTrace(); -133 } -134 } -135 } -136 -137 /** -138 * @return An XmlRpcStruct that represents the object. -139 */ -140 @SuppressWarnings("unchecked") -141 public XmlRpcStruct toXmlRpcStruct() { -142 XmlRpcStruct result = new XmlRpcStruct(); -143 Field[] f = this.getClass().getDeclaredFields(); -144 for (Field field : f) { -145 try { -146 Object o = field.get(this); -147 if (o != null) { -148 result.put(field.getName(), o); -149 } -150 } catch (IllegalArgumentException e) { -151 e.printStackTrace(); -152 } catch (IllegalAccessException e) { -153 e.printStackTrace(); -154 } -155 } -156 return result; -157 } -158} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress.configuration; -011 -012import org.apache.commons.cli.BasicParser; -013import org.apache.commons.cli.CommandLine; -014import org.apache.commons.cli.CommandLineParser; -015import org.apache.commons.cli.Option; -016import org.apache.commons.cli.Options; -017import org.apache.commons.cli.ParseException; -018import org.apache.commons.configuration.BaseConfiguration; -019 -020/** -021 * -022 * Implement a simple CLI configuration in apache commons configuration style -023 * -024 * @author Can Bican <can@bican.net> -025 * -026 */ -027public class CliConfiguration extends BaseConfiguration { -028 /** -029 * -030 * generates the configuration in terms of arguments and options -031 * -032 * @param args Command line arguments -033 * @param options Command line options -034 * @throws ParseException When the configuration cannot be parsed -035 */ -036 @SuppressWarnings("nls") -037 public CliConfiguration(String[] args, Options options) throws ParseException { -038 CommandLineParser parser = new BasicParser(); -039 CommandLine commandLine = parser.parse(options, args); -040 for (Option option : commandLine.getOptions()) { -041 String key = option.getLongOpt(); -042 String val = option.getValue(); -043 if (val == null) { -044 this.addProperty(key, "N/A"); -045 } else { -046 this.addProperty(key, val); -047 } -048 } -049 } -050} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress.configuration; -011 -012import java.util.prefs.BackingStoreException; -013import java.util.prefs.Preferences; -014 -015import org.apache.commons.configuration.BaseConfiguration; -016 -017/** -018 * -019 * -020 * @author Can Bican <can@bican.net> -021 * -022 */ -023public class PreferencesConfiguration extends BaseConfiguration { -024 -025 /** -026 * @param cl Calling class -027 */ -028 public PreferencesConfiguration(Class<?> cl) { -029 try { -030 Preferences p = Preferences.userNodeForPackage(cl); -031 for (String preference : p.keys()) { -032 this.addProperty(preference, p.get(preference, null)); -033 } -034 } catch (BackingStoreException e) { -035 // then we end up with an empty set of preferences, no big deal -036 } -037 } -038} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress.configuration; -011 -012import java.util.ArrayList; -013import java.util.Collection; -014 -015import org.apache.commons.cli.Options; -016import org.apache.commons.cli.ParseException; -017import org.apache.commons.configuration.CompositeConfiguration; -018import org.apache.commons.configuration.Configuration; -019 -020/** -021 * -022 * A composite configuration class that combines preferences and command line. -023 * -024 * @author Can Bican <can@bican.net> -025 * -026 */ -027public class WpCliConfiguration { -028 -029 private CompositeConfiguration config = null; -030 -031 /** -032 * @param args Command line arguments -033 * @param options Command line options -034 * @param cl Calling class -035 * @throws ParseException When the configuration cannot be parsed -036 */ -037 public WpCliConfiguration(String[] args, Options options, Class<?> cl) -038 throws ParseException { -039 Collection<Configuration> confs = new ArrayList<Configuration>(); -040 confs.add(new CliConfiguration(args, options)); -041 confs.add(new PreferencesConfiguration(cl)); -042 this.config = new CompositeConfiguration(confs); -043 } -044 -045 /** -046 * @param key Option key to check -047 * @return <code>true</code> if the configuration contains the key -048 */ -049 public boolean hasOption(String key) { -050 return this.config.containsKey(key); -051 } -052 -053 /** -054 * @param key Option key to retrieve -055 * @return Value of the option key -056 */ -057 public String getOptionValue(String key) { -058 return this.config.getString(key); -059 } -060 -061} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001/* -002 * -003 * Wordpress-java -004 * http://code.google.com/p/wordpress-java/ -005 * -006 * Copyright 2012 Can Bican <can@bican.net> -007 * See the file 'COPYING' in the distribution for licensing terms. -008 * -009 */ -010package net.bican.wordpress.example; -011 -012import java.net.MalformedURLException; -013import java.util.List; -014 -015import redstone.xmlrpc.XmlRpcFault; -016 -017import net.bican.wordpress.Page; -018import net.bican.wordpress.PageDefinition; -019import net.bican.wordpress.Wordpress; -020 -021/** -022 * -023 * Example implementation -024 * -025 * Run this as java net.bican.wordpress.example.Main <username> -026 * <password> <xmlrpc-url> for your blog. -027 * -028 * @author Can Bican -029 * -030 */ -031public class Main { -032 -033 /** -034 * @param args -035 * @throws MalformedURLException -036 * @throws XmlRpcFault -037 */ -038 @SuppressWarnings("nls") -039 public static void main(String[] args) throws MalformedURLException, -040 XmlRpcFault { -041 String username = args[0]; -042 String password = args[1]; -043 String xmlRpcUrl = args[2]; -044 Wordpress wp = new Wordpress(username, password, xmlRpcUrl); -045 List<Page> recentPosts = wp.getRecentPosts(10); -046 System.out.println("Here are the ten recent posts:"); -047 for (Page page : recentPosts) { -048 System.out.println(page.getPostid() + ":" + page.getTitle()); -049 } -050 List<PageDefinition> pages = wp.getPageList(); -051 System.out.println("Here are the pages:"); -052 for (PageDefinition pageDefinition : pages) { -053 System.out.println(pageDefinition.getPage_title()); -054 } -055 System.out.println("Posting a test (draft) page from a previous page..."); -056 Page recentPost = wp.getRecentPosts(1).get(0); -057 recentPost.setTitle("Test Page"); -058 recentPost.setDescription("Test description"); -059 String result = wp.newPost(recentPost, false); -060 System.out.println("new post page id: " + result); -061 System.out.println("\nThat's all for now."); -062 } -063 -064} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001package org.json; -002 -003/* -004 Copyright (c) 2002 JSON.org -005 -006 Permission is hereby granted, free of charge, to any person obtaining a copy -007 of this software and associated documentation files (the "Software"), to deal -008 in the Software without restriction, including without limitation the rights -009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -010 copies of the Software, and to permit persons to whom the Software is -011 furnished to do so, subject to the following conditions: -012 -013 The above copyright notice and this permission notice shall be included in all -014 copies or substantial portions of the Software. -015 -016 The Software shall be used for Good, not Evil. -017 -018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -024 SOFTWARE. -025 */ -026 -027import java.io.IOException; -028import java.io.Writer; -029import java.lang.reflect.Array; -030import java.util.ArrayList; -031import java.util.Collection; -032import java.util.Iterator; -033import java.util.Map; -034 -035/** -036 * A JSONArray is an ordered sequence of values. Its external text form is a -037 * string wrapped in square brackets with commas separating the values. The -038 * internal form is an object having <code>get</code> and <code>opt</code> -039 * methods for accessing the values by index, and <code>put</code> methods for -040 * adding or replacing values. The values can be any of these types: -041 * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>, -042 * <code>Number</code>, <code>String</code>, or the -043 * <code>JSONObject.NULL object</code>. -044 * <p> -045 * The constructor can convert a JSON text into a Java object. The -046 * <code>toString</code> method converts to JSON text. -047 * <p> -048 * A <code>get</code> method returns a value if one can be found, and throws an -049 * exception if one cannot be found. An <code>opt</code> method returns a -050 * default value instead of throwing an exception, and so is useful for -051 * obtaining optional values. -052 * <p> -053 * The generic <code>get()</code> and <code>opt()</code> methods return an -054 * object which you can cast or query for type. There are also typed -055 * <code>get</code> and <code>opt</code> methods that do type checking and type -056 * coercion for you. -057 * <p> -058 * The texts produced by the <code>toString</code> methods strictly conform to -059 * JSON syntax rules. The constructors are more forgiving in the texts they will -060 * accept: -061 * <ul> -062 * <li>An extra <code>,</code> <small>(comma)</small> may appear just -063 * before the closing bracket.</li> -064 * <li>The <code>null</code> value will be inserted when there is <code>,</code> -065 * <small>(comma)</small> elision.</li> -066 * <li>Strings may be quoted with <code>'</code> <small>(single quote)</small>.</li> -067 * <li>Strings do not need to be quoted at all if they do not begin with a quote -068 * or single quote, and if they do not contain leading or trailing spaces, and -069 * if they do not contain any of these characters: -070 * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and -071 * if they are not the reserved words <code>true</code>, <code>false</code>, or -072 * <code>null</code>.</li> -073 * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as -074 * well as by <code>,</code> <small>(comma)</small>.</li> -075 * <li>Numbers may have the <code>0x-</code> <small>(hex)</small> prefix.</li> -076 * </ul> -077 * -078 * @author JSON.org -079 * @version 2009-04-14 -080 */ -081@SuppressWarnings({"unchecked","rawtypes","nls"}) -082public class JSONArray { -083 -084 /** -085 * The arrayList where the JSONArray's properties are kept. -086 */ -087 private ArrayList myArrayList; -088 -089 /** -090 * Construct an empty JSONArray. -091 */ -092 public JSONArray() { -093 this.myArrayList = new ArrayList(); -094 } -095 -096 /** -097 * Construct a JSONArray from a JSONTokener. -098 * -099 * @param x A JSONTokener -100 * @throws JSONException If there is a syntax error. -101 */ -102 public JSONArray(JSONTokener x) throws JSONException { -103 this(); -104 char c = x.nextClean(); -105 char q; -106 if (c == '[') { -107 q = ']'; -108 } else if (c == '(') { -109 q = ')'; -110 } else { -111 throw x.syntaxError("A JSONArray text must start with '['"); -112 } -113 if (x.nextClean() == ']') { -114 return; -115 } -116 x.back(); -117 for (;;) { -118 if (x.nextClean() == ',') { -119 x.back(); -120 this.myArrayList.add(null); -121 } else { -122 x.back(); -123 this.myArrayList.add(x.nextValue()); -124 } -125 c = x.nextClean(); -126 switch (c) { -127 case ';': -128 case ',': -129 if (x.nextClean() == ']') { -130 return; -131 } -132 x.back(); -133 break; -134 case ']': -135 case ')': -136 if (q != c) { -137 throw x.syntaxError("Expected a '" + new Character(q) + "'"); -138 } -139 return; -140 default: -141 throw x.syntaxError("Expected a ',' or ']'"); -142 } -143 } -144 } -145 -146 /** -147 * Construct a JSONArray from a source JSON text. -148 * -149 * @param source A string that begins with <code>[</code> <small>(left -150 * bracket)</small> and ends with <code>]</code> <small>(right -151 * bracket)</small>. -152 * @throws JSONException If there is a syntax error. -153 */ -154 public JSONArray(String source) throws JSONException { -155 this(new JSONTokener(source)); -156 } -157 -158 /** -159 * Construct a JSONArray from a Collection. -160 * -161 * @param collection A Collection. -162 */ -163 public JSONArray(Collection collection) { -164 this.myArrayList = new ArrayList(); -165 if (collection != null) { -166 Iterator iter = collection.iterator(); -167 while (iter.hasNext()) { -168 Object o = iter.next(); -169 this.myArrayList.add(JSONObject.wrap(o)); -170 } -171 } -172 } -173 -174 /** -175 * Construct a JSONArray from an array -176 * -177 * @param array TODO -178 * @throws JSONException If not an array. -179 */ -180 public JSONArray(Object array) throws JSONException { -181 this(); -182 if (array.getClass().isArray()) { -183 int length = Array.getLength(array); -184 for (int i = 0; i < length; i += 1) { -185 this.put(JSONObject.wrap(Array.get(array, i))); -186 } -187 } else { -188 throw new JSONException( -189 "JSONArray initial value should be a string or collection or array."); -190 } -191 } -192 -193 /** -194 * Get the object value associated with an index. -195 * -196 * @param index The index must be between 0 and length() - 1. -197 * @return An object value. -198 * @throws JSONException If there is no value for the index. -199 */ -200 public Object get(int index) throws JSONException { -201 Object o = opt(index); -202 if (o == null) { -203 throw new JSONException("JSONArray[" + index + "] not found."); -204 } -205 return o; -206 } -207 -208 /** -209 * Get the boolean value associated with an index. The string values "true" -210 * and "false" are converted to boolean. -211 * -212 * @param index The index must be between 0 and length() - 1. -213 * @return The truth. -214 * @throws JSONException If there is no value for the index or if the value is -215 * not convertable to boolean. -216 */ -217 public boolean getBoolean(int index) throws JSONException { -218 Object o = get(index); -219 if (o.equals(Boolean.FALSE) -220 || (o instanceof String && ((String) o).equalsIgnoreCase("false"))) { -221 return false; -222 } else if (o.equals(Boolean.TRUE) -223 || (o instanceof String && ((String) o).equalsIgnoreCase("true"))) { -224 return true; -225 } -226 throw new JSONException("JSONArray[" + index + "] is not a Boolean."); -227 } -228 -229 /** -230 * Get the double value associated with an index. -231 * -232 * @param index The index must be between 0 and length() - 1. -233 * @return The value. -234 * @throws JSONException If the key is not found or if the value cannot be -235 * converted to a number. -236 */ -237 public double getDouble(int index) throws JSONException { -238 Object o = get(index); -239 try { -240 return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf( -241 (String) o).doubleValue(); -242 } catch (Exception e) { -243 throw new JSONException("JSONArray[" + index + "] is not a number."); -244 } -245 } -246 -247 /** -248 * Get the int value associated with an index. -249 * -250 * @param index The index must be between 0 and length() - 1. -251 * @return The value. -252 * @throws JSONException If the key is not found or if the value cannot be -253 * converted to a number. if the value cannot be converted to a -254 * number. -255 */ -256 public int getInt(int index) throws JSONException { -257 Object o = get(index); -258 return o instanceof Number ? ((Number) o).intValue() -259 : (int) getDouble(index); -260 } -261 -262 /** -263 * Get the JSONArray associated with an index. -264 * -265 * @param index The index must be between 0 and length() - 1. -266 * @return A JSONArray value. -267 * @throws JSONException If there is no value for the index. or if the value -268 * is not a JSONArray -269 */ -270 public JSONArray getJSONArray(int index) throws JSONException { -271 Object o = get(index); -272 if (o instanceof JSONArray) { -273 return (JSONArray) o; -274 } -275 throw new JSONException("JSONArray[" + index + "] is not a JSONArray."); -276 } -277 -278 /** -279 * Get the JSONObject associated with an index. -280 * -281 * @param index subscript -282 * @return A JSONObject value. -283 * @throws JSONException If there is no value for the index or if the value is -284 * not a JSONObject -285 */ -286 public JSONObject getJSONObject(int index) throws JSONException { -287 Object o = get(index); -288 if (o instanceof JSONObject) { -289 return (JSONObject) o; -290 } -291 throw new JSONException("JSONArray[" + index + "] is not a JSONObject."); -292 } -293 -294 /** -295 * Get the long value associated with an index. -296 * -297 * @param index The index must be between 0 and length() - 1. -298 * @return The value. -299 * @throws JSONException If the key is not found or if the value cannot be -300 * converted to a number. -301 */ -302 public long getLong(int index) throws JSONException { -303 Object o = get(index); -304 return o instanceof Number ? ((Number) o).longValue() -305 : (long) getDouble(index); -306 } -307 -308 /** -309 * Get the string associated with an index. -310 * -311 * @param index The index must be between 0 and length() - 1. -312 * @return A string value. -313 * @throws JSONException If there is no value for the index. -314 */ -315 public String getString(int index) throws JSONException { -316 return get(index).toString(); -317 } -318 -319 /** -320 * Determine if the value is null. -321 * -322 * @param index The index must be between 0 and length() - 1. -323 * @return true if the value at the index is null, or if there is no value. -324 */ -325 public boolean isNull(int index) { -326 return JSONObject.NULL.equals(opt(index)); -327 } -328 -329 /** -330 * Make a string from the contents of this JSONArray. The -331 * <code>separator</code> string is inserted between each element. Warning: -332 * This method assumes that the data structure is acyclical. -333 * -334 * @param separator A string that will be inserted between the elements. -335 * @return a string. -336 * @throws JSONException If the array contains an invalid number. -337 */ -338 public String join(String separator) throws JSONException { -339 int len = length(); -340 StringBuffer sb = new StringBuffer(); -341 -342 for (int i = 0; i < len; i += 1) { -343 if (i > 0) { -344 sb.append(separator); -345 } -346 sb.append(JSONObject.valueToString(this.myArrayList.get(i))); -347 } -348 return sb.toString(); -349 } -350 -351 /** -352 * Get the number of elements in the JSONArray, included nulls. -353 * -354 * @return The length (or size). -355 */ -356 public int length() { -357 return this.myArrayList.size(); -358 } -359 -360 /** -361 * Get the optional object value associated with an index. -362 * -363 * @param index The index must be between 0 and length() - 1. -364 * @return An object value, or null if there is no object at that index. -365 */ -366 public Object opt(int index) { -367 return (index < 0 || index >= length()) ? null : this.myArrayList -368 .get(index); -369 } -370 -371 /** -372 * Get the optional boolean value associated with an index. It returns false -373 * if there is no value at that index, or if the value is not Boolean.TRUE or -374 * the String "true". -375 * -376 * @param index The index must be between 0 and length() - 1. -377 * @return The truth. -378 */ -379 public boolean optBoolean(int index) { -380 return optBoolean(index, false); -381 } -382 -383 /** -384 * Get the optional boolean value associated with an index. It returns the -385 * defaultValue if there is no value at that index or if it is not a Boolean -386 * or the String "true" or "false" (case insensitive). -387 * -388 * @param index The index must be between 0 and length() - 1. -389 * @param defaultValue A boolean default. -390 * @return The truth. -391 */ -392 public boolean optBoolean(int index, boolean defaultValue) { -393 try { -394 return getBoolean(index); -395 } catch (Exception e) { -396 return defaultValue; -397 } -398 } -399 -400 /** -401 * Get the optional double value associated with an index. NaN is returned if -402 * there is no value for the index, or if the value is not a number and cannot -403 * be converted to a number. -404 * -405 * @param index The index must be between 0 and length() - 1. -406 * @return The value. -407 */ -408 public double optDouble(int index) { -409 return optDouble(index, Double.NaN); -410 } -411 -412 /** -413 * Get the optional double value associated with an index. The defaultValue is -414 * returned if there is no value for the index, or if the value is not a -415 * number and cannot be converted to a number. -416 * -417 * @param index subscript -418 * @param defaultValue The default value. -419 * @return The value. -420 */ -421 public double optDouble(int index, double defaultValue) { -422 try { -423 return getDouble(index); -424 } catch (Exception e) { -425 return defaultValue; -426 } -427 } -428 -429 /** -430 * Get the optional int value associated with an index. Zero is returned if -431 * there is no value for the index, or if the value is not a number and cannot -432 * be converted to a number. -433 * -434 * @param index The index must be between 0 and length() - 1. -435 * @return The value. -436 */ -437 public int optInt(int index) { -438 return optInt(index, 0); -439 } -440 -441 /** -442 * Get the optional int value associated with an index. The defaultValue is -443 * returned if there is no value for the index, or if the value is not a -444 * number and cannot be converted to a number. -445 * -446 * @param index The index must be between 0 and length() - 1. -447 * @param defaultValue The default value. -448 * @return The value. -449 */ -450 public int optInt(int index, int defaultValue) { -451 try { -452 return getInt(index); -453 } catch (Exception e) { -454 return defaultValue; -455 } -456 } -457 -458 /** -459 * Get the optional JSONArray associated with an index. -460 * -461 * @param index subscript -462 * @return A JSONArray value, or null if the index has no value, or if the -463 * value is not a JSONArray. -464 */ -465 public JSONArray optJSONArray(int index) { -466 Object o = opt(index); -467 return o instanceof JSONArray ? (JSONArray) o : null; -468 } -469 -470 /** -471 * Get the optional JSONObject associated with an index. Null is returned if -472 * the key is not found, or null if the index has no value, or if the value is -473 * not a JSONObject. -474 * -475 * @param index The index must be between 0 and length() - 1. -476 * @return A JSONObject value. -477 */ -478 public JSONObject optJSONObject(int index) { -479 Object o = opt(index); -480 return o instanceof JSONObject ? (JSONObject) o : null; -481 } -482 -483 /** -484 * Get the optional long value associated with an index. Zero is returned if -485 * there is no value for the index, or if the value is not a number and cannot -486 * be converted to a number. -487 * -488 * @param index The index must be between 0 and length() - 1. -489 * @return The value. -490 */ -491 public long optLong(int index) { -492 return optLong(index, 0); -493 } -494 -495 /** -496 * Get the optional long value associated with an index. The defaultValue is -497 * returned if there is no value for the index, or if the value is not a -498 * number and cannot be converted to a number. -499 * -500 * @param index The index must be between 0 and length() - 1. -501 * @param defaultValue The default value. -502 * @return The value. -503 */ -504 public long optLong(int index, long defaultValue) { -505 try { -506 return getLong(index); -507 } catch (Exception e) { -508 return defaultValue; -509 } -510 } -511 -512 /** -513 * Get the optional string value associated with an index. It returns an empty -514 * string if there is no value at that index. If the value is not a string and -515 * is not null, then it is coverted to a string. -516 * -517 * @param index The index must be between 0 and length() - 1. -518 * @return A String value. -519 */ -520 public String optString(int index) { -521 return optString(index, ""); -522 } -523 -524 /** -525 * Get the optional string associated with an index. The defaultValue is -526 * returned if the key is not found. -527 * -528 * @param index The index must be between 0 and length() - 1. -529 * @param defaultValue The default value. -530 * @return A String value. -531 */ -532 public String optString(int index, String defaultValue) { -533 Object o = opt(index); -534 return o != null ? o.toString() : defaultValue; -535 } -536 -537 /** -538 * Append a boolean value. This increases the array's length by one. -539 * -540 * @param value A boolean value. -541 * @return this. -542 */ -543 public JSONArray put(boolean value) { -544 put(value ? Boolean.TRUE : Boolean.FALSE); -545 return this; -546 } -547 -548 /** -549 * Put a value in the JSONArray, where the value will be a JSONArray which is -550 * produced from a Collection. -551 * -552 * @param value A Collection value. -553 * @return this. -554 */ -555 public JSONArray put(Collection value) { -556 put(new JSONArray(value)); -557 return this; -558 } -559 -560 /** -561 * Append a double value. This increases the array's length by one. -562 * -563 * @param value A double value. -564 * @throws JSONException if the value is not finite. -565 * @return this. -566 */ -567 public JSONArray put(double value) throws JSONException { -568 Double d = new Double(value); -569 JSONObject.testValidity(d); -570 put(d); -571 return this; -572 } -573 -574 /** -575 * Append an int value. This increases the array's length by one. -576 * -577 * @param value An int value. -578 * @return this. -579 */ -580 public JSONArray put(int value) { -581 put(new Integer(value)); -582 return this; -583 } -584 -585 /** -586 * Append an long value. This increases the array's length by one. -587 * -588 * @param value A long value. -589 * @return this. -590 */ -591 public JSONArray put(long value) { -592 put(new Long(value)); -593 return this; -594 } -595 -596 /** -597 * Put a value in the JSONArray, where the value will be a JSONObject which is -598 * produced from a Map. -599 * -600 * @param value A Map value. -601 * @return this. -602 */ -603 public JSONArray put(Map value) { -604 put(new JSONObject(value)); -605 return this; -606 } -607 -608 /** -609 * Append an object value. This increases the array's length by one. -610 * -611 * @param value An object value. The value should be a Boolean, Double, -612 * Integer, JSONArray, JSONObject, Long, or String, or the -613 * JSONObject.NULL object. -614 * @return this. -615 */ -616 public JSONArray put(Object value) { -617 this.myArrayList.add(value); -618 return this; -619 } -620 -621 /** -622 * Put or replace a boolean value in the JSONArray. If the index is greater -623 * than the length of the JSONArray, then null elements will be added as -624 * necessary to pad it out. -625 * -626 * @param index The subscript. -627 * @param value A boolean value. -628 * @return this. -629 * @throws JSONException If the index is negative. -630 */ -631 public JSONArray put(int index, boolean value) throws JSONException { -632 put(index, value ? Boolean.TRUE : Boolean.FALSE); -633 return this; -634 } -635 -636 /** -637 * Put a value in the JSONArray, where the value will be a JSONArray which is -638 * produced from a Collection. -639 * -640 * @param index The subscript. -641 * @param value A Collection value. -642 * @return this. -643 * @throws JSONException If the index is negative or if the value is not -644 * finite. -645 */ -646 public JSONArray put(int index, Collection value) throws JSONException { -647 put(index, new JSONArray(value)); -648 return this; -649 } -650 -651 /** -652 * Put or replace a double value. If the index is greater than the length of -653 * the JSONArray, then null elements will be added as necessary to pad it out. -654 * -655 * @param index The subscript. -656 * @param value A double value. -657 * @return this. -658 * @throws JSONException If the index is negative or if the value is not -659 * finite. -660 */ -661 public JSONArray put(int index, double value) throws JSONException { -662 put(index, new Double(value)); -663 return this; -664 } -665 -666 /** -667 * Put or replace an int value. If the index is greater than the length of the -668 * JSONArray, then null elements will be added as necessary to pad it out. -669 * -670 * @param index The subscript. -671 * @param value An int value. -672 * @return this. -673 * @throws JSONException If the index is negative. -674 */ -675 public JSONArray put(int index, int value) throws JSONException { -676 put(index, new Integer(value)); -677 return this; -678 } -679 -680 /** -681 * Put or replace a long value. If the index is greater than the length of the -682 * JSONArray, then null elements will be added as necessary to pad it out. -683 * -684 * @param index The subscript. -685 * @param value A long value. -686 * @return this. -687 * @throws JSONException If the index is negative. -688 */ -689 public JSONArray put(int index, long value) throws JSONException { -690 put(index, new Long(value)); -691 return this; -692 } -693 -694 /** -695 * Put a value in the JSONArray, where the value will be a JSONObject which is -696 * produced from a Map. -697 * -698 * @param index The subscript. -699 * @param value The Map value. -700 * @return this. -701 * @throws JSONException If the index is negative or if the the value is an -702 * invalid number. -703 */ -704 public JSONArray put(int index, Map value) throws JSONException { -705 put(index, new JSONObject(value)); -706 return this; -707 } -708 -709 /** -710 * Put or replace an object value in the JSONArray. If the index is greater -711 * than the length of the JSONArray, then null elements will be added as -712 * necessary to pad it out. -713 * -714 * @param index The subscript. -715 * @param value The value to put into the array. The value should be a -716 * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, -717 * or the JSONObject.NULL object. -718 * @return this. -719 * @throws JSONException If the index is negative or if the the value is an -720 * invalid number. -721 */ -722 public JSONArray put(int index, Object value) throws JSONException { -723 JSONObject.testValidity(value); -724 if (index < 0) { -725 throw new JSONException("JSONArray[" + index + "] not found."); -726 } -727 if (index < length()) { -728 this.myArrayList.set(index, value); -729 } else { -730 while (index != length()) { -731 put(JSONObject.NULL); -732 } -733 put(value); -734 } -735 return this; -736 } -737 -738 /** -739 * Remove an index and close the hole. -740 * -741 * @param index The index of the element to be removed. -742 * @return The value that was associated with the index, or null if there was -743 * no value. -744 */ -745 public Object remove(int index) { -746 Object o = opt(index); -747 this.myArrayList.remove(index); -748 return o; -749 } -750 -751 /** -752 * Produce a JSONObject by combining a JSONArray of names with the values of -753 * this JSONArray. -754 * -755 * @param names A JSONArray containing a list of key strings. These will be -756 * paired with the values. -757 * @return A JSONObject, or null if there are no names or if this JSONArray -758 * has no values. -759 * @throws JSONException If any of the names are null. -760 */ -761 public JSONObject toJSONObject(JSONArray names) throws JSONException { -762 if (names == null || names.length() == 0 || length() == 0) { -763 return null; -764 } -765 JSONObject jo = new JSONObject(); -766 for (int i = 0; i < names.length(); i += 1) { -767 jo.put(names.getString(i), this.opt(i)); -768 } -769 return jo; -770 } -771 -772 /** -773 * Make a JSON text of this JSONArray. For compactness, no unnecessary -774 * whitespace is added. If it is not possible to produce a syntactically -775 * correct JSON text then null will be returned instead. This could occur if -776 * the array contains an invalid number. -777 * <p> -778 * Warning: This method assumes that the data structure is acyclical. -779 * -780 * @return a printable, displayable, transmittable representation of the -781 * array. -782 */ -783 @Override -784 public String toString() { -785 try { -786 return '[' + join(",") + ']'; -787 } catch (Exception e) { -788 return null; -789 } -790 } -791 -792 /** -793 * Make a prettyprinted JSON text of this JSONArray. Warning: This method -794 * assumes that the data structure is acyclical. -795 * -796 * @param indentFactor The number of spaces to add to each level of -797 * indentation. -798 * @return a printable, displayable, transmittable representation of the -799 * object, beginning with <code>[</code> <small>(left -800 * bracket)</small> and ending with <code>]</code> <small>(right -801 * bracket)</small>. -802 * @throws JSONException -803 */ -804 public String toString(int indentFactor) throws JSONException { -805 return toString(indentFactor, 0); -806 } -807 -808 /** -809 * Make a prettyprinted JSON text of this JSONArray. Warning: This method -810 * assumes that the data structure is acyclical. -811 * -812 * @param indentFactor The number of spaces to add to each level of -813 * indentation. -814 * @param indent The indention of the top level. -815 * @return a printable, displayable, transmittable representation of the -816 * array. -817 * @throws JSONException -818 */ -819 String toString(int indentFactor, int indent) throws JSONException { -820 int len = length(); -821 if (len == 0) { -822 return "[]"; -823 } -824 int i; -825 StringBuffer sb = new StringBuffer("["); -826 if (len == 1) { -827 sb.append(JSONObject.valueToString(this.myArrayList.get(0), indentFactor, -828 indent)); -829 } else { -830 int newindent = indent + indentFactor; -831 sb.append('\n'); -832 for (i = 0; i < len; i += 1) { -833 if (i > 0) { -834 sb.append(",\n"); -835 } -836 for (int j = 0; j < newindent; j += 1) { -837 sb.append(' '); -838 } -839 sb.append(JSONObject.valueToString(this.myArrayList.get(i), -840 indentFactor, newindent)); -841 } -842 sb.append('\n'); -843 for (i = 0; i < indent; i += 1) { -844 sb.append(' '); -845 } -846 } -847 sb.append(']'); -848 return sb.toString(); -849 } -850 -851 /** -852 * Write the contents of the JSONArray as JSON text to a writer. For -853 * compactness, no whitespace is added. -854 * <p> -855 * Warning: This method assumes that the data structure is acyclical. -856 * -857 * @param writer TODO -858 * -859 * @return The writer. -860 * @throws JSONException -861 */ -862 public Writer write(Writer writer) throws JSONException { -863 try { -864 boolean b = false; -865 int len = length(); -866 -867 writer.write('['); -868 -869 for (int i = 0; i < len; i += 1) { -870 if (b) { -871 writer.write(','); -872 } -873 Object v = this.myArrayList.get(i); -874 if (v instanceof JSONObject) { -875 ((JSONObject) v).write(writer); -876 } else if (v instanceof JSONArray) { -877 ((JSONArray) v).write(writer); -878 } else { -879 writer.write(JSONObject.valueToString(v)); -880 } -881 b = true; -882 } -883 writer.write(']'); -884 return writer; -885 } catch (IOException e) { -886 throw new JSONException(e); -887 } -888 } -889} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001package org.json; -002 -003/** -004 * The JSONException is thrown by the JSON.org classes when things are amiss. -005 * -006 * @author JSON.org -007 * @version 2008-09-18 -008 */ -009public class JSONException extends Exception { -010 /** -011 * -012 */ -013 private static final long serialVersionUID = 0; -014 -015 private Throwable cause; -016 -017 /** -018 * Constructs a JSONException with an explanatory message. -019 * -020 * @param message Detail about the reason for the exception. -021 */ -022 public JSONException(String message) { -023 super(message); -024 } -025 -026 /** -027 * @param t TODO -028 */ -029 public JSONException(Throwable t) { -030 super(t.getMessage()); -031 this.cause = t; -032 } -033 -034 /** -035 * (non-Javadoc) -036 * -037 * @see java.lang.Throwable#getCause() -038 */ -039 @Override -040 public synchronized Throwable getCause() { -041 return this.cause; -042 } -043} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001package org.json; -002 -003/* -004 Copyright (c) 2002 JSON.org -005 -006 Permission is hereby granted, free of charge, to any person obtaining a copy -007 of this software and associated documentation files (the "Software"), to deal -008 in the Software without restriction, including without limitation the rights -009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -010 copies of the Software, and to permit persons to whom the Software is -011 furnished to do so, subject to the following conditions: -012 -013 The above copyright notice and this permission notice shall be included in all -014 copies or substantial portions of the Software. -015 -016 The Software shall be used for Good, not Evil. -017 -018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -024 SOFTWARE. -025 */ -026 -027import java.io.IOException; -028import java.io.Writer; -029import java.lang.reflect.Field; -030import java.lang.reflect.Modifier; -031import java.lang.reflect.Method; -032import java.util.Collection; -033import java.util.HashMap; -034import java.util.Iterator; -035import java.util.Map; -036import java.util.TreeSet; -037 -038/** -039 * A JSONObject is an unordered collection of name/value pairs. Its external -040 * form is a string wrapped in curly braces with colons between the names and -041 * values, and commas between the values and names. The internal form is an -042 * object having <code>get</code> and <code>opt</code> methods for accessing the -043 * values by name, and <code>put</code> methods for adding or replacing values -044 * by name. The values can be any of these types: <code>Boolean</code>, -045 * <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>, -046 * <code>String</code>, or the <code>JSONObject.NULL</code> object. A JSONObject -047 * constructor can be used to convert an external form JSON text into an -048 * internal form whose values can be retrieved with the <code>get</code> and -049 * <code>opt</code> methods, or to convert values into a JSON text using the -050 * <code>put</code> and <code>toString</code> methods. A <code>get</code> method -051 * returns a value if one can be found, and throws an exception if one cannot be -052 * found. An <code>opt</code> method returns a default value instead of throwing -053 * an exception, and so is useful for obtaining optional values. -054 * <p> -055 * The generic <code>get()</code> and <code>opt()</code> methods return an -056 * object, which you can cast or query for type. There are also typed -057 * <code>get</code> and <code>opt</code> methods that do type checking and type -058 * coercion for you. -059 * <p> -060 * The <code>put</code> methods adds values to an object. For example, -061 * -062 * <pre> -063 * myString = new JSONObject().put("JSON", "Hello, World!").toString(); -064 * </pre> -065 * -066 * produces the string <code>{"JSON": "Hello, World"}</code>. -067 * <p> -068 * The texts produced by the <code>toString</code> methods strictly conform to -069 * the JSON syntax rules. The constructors are more forgiving in the texts they -070 * will accept: -071 * <ul> -072 * <li>An extra <code>,</code> <small>(comma)</small> may appear just -073 * before the closing brace.</li> -074 * <li>Strings may be quoted with <code>'</code> <small>(single quote)</small>.</li> -075 * <li>Strings do not need to be quoted at all if they do not begin with a quote -076 * or single quote, and if they do not contain leading or trailing spaces, and -077 * if they do not contain any of these characters: -078 * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and -079 * if they are not the reserved words <code>true</code>, <code>false</code>, or -080 * <code>null</code>.</li> -081 * <li>Keys can be followed by <code>=</code> or <code>=></code> as well as by -082 * <code>:</code>.</li> -083 * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as -084 * well as by <code>,</code> <small>(comma)</small>.</li> -085 * <li>Numbers may have the <code>0-</code> <small>(octal)</small> or <code>0x-</code> -086 * <small>(hex)</small> prefix.</li> -087 * </ul> -088 * -089 * @author JSON.org -090 * @version 2010-01-05 -091 */ -092@SuppressWarnings( { "unchecked", "synthetic-access", "rawtypes","nls" }) -093public class JSONObject { -094 -095 /** -096 * JSONObject.NULL is equivalent to the value that JavaScript calls null, -097 * whilst Java's null is equivalent to the value that JavaScript calls -098 * undefined. -099 */ -100 private static final class Null { -101 -102 /** -103 * There is only intended to be a single instance of the NULL object, so the -104 * clone method returns itself. -105 * -106 * @return NULL. -107 */ -108 @Override -109 protected final Object clone() { -110 return this; -111 } -112 -113 /** -114 * A Null object is equal to the null value and to itself. -115 * -116 * @param object An object to test for nullness. -117 * @return true if the object parameter is the JSONObject.NULL object or -118 * null. -119 */ -120 @Override -121 public boolean equals(Object object) { -122 return object == null || object == this; -123 } -124 -125 /** -126 * Get the "null" string value. -127 * -128 * @return The string "null". -129 */ -130 @Override -131 public String toString() { -132 return "null"; -133 } -134 -135 @Override -136 public int hashCode() { -137 return super.hashCode(); -138 } -139 } -140 -141 /** -142 * The map where the JSONObject's properties are kept. -143 */ -144 private Map map; -145 -146 /** -147 * It is sometimes more convenient and less ambiguous to have a -148 * <code>NULL</code> object than to use Java's <code>null</code> value. -149 * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>. -150 * <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>. -151 */ -152 public static final Object NULL = new Null(); -153 -154 /** -155 * Construct an empty JSONObject. -156 */ -157 public JSONObject() { -158 this.map = new HashMap(); -159 } -160 -161 /** -162 * Construct a JSONObject from a subset of another JSONObject. An array of -163 * strings is used to identify the keys that should be copied. Missing keys -164 * are ignored. -165 * -166 * @param jo A JSONObject. -167 * @param names An array of strings. -168 */ -169 public JSONObject(JSONObject jo, String[] names) { -170 this(); -171 for (int i = 0; i < names.length; i += 1) { -172 try { -173 putOnce(names[i], jo.opt(names[i])); -174 } catch (Exception ignore) { -175 // ?? -176 } -177 } -178 } -179 -180 /** -181 * Construct a JSONObject from a JSONTokener. -182 * -183 * @param x A JSONTokener object containing the source string. -184 * @throws JSONException If there is a syntax error in the source string or a -185 * duplicated key. -186 */ -187 public JSONObject(JSONTokener x) throws JSONException { -188 this(); -189 char c; -190 String key; -191 -192 if (x.nextClean() != '{') { -193 throw x.syntaxError("A JSONObject text must begin with '{'"); -194 } -195 for (;;) { -196 c = x.nextClean(); -197 switch (c) { -198 case 0: -199 throw x.syntaxError("A JSONObject text must end with '}'"); -200 case '}': -201 return; -202 default: -203 x.back(); -204 key = x.nextValue().toString(); -205 } -206 -207 /* -208 * The key is followed by ':'. We will also tolerate '=' or '=>'. -209 */ -210 -211 c = x.nextClean(); -212 if (c == '=') { -213 if (x.next() != '>') { -214 x.back(); -215 } -216 } else if (c != ':') { -217 throw x.syntaxError("Expected a ':' after a key"); -218 } -219 putOnce(key, x.nextValue()); -220 -221 /* -222 * Pairs are separated by ','. We will also tolerate ';'. -223 */ -224 -225 switch (x.nextClean()) { -226 case ';': -227 case ',': -228 if (x.nextClean() == '}') { -229 return; -230 } -231 x.back(); -232 break; -233 case '}': -234 return; -235 default: -236 throw x.syntaxError("Expected a ',' or '}'"); -237 } -238 } -239 } -240 -241 /** -242 * Construct a JSONObject from a Map. -243 * -244 * @param map A map object that can be used to initialize the contents of the -245 * JSONObject. -246 */ -247 public JSONObject(Map map) { -248 this.map = new HashMap(); -249 if (map != null) { -250 Iterator i = map.entrySet().iterator(); -251 while (i.hasNext()) { -252 Map.Entry e = (Map.Entry) i.next(); -253 this.map.put(e.getKey(), wrap(e.getValue())); -254 } -255 } -256 } -257 -258 /** -259 * Construct a JSONObject from an Object using bean getters. It reflects on -260 * all of the public methods of the object. For each of the methods with no -261 * parameters and a name starting with <code>"get"</code> or <code>"is"</code> -262 * followed by an uppercase letter, the method is invoked, and a key and the -263 * value returned from the getter method are put into the new JSONObject. -264 * -265 * The key is formed by removing the <code>"get"</code> or <code>"is"</code> -266 * prefix. If the second remaining character is not upper case, then the first -267 * character is converted to lower case. -268 * -269 * For example, if an object has a method named <code>"getName"</code>, and if -270 * the result of calling <code>object.getName()</code> is -271 * <code>"Larry Fine"</code>, then the JSONObject will contain -272 * <code>"name": "Larry Fine"</code>. -273 * -274 * @param bean An object that has getter methods that should be used to make a -275 * JSONObject. -276 */ -277 public JSONObject(Object bean) { -278 this(); -279 populateMap(bean); -280 } -281 -282 /** -283 * Construct a JSONObject from an Object, using reflection to find the public -284 * members. The resulting JSONObject's keys will be the strings from the names -285 * array, and the values will be the field values associated with those keys -286 * in the object. If a key is not found or not visible, then it will not be -287 * copied into the new JSONObject. -288 * -289 * @param object An object that has fields that should be used to make a -290 * JSONObject. -291 * @param names An array of strings, the names of the fields to be obtained -292 * from the object. -293 */ -294 public JSONObject(Object object, String names[]) { -295 this(); -296 Class c = object.getClass(); -297 for (int i = 0; i < names.length; i += 1) { -298 String name = names[i]; -299 try { -300 putOpt(name, c.getField(name).get(object)); -301 } catch (Exception ignore) { -302 // ?? -303 } -304 } -305 } -306 -307 /** -308 * Construct a JSONObject from a source JSON text string. This is the most -309 * commonly used JSONObject constructor. -310 * -311 * @param source A string beginning with <code>{</code> <small>(left -312 * brace)</small> and ending with <code>}</code> <small>(right -313 * brace)</small>. -314 * @exception JSONException If there is a syntax error in the source string or -315 * a duplicated key. -316 */ -317 public JSONObject(String source) throws JSONException { -318 this(new JSONTokener(source)); -319 } -320 -321 /** -322 * Accumulate values under a key. It is similar to the put method except that -323 * if there is already an object stored under the key then a JSONArray is -324 * stored under the key to hold all of the accumulated values. If there is -325 * already a JSONArray, then the new value is appended to it. In contrast, the -326 * put method replaces the previous value. -327 * -328 * @param key A key string. -329 * @param value An object to be accumulated under the key. -330 * @return this. -331 * @throws JSONException If the value is an invalid number or if the key is -332 * null. -333 */ -334 public JSONObject accumulate(String key, Object value) throws JSONException { -335 testValidity(value); -336 Object o = opt(key); -337 if (o == null) { -338 put(key, value instanceof JSONArray ? new JSONArray().put(value) : value); -339 } else if (o instanceof JSONArray) { -340 ((JSONArray) o).put(value); -341 } else { -342 put(key, new JSONArray().put(o).put(value)); -343 } -344 return this; -345 } -346 -347 /** -348 * Append values to the array under a key. If the key does not exist in the -349 * JSONObject, then the key is put in the JSONObject with its value being a -350 * JSONArray containing the value parameter. If the key was already associated -351 * with a JSONArray, then the value parameter is appended to it. -352 * -353 * @param key A key string. -354 * @param value An object to be accumulated under the key. -355 * @return this. -356 * @throws JSONException If the key is null or if the current value associated -357 * with the key is not a JSONArray. -358 */ -359 public JSONObject append(String key, Object value) throws JSONException { -360 testValidity(value); -361 Object o = opt(key); -362 if (o == null) { -363 put(key, new JSONArray().put(value)); -364 } else if (o instanceof JSONArray) { -365 put(key, ((JSONArray) o).put(value)); -366 } else { -367 throw new JSONException("JSONObject[" + key + "] is not a JSONArray."); -368 } -369 return this; -370 } -371 -372 /** -373 * Produce a string from a double. The string "null" will be returned if the -374 * number is not finite. -375 * -376 * @param d A double. -377 * @return A String. -378 */ -379 static public String doubleToString(double d) { -380 if (Double.isInfinite(d) || Double.isNaN(d)) { -381 return "null"; -382 } -383 -384 // Shave off trailing zeros and decimal point, if possible. -385 -386 String s = Double.toString(d); -387 if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) { -388 while (s.endsWith("0")) { -389 s = s.substring(0, s.length() - 1); -390 } -391 if (s.endsWith(".")) { -392 s = s.substring(0, s.length() - 1); -393 } -394 } -395 return s; -396 } -397 -398 /** -399 * Get the value object associated with a key. -400 * -401 * @param key A key string. -402 * @return The object associated with the key. -403 * @throws JSONException if the key is not found. -404 */ -405 public Object get(String key) throws JSONException { -406 Object o = opt(key); -407 if (o == null) { -408 throw new JSONException("JSONObject[" + quote(key) + "] not found."); -409 } -410 return o; -411 } -412 -413 /** -414 * Get the boolean value associated with a key. -415 * -416 * @param key A key string. -417 * @return The truth. -418 * @throws JSONException if the value is not a Boolean or the String "true" or -419 * "false". -420 */ -421 public boolean getBoolean(String key) throws JSONException { -422 Object o = get(key); -423 if (o.equals(Boolean.FALSE) -424 || (o instanceof String && ((String) o).equalsIgnoreCase("false"))) { -425 return false; -426 } else if (o.equals(Boolean.TRUE) -427 || (o instanceof String && ((String) o).equalsIgnoreCase("true"))) { -428 return true; -429 } -430 throw new JSONException("JSONObject[" + quote(key) + "] is not a Boolean."); -431 } -432 -433 /** -434 * Get the double value associated with a key. -435 * -436 * @param key A key string. -437 * @return The numeric value. -438 * @throws JSONException if the key is not found or if the value is not a -439 * Number object and cannot be converted to a number. -440 */ -441 public double getDouble(String key) throws JSONException { -442 Object o = get(key); -443 try { -444 return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf( -445 (String) o).doubleValue(); -446 } catch (Exception e) { -447 throw new JSONException("JSONObject[" + quote(key) + "] is not a number."); -448 } -449 } -450 -451 /** -452 * Get the int value associated with a key. -453 * -454 * @param key A key string. -455 * @return The integer value. -456 * @throws JSONException if the key is not found or if the value cannot be -457 * converted to an integer. -458 */ -459 public int getInt(String key) throws JSONException { -460 Object o = get(key); -461 try { -462 return o instanceof Number ? ((Number) o).intValue() : Integer -463 .parseInt((String) o); -464 } catch (Exception e) { -465 throw new JSONException("JSONObject[" + quote(key) + "] is not an int."); -466 } -467 } -468 -469 /** -470 * Get the JSONArray value associated with a key. -471 * -472 * @param key A key string. -473 * @return A JSONArray which is the value. -474 * @throws JSONException if the key is not found or if the value is not a -475 * JSONArray. -476 */ -477 public JSONArray getJSONArray(String key) throws JSONException { -478 Object o = get(key); -479 if (o instanceof JSONArray) { -480 return (JSONArray) o; -481 } -482 throw new JSONException("JSONObject[" + quote(key) -483 + "] is not a JSONArray."); -484 } -485 -486 /** -487 * Get the JSONObject value associated with a key. -488 * -489 * @param key A key string. -490 * @return A JSONObject which is the value. -491 * @throws JSONException if the key is not found or if the value is not a -492 * JSONObject. -493 */ -494 public JSONObject getJSONObject(String key) throws JSONException { -495 Object o = get(key); -496 if (o instanceof JSONObject) { -497 return (JSONObject) o; -498 } -499 throw new JSONException("JSONObject[" + quote(key) -500 + "] is not a JSONObject."); -501 } -502 -503 /** -504 * Get the long value associated with a key. -505 * -506 * @param key A key string. -507 * @return The long value. -508 * @throws JSONException if the key is not found or if the value cannot be -509 * converted to a long. -510 */ -511 public long getLong(String key) throws JSONException { -512 Object o = get(key); -513 try { -514 return o instanceof Number ? ((Number) o).longValue() : Long -515 .parseLong((String) o); -516 } catch (Exception e) { -517 throw new JSONException("JSONObject[" + quote(key) + "] is not a long."); -518 } -519 } -520 -521 /** -522 * Get an array of field names from a JSONObject. -523 * -524 * @param jo TODO -525 * -526 * @return An array of field names, or null if there are no names. -527 */ -528 public static String[] getNames(JSONObject jo) { -529 int length = jo.length(); -530 if (length == 0) { -531 return null; -532 } -533 Iterator i = jo.keys(); -534 String[] names = new String[length]; -535 int j = 0; -536 while (i.hasNext()) { -537 names[j] = (String) i.next(); -538 j += 1; -539 } -540 return names; -541 } -542 -543 /** -544 * Get an array of field names from an Object. -545 * -546 * @param object TODO -547 * -548 * @return An array of field names, or null if there are no names. -549 */ -550 public static String[] getNames(Object object) { -551 if (object == null) { -552 return null; -553 } -554 Class klass = object.getClass(); -555 Field[] fields = klass.getFields(); -556 int length = fields.length; -557 if (length == 0) { -558 return null; -559 } -560 String[] names = new String[length]; -561 for (int i = 0; i < length; i += 1) { -562 names[i] = fields[i].getName(); -563 } -564 return names; -565 } -566 -567 /** -568 * Get the string associated with a key. -569 * -570 * @param key A key string. -571 * @return A string which is the value. -572 * @throws JSONException if the key is not found. -573 */ -574 public String getString(String key) throws JSONException { -575 return get(key).toString(); -576 } -577 -578 /** -579 * Determine if the JSONObject contains a specific key. -580 * -581 * @param key A key string. -582 * @return true if the key exists in the JSONObject. -583 */ -584 public boolean has(String key) { -585 return this.map.containsKey(key); -586 } -587 -588 /** -589 * Increment a property of a JSONObject. If there is no such property, create -590 * one with a value of 1. If there is such a property, and if it is an -591 * Integer, Long, Double, or Float, then add one to it. -592 * -593 * @param key A key string. -594 * @return this. -595 * @throws JSONException If there is already a property with this name that is -596 * not an Integer, Long, Double, or Float. -597 */ -598 public JSONObject increment(String key) throws JSONException { -599 Object value = opt(key); -600 if (value == null) { -601 put(key, 1); -602 } else { -603 if (value instanceof Integer) { -604 put(key, ((Integer) value).intValue() + 1); -605 } else if (value instanceof Long) { -606 put(key, ((Long) value).longValue() + 1); -607 } else if (value instanceof Double) { -608 put(key, ((Double) value).doubleValue() + 1); -609 } else if (value instanceof Float) { -610 put(key, ((Float) value).floatValue() + 1); -611 } else { -612 throw new JSONException("Unable to increment [" + key + "]."); -613 } -614 } -615 return this; -616 } -617 -618 /** -619 * Determine if the value associated with the key is null or if there is no -620 * value. -621 * -622 * @param key A key string. -623 * @return true if there is no value associated with the key or if the value -624 * is the JSONObject.NULL object. -625 */ -626 public boolean isNull(String key) { -627 return JSONObject.NULL.equals(opt(key)); -628 } -629 -630 /** -631 * Get an enumeration of the keys of the JSONObject. -632 * -633 * @return An iterator of the keys. -634 */ -635 public Iterator keys() { -636 return this.map.keySet().iterator(); -637 } -638 -639 /** -640 * Get the number of keys stored in the JSONObject. -641 * -642 * @return The number of keys in the JSONObject. -643 */ -644 public int length() { -645 return this.map.size(); -646 } -647 -648 /** -649 * Produce a JSONArray containing the names of the elements of this -650 * JSONObject. -651 * -652 * @return A JSONArray containing the key strings, or null if the JSONObject -653 * is empty. -654 */ -655 public JSONArray names() { -656 JSONArray ja = new JSONArray(); -657 Iterator keys = keys(); -658 while (keys.hasNext()) { -659 ja.put(keys.next()); -660 } -661 return ja.length() == 0 ? null : ja; -662 } -663 -664 /** -665 * Produce a string from a Number. -666 * -667 * @param n A Number -668 * @return A String. -669 * @throws JSONException If n is a non-finite number. -670 */ -671 static public String numberToString(Number n) throws JSONException { -672 if (n == null) { -673 throw new JSONException("Null pointer"); -674 } -675 testValidity(n); -676 -677 // Shave off trailing zeros and decimal point, if possible. -678 -679 String s = n.toString(); -680 if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) { -681 while (s.endsWith("0")) { -682 s = s.substring(0, s.length() - 1); -683 } -684 if (s.endsWith(".")) { -685 s = s.substring(0, s.length() - 1); -686 } -687 } -688 return s; -689 } -690 -691 /** -692 * Get an optional value associated with a key. -693 * -694 * @param key A key string. -695 * @return An object which is the value, or null if there is no value. -696 */ -697 public Object opt(String key) { -698 return key == null ? null : this.map.get(key); -699 } -700 -701 /** -702 * Get an optional boolean associated with a key. It returns false if there is -703 * no such key, or if the value is not Boolean.TRUE or the String "true". -704 * -705 * @param key A key string. -706 * @return The truth. -707 */ -708 public boolean optBoolean(String key) { -709 return optBoolean(key, false); -710 } -711 -712 /** -713 * Get an optional boolean associated with a key. It returns the defaultValue -714 * if there is no such key, or if it is not a Boolean or the String "true" or -715 * "false" (case insensitive). -716 * -717 * @param key A key string. -718 * @param defaultValue The default. -719 * @return The truth. -720 */ -721 public boolean optBoolean(String key, boolean defaultValue) { -722 try { -723 return getBoolean(key); -724 } catch (Exception e) { -725 return defaultValue; -726 } -727 } -728 -729 /** -730 * Get an optional double associated with a key, or NaN if there is no such -731 * key or if its value is not a number. If the value is a string, an attempt -732 * will be made to evaluate it as a number. -733 * -734 * @param key A string which is the key. -735 * @return An object which is the value. -736 */ -737 public double optDouble(String key) { -738 return optDouble(key, Double.NaN); -739 } -740 -741 /** -742 * Get an optional double associated with a key, or the defaultValue if there -743 * is no such key or if its value is not a number. If the value is a string, -744 * an attempt will be made to evaluate it as a number. -745 * -746 * @param key A key string. -747 * @param defaultValue The default. -748 * @return An object which is the value. -749 */ -750 public double optDouble(String key, double defaultValue) { -751 try { -752 Object o = opt(key); -753 return o instanceof Number ? ((Number) o).doubleValue() : new Double( -754 (String) o).doubleValue(); -755 } catch (Exception e) { -756 return defaultValue; -757 } -758 } -759 -760 /** -761 * Get an optional int value associated with a key, or zero if there is no -762 * such key or if the value is not a number. If the value is a string, an -763 * attempt will be made to evaluate it as a number. -764 * -765 * @param key A key string. -766 * @return An object which is the value. -767 */ -768 public int optInt(String key) { -769 return optInt(key, 0); -770 } -771 -772 /** -773 * Get an optional int value associated with a key, or the default if there is -774 * no such key or if the value is not a number. If the value is a string, an -775 * attempt will be made to evaluate it as a number. -776 * -777 * @param key A key string. -778 * @param defaultValue The default. -779 * @return An object which is the value. -780 */ -781 public int optInt(String key, int defaultValue) { -782 try { -783 return getInt(key); -784 } catch (Exception e) { -785 return defaultValue; -786 } -787 } -788 -789 /** -790 * Get an optional JSONArray associated with a key. It returns null if there -791 * is no such key, or if its value is not a JSONArray. -792 * -793 * @param key A key string. -794 * @return A JSONArray which is the value. -795 */ -796 public JSONArray optJSONArray(String key) { -797 Object o = opt(key); -798 return o instanceof JSONArray ? (JSONArray) o : null; -799 } -800 -801 /** -802 * Get an optional JSONObject associated with a key. It returns null if there -803 * is no such key, or if its value is not a JSONObject. -804 * -805 * @param key A key string. -806 * @return A JSONObject which is the value. -807 */ -808 public JSONObject optJSONObject(String key) { -809 Object o = opt(key); -810 return o instanceof JSONObject ? (JSONObject) o : null; -811 } -812 -813 /** -814 * Get an optional long value associated with a key, or zero if there is no -815 * such key or if the value is not a number. If the value is a string, an -816 * attempt will be made to evaluate it as a number. -817 * -818 * @param key A key string. -819 * @return An object which is the value. -820 */ -821 public long optLong(String key) { -822 return optLong(key, 0); -823 } -824 -825 /** -826 * Get an optional long value associated with a key, or the default if there -827 * is no such key or if the value is not a number. If the value is a string, -828 * an attempt will be made to evaluate it as a number. -829 * -830 * @param key A key string. -831 * @param defaultValue The default. -832 * @return An object which is the value. -833 */ -834 public long optLong(String key, long defaultValue) { -835 try { -836 return getLong(key); -837 } catch (Exception e) { -838 return defaultValue; -839 } -840 } -841 -842 /** -843 * Get an optional string associated with a key. It returns an empty string if -844 * there is no such key. If the value is not a string and is not null, then it -845 * is coverted to a string. -846 * -847 * @param key A key string. -848 * @return A string which is the value. -849 */ -850 public String optString(String key) { -851 return optString(key, ""); -852 } -853 -854 /** -855 * Get an optional string associated with a key. It returns the defaultValue -856 * if there is no such key. -857 * -858 * @param key A key string. -859 * @param defaultValue The default. -860 * @return A string which is the value. -861 */ -862 public String optString(String key, String defaultValue) { -863 Object o = opt(key); -864 return o != null ? o.toString() : defaultValue; -865 } -866 -867 private void populateMap(Object bean) { -868 Class klass = bean.getClass(); -869 -870 // If klass is a System class then set includeSuperClass to false. -871 -872 boolean includeSuperClass = klass.getClassLoader() != null; -873 -874 Method[] methods = (includeSuperClass) ? klass.getMethods() : klass -875 .getDeclaredMethods(); -876 for (int i = 0; i < methods.length; i += 1) { -877 try { -878 Method method = methods[i]; -879 if (Modifier.isPublic(method.getModifiers())) { -880 String name = method.getName(); -881 String key = ""; -882 if (name.startsWith("get")) { -883 if (name.equals("getClass") || name.equals("getDeclaringClass")) { -884 key = ""; -885 } else { -886 key = name.substring(3); -887 } -888 } else if (name.startsWith("is")) { -889 key = name.substring(2); -890 } -891 if (key.length() > 0 && Character.isUpperCase(key.charAt(0)) -892 && method.getParameterTypes().length == 0) { -893 if (key.length() == 1) { -894 key = key.toLowerCase(); -895 } else if (!Character.isUpperCase(key.charAt(1))) { -896 key = key.substring(0, 1).toLowerCase() + key.substring(1); -897 } -898 -899 Object result = method.invoke(bean, (Object[]) null); -900 -901 this.map.put(key, wrap(result)); -902 } -903 } -904 } catch (Exception ignore) { -905 // ?? -906 } -907 } -908 } -909 -910 /** -911 * Put a key/boolean pair in the JSONObject. -912 * -913 * @param key A key string. -914 * @param value A boolean which is the value. -915 * @return this. -916 * @throws JSONException If the key is null. -917 */ -918 public JSONObject put(String key, boolean value) throws JSONException { -919 put(key, value ? Boolean.TRUE : Boolean.FALSE); -920 return this; -921 } -922 -923 /** -924 * Put a key/value pair in the JSONObject, where the value will be a JSONArray -925 * which is produced from a Collection. -926 * -927 * @param key A key string. -928 * @param value A Collection value. -929 * @return this. -930 * @throws JSONException -931 */ -932 public JSONObject put(String key, Collection value) throws JSONException { -933 put(key, new JSONArray(value)); -934 return this; -935 } -936 -937 /** -938 * Put a key/double pair in the JSONObject. -939 * -940 * @param key A key string. -941 * @param value A double which is the value. -942 * @return this. -943 * @throws JSONException If the key is null or if the number is invalid. -944 */ -945 public JSONObject put(String key, double value) throws JSONException { -946 put(key, new Double(value)); -947 return this; -948 } -949 -950 /** -951 * Put a key/int pair in the JSONObject. -952 * -953 * @param key A key string. -954 * @param value An int which is the value. -955 * @return this. -956 * @throws JSONException If the key is null. -957 */ -958 public JSONObject put(String key, int value) throws JSONException { -959 put(key, new Integer(value)); -960 return this; -961 } -962 -963 /** -964 * Put a key/long pair in the JSONObject. -965 * -966 * @param key A key string. -967 * @param value A long which is the value. -968 * @return this. -969 * @throws JSONException If the key is null. -970 */ -971 public JSONObject put(String key, long value) throws JSONException { -972 put(key, new Long(value)); -973 return this; -974 } -975 -976 /** -977 * Put a key/value pair in the JSONObject, where the value will be a -978 * JSONObject which is produced from a Map. -979 * -980 * @param key A key string. -981 * @param value A Map value. -982 * @return this. -983 * @throws JSONException -984 */ -985 public JSONObject put(String key, Map value) throws JSONException { -986 put(key, new JSONObject(value)); -987 return this; -988 } -989 -990 /** -991 * Put a key/value pair in the JSONObject. If the value is null, then the key -992 * will be removed from the JSONObject if it is present. -993 * -994 * @param key A key string. -995 * @param value An object which is the value. It should be of one of these -996 * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, -997 * String, or the JSONObject.NULL object. -998 * @return this. -999 * @throws JSONException If the value is non-finite number or if the key is -1000 * null. -1001 */ -1002 public JSONObject put(String key, Object value) throws JSONException { -1003 if (key == null) { -1004 throw new JSONException("Null key."); -1005 } -1006 if (value != null) { -1007 testValidity(value); -1008 this.map.put(key, value); -1009 } else { -1010 remove(key); -1011 } -1012 return this; -1013 } -1014 -1015 /** -1016 * Put a key/value pair in the JSONObject, but only if the key and the value -1017 * are both non-null, and only if there is not already a member with that -1018 * name. -1019 * -1020 * @param key -1021 * @param value -1022 * @return his. -1023 * @throws JSONException if the key is a duplicate -1024 */ -1025 public JSONObject putOnce(String key, Object value) throws JSONException { -1026 if (key != null && value != null) { -1027 if (opt(key) != null) { -1028 throw new JSONException("Duplicate key \"" + key + "\""); -1029 } -1030 put(key, value); -1031 } -1032 return this; -1033 } -1034 -1035 /** -1036 * Put a key/value pair in the JSONObject, but only if the key and the value -1037 * are both non-null. -1038 * -1039 * @param key A key string. -1040 * @param value An object which is the value. It should be of one of these -1041 * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, -1042 * String, or the JSONObject.NULL object. -1043 * @return this. -1044 * @throws JSONException If the value is a non-finite number. -1045 */ -1046 public JSONObject putOpt(String key, Object value) throws JSONException { -1047 if (key != null && value != null) { -1048 put(key, value); -1049 } -1050 return this; -1051 } -1052 -1053 /** -1054 * Produce a string in double quotes with backslash sequences in all the right -1055 * places. A backslash will be inserted within </, allowing JSON text to be -1056 * delivered in HTML. In JSON text, a string cannot contain a control -1057 * character or an unescaped quote or backslash. -1058 * -1059 * @param string A String -1060 * @return A String correctly formatted for insertion in a JSON text. -1061 */ -1062 public static String quote(String string) { -1063 if (string == null || string.length() == 0) { -1064 return "\"\""; -1065 } -1066 -1067 char b; -1068 char c = 0; -1069 int i; -1070 int len = string.length(); -1071 StringBuffer sb = new StringBuffer(len + 4); -1072 String t; -1073 -1074 sb.append('"'); -1075 for (i = 0; i < len; i += 1) { -1076 b = c; -1077 c = string.charAt(i); -1078 switch (c) { -1079 case '\\': -1080 case '"': -1081 sb.append('\\'); -1082 sb.append(c); -1083 break; -1084 case '/': -1085 if (b == '<') { -1086 sb.append('\\'); -1087 } -1088 sb.append(c); -1089 break; -1090 case '\b': -1091 sb.append("\\b"); -1092 break; -1093 case '\t': -1094 sb.append("\\t"); -1095 break; -1096 case '\n': -1097 sb.append("\\n"); -1098 break; -1099 case '\f': -1100 sb.append("\\f"); -1101 break; -1102 case '\r': -1103 sb.append("\\r"); -1104 break; -1105 default: -1106 if (c < ' ' || (c >= '\u0080' && c < '\u00a0') -1107 || (c >= '\u2000' && c < '\u2100')) { -1108 t = "000" + Integer.toHexString(c); -1109 sb.append("\\u" + t.substring(t.length() - 4)); -1110 } else { -1111 sb.append(c); -1112 } -1113 } -1114 } -1115 sb.append('"'); -1116 return sb.toString(); -1117 } -1118 -1119 /** -1120 * Remove a name and its value, if present. -1121 * -1122 * @param key The name to be removed. -1123 * @return The value that was associated with the name, or null if there was -1124 * no value. -1125 */ -1126 public Object remove(String key) { -1127 return this.map.remove(key); -1128 } -1129 -1130 /** -1131 * Get an enumeration of the keys of the JSONObject. The keys will be sorted -1132 * alphabetically. -1133 * -1134 * @return An iterator of the keys. -1135 */ -1136 public Iterator sortedKeys() { -1137 return new TreeSet(this.map.keySet()).iterator(); -1138 } -1139 -1140 /** -1141 * Try to convert a string into a number, boolean, or null. If the string -1142 * can't be converted, return the string. -1143 * -1144 * @param s A String. -1145 * @return A simple JSON value. -1146 */ -1147 static public Object stringToValue(String s) { -1148 if (s.equals("")) { -1149 return s; -1150 } -1151 if (s.equalsIgnoreCase("true")) { -1152 return Boolean.TRUE; -1153 } -1154 if (s.equalsIgnoreCase("false")) { -1155 return Boolean.FALSE; -1156 } -1157 if (s.equalsIgnoreCase("null")) { -1158 return JSONObject.NULL; -1159 } -1160 -1161 /* -1162 * If it might be a number, try converting it. We support the non-standard -1163 * 0x- convention. If a number cannot be produced, then the value will just -1164 * be a string. Note that the 0x-, plus, and implied string conventions are -1165 * non-standard. A JSON parser may accept non-JSON forms as long as it -1166 * accepts all correct JSON forms. -1167 */ -1168 -1169 char b = s.charAt(0); -1170 if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') { -1171 if (b == '0' && s.length() > 2 -1172 && (s.charAt(1) == 'x' || s.charAt(1) == 'X')) { -1173 try { -1174 return new Integer(Integer.parseInt(s.substring(2), 16)); -1175 } catch (Exception ignore) { -1176 // ?? -1177 } -1178 } -1179 try { -1180 if (s.indexOf('.') > -1 || s.indexOf('e') > -1 || s.indexOf('E') > -1) { -1181 return Double.valueOf(s); -1182 } -1183 Long myLong = new Long(s); -1184 if (myLong.longValue() == myLong.intValue()) { -1185 return new Integer(myLong.intValue()); -1186 } -1187 return myLong; -1188 } catch (Exception ignore) { -1189 // ?? -1190 } -1191 } -1192 return s; -1193 } -1194 -1195 /** -1196 * Throw an exception if the object is an NaN or infinite number. -1197 * -1198 * @param o The object to test. -1199 * @throws JSONException If o is a non-finite number. -1200 */ -1201 static void testValidity(Object o) throws JSONException { -1202 if (o != null) { -1203 if (o instanceof Double) { -1204 if (((Double) o).isInfinite() || ((Double) o).isNaN()) { -1205 throw new JSONException("JSON does not allow non-finite numbers."); -1206 } -1207 } else if (o instanceof Float) { -1208 if (((Float) o).isInfinite() || ((Float) o).isNaN()) { -1209 throw new JSONException("JSON does not allow non-finite numbers."); -1210 } -1211 } -1212 } -1213 } -1214 -1215 /** -1216 * Produce a JSONArray containing the values of the members of this -1217 * JSONObject. -1218 * -1219 * @param names A JSONArray containing a list of key strings. This determines -1220 * the sequence of the values in the result. -1221 * @return A JSONArray of values. -1222 * @throws JSONException If any of the values are non-finite numbers. -1223 */ -1224 public JSONArray toJSONArray(JSONArray names) throws JSONException { -1225 if (names == null || names.length() == 0) { -1226 return null; -1227 } -1228 JSONArray ja = new JSONArray(); -1229 for (int i = 0; i < names.length(); i += 1) { -1230 ja.put(this.opt(names.getString(i))); -1231 } -1232 return ja; -1233 } -1234 -1235 /** -1236 * Make a JSON text of this JSONObject. For compactness, no whitespace is -1237 * added. If this would not result in a syntactically correct JSON text, then -1238 * null will be returned instead. -1239 * <p> -1240 * Warning: This method assumes that the data structure is acyclical. -1241 * -1242 * @return a printable, displayable, portable, transmittable representation of -1243 * the object, beginning with <code>{</code> <small>(left -1244 * brace)</small> and ending with <code>}</code> <small>(right -1245 * brace)</small>. -1246 */ -1247 @Override -1248 public String toString() { -1249 try { -1250 Iterator keys = keys(); -1251 StringBuffer sb = new StringBuffer("{"); -1252 -1253 while (keys.hasNext()) { -1254 if (sb.length() > 1) { -1255 sb.append(','); -1256 } -1257 Object o = keys.next(); -1258 sb.append(quote(o.toString())); -1259 sb.append(':'); -1260 sb.append(valueToString(this.map.get(o))); -1261 } -1262 sb.append('}'); -1263 return sb.toString(); -1264 } catch (Exception e) { -1265 return null; -1266 } -1267 } -1268 -1269 /** -1270 * Make a prettyprinted JSON text of this JSONObject. -1271 * <p> -1272 * Warning: This method assumes that the data structure is acyclical. -1273 * -1274 * @param indentFactor The number of spaces to add to each level of -1275 * indentation. -1276 * @return a printable, displayable, portable, transmittable representation of -1277 * the object, beginning with <code>{</code> <small>(left -1278 * brace)</small> and ending with <code>}</code> <small>(right -1279 * brace)</small>. -1280 * @throws JSONException If the object contains an invalid number. -1281 */ -1282 public String toString(int indentFactor) throws JSONException { -1283 return toString(indentFactor, 0); -1284 } -1285 -1286 /** -1287 * Make a prettyprinted JSON text of this JSONObject. -1288 * <p> -1289 * Warning: This method assumes that the data structure is acyclical. -1290 * -1291 * @param indentFactor The number of spaces to add to each level of -1292 * indentation. -1293 * @param indent The indentation of the top level. -1294 * @return a printable, displayable, transmittable representation of the -1295 * object, beginning with <code>{</code> <small>(left -1296 * brace)</small> and ending with <code>}</code> <small>(right -1297 * brace)</small>. -1298 * @throws JSONException If the object contains an invalid number. -1299 */ -1300 String toString(int indentFactor, int indent) throws JSONException { -1301 int j; -1302 int n = length(); -1303 if (n == 0) { -1304 return "{}"; -1305 } -1306 Iterator keys = sortedKeys(); -1307 StringBuffer sb = new StringBuffer("{"); -1308 int newindent = indent + indentFactor; -1309 Object o; -1310 if (n == 1) { -1311 o = keys.next(); -1312 sb.append(quote(o.toString())); -1313 sb.append(": "); -1314 sb.append(valueToString(this.map.get(o), indentFactor, indent)); -1315 } else { -1316 while (keys.hasNext()) { -1317 o = keys.next(); -1318 if (sb.length() > 1) { -1319 sb.append(",\n"); -1320 } else { -1321 sb.append('\n'); -1322 } -1323 for (j = 0; j < newindent; j += 1) { -1324 sb.append(' '); -1325 } -1326 sb.append(quote(o.toString())); -1327 sb.append(": "); -1328 sb.append(valueToString(this.map.get(o), indentFactor, newindent)); -1329 } -1330 if (sb.length() > 1) { -1331 sb.append('\n'); -1332 for (j = 0; j < indent; j += 1) { -1333 sb.append(' '); -1334 } -1335 } -1336 } -1337 sb.append('}'); -1338 return sb.toString(); -1339 } -1340 -1341 /** -1342 * Make a JSON text of an Object value. If the object has an -1343 * value.toJSONString() method, then that method will be used to produce the -1344 * JSON text. The method is required to produce a strictly conforming text. If -1345 * the object does not contain a toJSONString method (which is the most common -1346 * case), then a text will be produced by other means. If the value is an -1347 * array or Collection, then a JSONArray will be made from it and its -1348 * toJSONString method will be called. If the value is a MAP, then a -1349 * JSONObject will be made from it and its toJSONString method will be called. -1350 * Otherwise, the value's toString method will be called, and the result will -1351 * be quoted. -1352 * -1353 * <p> -1354 * Warning: This method assumes that the data structure is acyclical. -1355 * -1356 * @param value The value to be serialized. -1357 * @return a printable, displayable, transmittable representation of the -1358 * object, beginning with <code>{</code> <small>(left -1359 * brace)</small> and ending with <code>}</code> <small>(right -1360 * brace)</small>. -1361 * @throws JSONException If the value is or contains an invalid number. -1362 */ -1363 static String valueToString(Object value) throws JSONException { -1364 if (value == null || value.equals(null)) { -1365 return "null"; -1366 } -1367 if (value instanceof JSONString) { -1368 Object o; -1369 try { -1370 o = ((JSONString) value).toJSONString(); -1371 } catch (Exception e) { -1372 throw new JSONException(e); -1373 } -1374 if (o instanceof String) { -1375 return (String) o; -1376 } -1377 throw new JSONException("Bad value from toJSONString: " + o); -1378 } -1379 if (value instanceof Number) { -1380 return numberToString((Number) value); -1381 } -1382 if (value instanceof Boolean || value instanceof JSONObject -1383 || value instanceof JSONArray) { -1384 return value.toString(); -1385 } -1386 if (value instanceof Map) { -1387 return new JSONObject((Map) value).toString(); -1388 } -1389 if (value instanceof Collection) { -1390 return new JSONArray((Collection) value).toString(); -1391 } -1392 if (value.getClass().isArray()) { -1393 return new JSONArray(value).toString(); -1394 } -1395 return quote(value.toString()); -1396 } -1397 -1398 /** -1399 * Make a prettyprinted JSON text of an object value. -1400 * <p> -1401 * Warning: This method assumes that the data structure is acyclical. -1402 * -1403 * @param value The value to be serialized. -1404 * @param indentFactor The number of spaces to add to each level of -1405 * indentation. -1406 * @param indent The indentation of the top level. -1407 * @return a printable, displayable, transmittable representation of the -1408 * object, beginning with <code>{</code> <small>(left -1409 * brace)</small> and ending with <code>}</code> <small>(right -1410 * brace)</small>. -1411 * @throws JSONException If the object contains an invalid number. -1412 */ -1413 static String valueToString(Object value, int indentFactor, int indent) -1414 throws JSONException { -1415 if (value == null || value.equals(null)) { -1416 return "null"; -1417 } -1418 try { -1419 if (value instanceof JSONString) { -1420 Object o = ((JSONString) value).toJSONString(); -1421 if (o instanceof String) { -1422 return (String) o; -1423 } -1424 } -1425 } catch (Exception ignore) { -1426 // ?? -1427 } -1428 if (value instanceof Number) { -1429 return numberToString((Number) value); -1430 } -1431 if (value instanceof Boolean) { -1432 return value.toString(); -1433 } -1434 if (value instanceof JSONObject) { -1435 return ((JSONObject) value).toString(indentFactor, indent); -1436 } -1437 if (value instanceof JSONArray) { -1438 return ((JSONArray) value).toString(indentFactor, indent); -1439 } -1440 if (value instanceof Map) { -1441 return new JSONObject((Map) value).toString(indentFactor, indent); -1442 } -1443 if (value instanceof Collection) { -1444 return new JSONArray((Collection) value).toString(indentFactor, indent); -1445 } -1446 if (value.getClass().isArray()) { -1447 return new JSONArray(value).toString(indentFactor, indent); -1448 } -1449 return quote(value.toString()); -1450 } -1451 -1452 /** -1453 * Wrap an object, if necessary. If the object is null, return the NULL -1454 * object. If it is an array or collection, wrap it in a JSONArray. If it is a -1455 * map, wrap it in a JSONObject. If it is a standard property (Double, String, -1456 * et al) then it is already wrapped. Otherwise, if it comes from one of the -1457 * java packages, turn it into a string. And if it doesn't, try to wrap it in -1458 * a JSONObject. If the wrapping fails, then null is returned. -1459 * -1460 * @param object The object to wrap -1461 * @return The wrapped value -1462 */ -1463 static Object wrap(Object object) { -1464 try { -1465 if (object == null) { -1466 return NULL; -1467 } -1468 if (object instanceof JSONObject || object instanceof JSONArray -1469 || object instanceof Byte || object instanceof Character -1470 || object instanceof Short || object instanceof Integer -1471 || object instanceof Long || object instanceof Boolean -1472 || object instanceof Float || object instanceof Double -1473 || object instanceof String || NULL.equals(object)) { -1474 return object; -1475 } -1476 -1477 if (object instanceof Collection) { -1478 return new JSONArray((Collection) object); -1479 } -1480 if (object.getClass().isArray()) { -1481 return new JSONArray(object); -1482 } -1483 if (object instanceof Map) { -1484 return new JSONObject((Map) object); -1485 } -1486 Package objectPackage = object.getClass().getPackage(); -1487 String objectPackageName = (objectPackage != null ? objectPackage -1488 .getName() : ""); -1489 if (objectPackageName.startsWith("java.") -1490 || objectPackageName.startsWith("javax.") -1491 || object.getClass().getClassLoader() == null) { -1492 return object.toString(); -1493 } -1494 return new JSONObject(object); -1495 } catch (Exception exception) { -1496 return null; -1497 } -1498 } -1499 -1500 /** -1501 * Write the contents of the JSONObject as JSON text to a writer. For -1502 * compactness, no whitespace is added. -1503 * <p> -1504 * Warning: This method assumes that the data structure is acyclical. -1505 * -1506 * @param writer TODO -1507 * -1508 * @return The writer. -1509 * @throws JSONException -1510 */ -1511 public Writer write(Writer writer) throws JSONException { -1512 try { -1513 boolean b = false; -1514 Iterator keys = keys(); -1515 writer.write('{'); -1516 -1517 while (keys.hasNext()) { -1518 if (b) { -1519 writer.write(','); -1520 } -1521 Object k = keys.next(); -1522 writer.write(quote(k.toString())); -1523 writer.write(':'); -1524 Object v = this.map.get(k); -1525 if (v instanceof JSONObject) { -1526 ((JSONObject) v).write(writer); -1527 } else if (v instanceof JSONArray) { -1528 ((JSONArray) v).write(writer); -1529 } else { -1530 writer.write(valueToString(v)); -1531 } -1532 b = true; -1533 } -1534 writer.write('}'); -1535 return writer; -1536 } catch (IOException exception) { -1537 throw new JSONException(exception); -1538 } -1539 } -1540} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001package org.json; -002 -003/** -004 * The <code>JSONString</code> interface allows a <code>toJSONString()</code> -005 * method so that a class can change the behavior of -006 * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>, and -007 * <code>JSONWriter.value(</code>Object<code>)</code>. The -008 * <code>toJSONString</code> method will be used instead of the default behavior -009 * of using the Object's <code>toString()</code> method and quoting the result. -010 */ -011public interface JSONString { -012 /** -013 * The <code>toJSONString</code> method allows a class to produce its own JSON -014 * serialization. -015 * -016 * @return A strictly syntactically correct JSON text. -017 */ -018 public String toJSONString(); -019} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
001package org.json; -002 -003import java.io.BufferedReader; -004import java.io.IOException; -005import java.io.Reader; -006import java.io.StringReader; -007 -008/* -009 Copyright (c) 2002 JSON.org -010 -011 Permission is hereby granted, free of charge, to any person obtaining a copy -012 of this software and associated documentation files (the "Software"), to deal -013 in the Software without restriction, including without limitation the rights -014 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -015 copies of the Software, and to permit persons to whom the Software is -016 furnished to do so, subject to the following conditions: -017 -018 The above copyright notice and this permission notice shall be included in all -019 copies or substantial portions of the Software. -020 -021 The Software shall be used for Good, not Evil. -022 -023 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -024 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -025 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -026 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -027 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -028 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -029 SOFTWARE. -030 */ -031 -032/** -033 * A JSONTokener takes a source string and extracts characters and tokens from -034 * it. It is used by the JSONObject and JSONArray constructors to parse JSON -035 * source strings. -036 * -037 * @author JSON.org -038 * @version 2010-02-02 -039 */ -040@SuppressWarnings("nls") -041public class JSONTokener { -042 -043 private int character; -044 -045 private boolean eof; -046 -047 private int index; -048 -049 private int line; -050 -051 private char previous; -052 -053 private Reader reader; -054 -055 private boolean usePrevious; -056 -057 /** -058 * Construct a JSONTokener from a reader. -059 * -060 * @param reader A reader. -061 */ -062 public JSONTokener(Reader reader) { -063 this.reader = reader.markSupported() ? reader : new BufferedReader(reader); -064 this.eof = false; -065 this.usePrevious = false; -066 this.previous = 0; -067 this.index = 0; -068 this.character = 1; -069 this.line = 1; -070 } -071 -072 /** -073 * Construct a JSONTokener from a string. -074 * -075 * @param s A source string. -076 */ -077 public JSONTokener(String s) { -078 this(new StringReader(s)); -079 } -080 -081 /** -082 * Back up one character. This provides a sort of lookahead capability, so -083 * that you can test for a digit or letter before attempting to parse the next -084 * number or identifier. -085 * -086 * @throws JSONException -087 */ -088 public void back() throws JSONException { -089 if (this.usePrevious || this.index <= 0) { -090 throw new JSONException("Stepping back two steps is not supported"); -091 } -092 this.index -= 1; -093 this.character -= 1; -094 this.usePrevious = true; -095 this.eof = false; -096 } -097 -098 /** -099 * Get the hex value of a character (base16). -100 * -101 * @param c A character between '0' and '9' or between 'A' and 'F' or between -102 * 'a' and 'f'. -103 * @return An int between 0 and 15, or -1 if c was not a hex digit. -104 */ -105 public static int dehexchar(char c) { -106 if (c >= '0' && c <= '9') { -107 return c - '0'; -108 } -109 if (c >= 'A' && c <= 'F') { -110 return c - ('A' - 10); -111 } -112 if (c >= 'a' && c <= 'f') { -113 return c - ('a' - 10); -114 } -115 return -1; -116 } -117 -118 /** -119 * @return TODO -120 */ -121 public boolean end() { -122 return this.eof && !this.usePrevious; -123 } -124 -125 /** -126 * Determine if the source string still contains characters that next() can -127 * consume. -128 * -129 * @return true if not yet at the end of the source. -130 * @throws JSONException -131 */ -132 public boolean more() throws JSONException { -133 next(); -134 if (end()) { -135 return false; -136 } -137 back(); -138 return true; -139 } -140 -141 /** -142 * Get the next character in the source string. -143 * -144 * @return The next character, or 0 if past the end of the source string. -145 * @throws JSONException -146 */ -147 public char next() throws JSONException { -148 int c; -149 if (this.usePrevious) { -150 this.usePrevious = false; -151 c = this.previous; -152 } else { -153 try { -154 c = this.reader.read(); -155 } catch (IOException exception) { -156 throw new JSONException(exception); -157 } -158 -159 if (c <= 0) { // End of stream -160 this.eof = true; -161 c = 0; -162 } -163 } -164 this.index += 1; -165 if (this.previous == '\r') { -166 this.line += 1; -167 this.character = c == '\n' ? 0 : 1; -168 } else if (c == '\n') { -169 this.line += 1; -170 this.character = 0; -171 } else { -172 this.character += 1; -173 } -174 this.previous = (char) c; -175 return this.previous; -176 } -177 -178 /** -179 * Consume the next character, and check that it matches a specified -180 * character. -181 * -182 * @param c The character to match. -183 * @return The character. -184 * @throws JSONException if the character does not match. -185 */ -186 public char next(char c) throws JSONException { -187 char n = next(); -188 if (n != c) { -189 throw syntaxError("Expected '" + c + "' and instead saw '" + n + "'"); -190 } -191 return n; -192 } -193 -194 /** -195 * Get the next n characters. -196 * -197 * @param n The number of characters to take. -198 * @return A string of n characters. -199 * @throws JSONException Substring bounds error if there are not n characters -200 * remaining in the source string. -201 */ -202 public String next(int n) throws JSONException { -203 if (n == 0) { -204 return ""; -205 } -206 -207 char[] buffer = new char[n]; -208 int pos = 0; -209 -210 while (pos < n) { -211 buffer[pos] = next(); -212 if (end()) { -213 throw syntaxError("Substring bounds error"); -214 } -215 pos += 1; -216 } -217 return new String(buffer); -218 } -219 -220 /** -221 * Get the next char in the string, skipping whitespace. -222 * -223 * @throws JSONException -224 * @return A character, or 0 if there are no more characters. -225 */ -226 public char nextClean() throws JSONException { -227 for (;;) { -228 char c = next(); -229 if (c == 0 || c > ' ') { -230 return c; -231 } -232 } -233 } -234 -235 /** -236 * Return the characters up to the next close quote character. Backslash -237 * processing is done. The formal JSON format does not allow strings in single -238 * quotes, but an implementation is allowed to accept them. -239 * -240 * @param quote The quoting character, either <code>"</code> <small>(double -241 * quote)</small> or <code>'</code> <small>(single quote)</small>. -242 * @return A String. -243 * @throws JSONException Unterminated string. -244 */ -245 public String nextString(char quote) throws JSONException { -246 char c; -247 StringBuffer sb = new StringBuffer(); -248 for (;;) { -249 c = next(); -250 switch (c) { -251 case 0: -252 case '\n': -253 case '\r': -254 throw syntaxError("Unterminated string"); -255 case '\\': -256 c = next(); -257 switch (c) { -258 case 'b': -259 sb.append('\b'); -260 break; -261 case 't': -262 sb.append('\t'); -263 break; -264 case 'n': -265 sb.append('\n'); -266 break; -267 case 'f': -268 sb.append('\f'); -269 break; -270 case 'r': -271 sb.append('\r'); -272 break; -273 case 'u': -274 sb.append((char) Integer.parseInt(next(4), 16)); -275 break; -276 case '"': -277 case '\'': -278 case '\\': -279 case '/': -280 sb.append(c); -281 break; -282 default: -283 throw syntaxError("Illegal escape."); -284 } -285 break; -286 default: -287 if (c == quote) { -288 return sb.toString(); -289 } -290 sb.append(c); -291 } -292 } -293 } -294 -295 /** -296 * Get the text up but not including the specified character or the end of -297 * line, whichever comes first. -298 * -299 * @param d A delimiter character. -300 * @return A string. -301 * @throws JSONException -302 */ -303 public String nextTo(char d) throws JSONException { -304 StringBuffer sb = new StringBuffer(); -305 for (;;) { -306 char c = next(); -307 if (c == d || c == 0 || c == '\n' || c == '\r') { -308 if (c != 0) { -309 back(); -310 } -311 return sb.toString().trim(); -312 } -313 sb.append(c); -314 } -315 } -316 -317 /** -318 * Get the text up but not including one of the specified delimiter characters -319 * or the end of line, whichever comes first. -320 * -321 * @param delimiters A set of delimiter characters. -322 * @return A string, trimmed. -323 * @throws JSONException -324 */ -325 public String nextTo(String delimiters) throws JSONException { -326 char c; -327 StringBuffer sb = new StringBuffer(); -328 for (;;) { -329 c = next(); -330 if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') { -331 if (c != 0) { -332 back(); -333 } -334 return sb.toString().trim(); -335 } -336 sb.append(c); -337 } -338 } -339 -340 /** -341 * Get the next value. The value can be a Boolean, Double, Integer, JSONArray, -342 * JSONObject, Long, or String, or the JSONObject.NULL object. -343 * -344 * @throws JSONException If syntax error. -345 * -346 * @return An object. -347 */ -348 public Object nextValue() throws JSONException { -349 char c = nextClean(); -350 String s; -351 -352 switch (c) { -353 case '"': -354 case '\'': -355 return nextString(c); -356 case '{': -357 back(); -358 return new JSONObject(this); -359 case '[': -360 case '(': -361 back(); -362 return new JSONArray(this); -363 } -364 -365 /* -366 * Handle unquoted text. This could be the values true, false, or null, or -367 * it can be a number. An implementation (such as this one) is allowed to -368 * also accept non-standard forms. -369 * -370 * Accumulate characters until we reach the end of the text or a formatting -371 * character. -372 */ -373 -374 StringBuffer sb = new StringBuffer(); -375 while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { -376 sb.append(c); -377 c = next(); -378 } -379 back(); -380 -381 s = sb.toString().trim(); -382 if (s.equals("")) { -383 throw syntaxError("Missing value"); -384 } -385 return JSONObject.stringToValue(s); -386 } -387 -388 /** -389 * Skip characters until the next character is the requested character. If the -390 * requested character is not found, no characters are skipped. -391 * -392 * @param to A character to skip to. -393 * @return The requested character, or zero if the requested character is not -394 * found. -395 * @throws JSONException -396 */ -397 public char skipTo(char to) throws JSONException { -398 char c; -399 try { -400 int startIndex = this.index; -401 int startCharacter = this.character; -402 int startLine = this.line; -403 this.reader.mark(Integer.MAX_VALUE); -404 do { -405 c = next(); -406 if (c == 0) { -407 this.reader.reset(); -408 this.index = startIndex; -409 this.character = startCharacter; -410 this.line = startLine; -411 return c; -412 } -413 } while (c != to); -414 } catch (IOException exc) { -415 throw new JSONException(exc); -416 } -417 -418 back(); -419 return c; -420 } -421 -422 /** -423 * Make a JSONException to signal a syntax error. -424 * -425 * @param message The error message. -426 * @return A JSONException object, suitable for throwing -427 */ -428 public JSONException syntaxError(String message) { -429 return new JSONException(message + toString()); -430 } -431 -432 /** -433 * Make a printable string of this JSONTokener. -434 * -435 * @return " at {index} [character {character} line {line}]" -436 */ -437 @Override -438 public String toString() { -439 return " at " + this.index + " [character " + this.character + " line " -440 + this.line + "]"; -441 } -442} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
Page
object, that is returned in lists
- *
- * @author Can Bican <can@bican.net>
- *
- */
-public class PageDefinition extends XmlRpcMapped implements StringHeader {
- String page_title;
-
- String page_parent_id;
-
- Date dateCreated;
-
- Date date_created_gmt;
-
- /**
- * @return the page_title
- */
- public String getPage_title() {
- return this.page_title;
- }
-
- /**
- * @param page_title the page_title to set
- */
- public void setPage_title(String page_title) {
- this.page_title = page_title;
- }
-
- /**
- * @return the page_parent_id
- */
- public String getPage_parent_id() {
- return this.page_parent_id;
- }
-
- /**
- * @param page_parent_id the page_parent_id to set
- */
- public void setPage_parent_id(String page_parent_id) {
- this.page_parent_id = page_parent_id;
- }
-
- /**
- * @return the dateCreated
- */
- public Date getDateCreated() {
- return this.dateCreated;
- }
-
- /**
- * @param dateCreated the dateCreated to set
- */
- public void setDateCreated(Date dateCreated) {
- this.dateCreated = dateCreated;
- }
-
- /**
- * @return the date_created_gmt
- */
- public Date getDate_created_gmt() {
- return this.date_created_gmt;
- }
-
- /**
- * @param date_created_gmt the date_created_gmt to set
- */
- public void setDate_created_gmt(Date date_created_gmt) {
- this.date_created_gmt = date_created_gmt;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see net.bican.wordpress.StringHeader#getStringHeader()
- */
- @Override
- @SuppressWarnings("nls")
- public String getStringHeader() {
- final String TAB = ":";
- return "Date Created" + TAB + "Date Created(GMT)" + TAB + "Parent ID" + TAB
- + "Page Title";
- }
-
-}
diff --git a/src/net/bican/wordpress/Ping.java b/src/net/bican/wordpress/Ping.java
deleted file mode 100644
index 9e96b8b..0000000
--- a/src/net/bican/wordpress/Ping.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *
- * Wordpress-java
- * http://code.google.com/p/wordpress-java/
- *
- * Copyright 2012 Can Bican Page
object.
- * @throws XmlRpcFault
- * Generic exception for xml-rpc operations
- */
- @SuppressWarnings("boxing")
- public Page getPage(int pageid) throws XmlRpcFault {
- XmlRpcStruct r = this.wp.getPage(0, pageid, this.username, this.password);
- Page result = new Page();
- result.fromXmlRpcStruct(r);
- return result;
- }
-
- /**
- * @return List of Pages, short format
- * @throws XmlRpcFault
- * Generic exception for xml-rpc operations
- */
- @SuppressWarnings("boxing")
- public List