Reformat of the source

This commit is contained in:
Jaime Martinez Rincon 2017-01-14 12:24:09 +01:00
parent 355bbcf180
commit a3a760ef08
18 changed files with 1142 additions and 1216 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

View File

@ -12,6 +12,11 @@ import java.util.Map;
public class AdapterFix implements ConfigurationAdapter {
private static final Map<String, ServerInfo> fakeServers = new HashMap<>();
private static AdapterFix instance = null;
private final ConfigurationAdapter adapter;
public AdapterFix(ConfigurationAdapter adapter) {
this.adapter = adapter;
}
public static void inject(ProxyServer server) {
if (instance == null) {
@ -32,12 +37,6 @@ public class AdapterFix implements ConfigurationAdapter {
return fakeServers;
}
private final ConfigurationAdapter adapter;
public AdapterFix(ConfigurationAdapter adapter) {
this.adapter = adapter;
}
@Override
public void load() {
adapter.load();

View File

@ -91,8 +91,10 @@ public enum PasteHelper {
}
};
public static final String DEVELOPER_KEY = "e3ff18d8fb001a3ece08ae0d7d4a87bd";
private String link;
private ScheduledTask task = null;
public void send(Plugin plugin, CommandSender sender, String message) {
try {
sender.sendMessage(new ComponentBuilder(message.replace("{link}", link == null ? link = paste(plugin) : link)
@ -115,5 +117,4 @@ public enum PasteHelper {
}
public abstract String paste(Plugin plugin) throws Exception;
public static final String DEVELOPER_KEY = "e3ff18d8fb001a3ece08ae0d7d4a87bd";
}

View File

@ -13,10 +13,10 @@ import static me.jaimemartz.lobbybalancer.LobbyBalancer.printStartupInfo;
public class PingManager {
private final LobbyBalancer plugin;
private final Map<ServerInfo, ServerStatus> storage = new HashMap<>();
private boolean stopped = true;
private PingTacticType tactic;
private ScheduledTask task;
private final Map<ServerInfo, ServerStatus> storage = new HashMap<>();
public PingManager(LobbyBalancer plugin) {
this.plugin = plugin;

View File

@ -3,18 +3,15 @@ package org.jpaste;
import org.jpaste.exceptions.PasteException;
/**
*
* An abstract representation of a paste.
*
* <p>
* <p>
* An abstract paste holds the paste contents and the {@link #paste()}
* operation.
* </p>
*
* @param <P> PasteResult implementation
* @author Brian B
*
* @param <P>
* PasteResult implementation
*/
public abstract class AbstractPaste<P extends AbstractPasteLink> {
private String contents;
@ -22,8 +19,7 @@ public abstract class AbstractPaste<P extends AbstractPasteLink> {
/**
* Creates a new abstract <code>AbstractPaste</code> instance.
*
* @param contents
* the contents of the paste
* @param contents the contents of the paste
*/
public AbstractPaste(String contents) {
this.contents = contents;
@ -41,8 +37,7 @@ public abstract class AbstractPaste<P extends AbstractPasteLink> {
/**
* Sets the paste contents
*
* @param contents
* contents of the paste
* @param contents contents of the paste
*/
public void setContents(String contents) {
this.contents = contents;

View File

@ -3,15 +3,13 @@ package org.jpaste;
import java.net.URL;
/**
*
* An representation of an abstract PasteLink
*
* <p>
* <p>
* An AbstractPasteLink holds the link/URL to a paste.
* </p>
*
* @author Brian B
*
*/
public abstract class AbstractPasteLink {

View File

@ -1,16 +1,14 @@
package org.jpaste.pastebin;
/**
*
* Represents a paste's expire date
*
* <p>
* <p>
* A list of all expire dates/times can be found at the <a
* href="http://pastebin.com/api">pastebin API manual</a>.
* </p>
*
* @author Brian B
*
*/
public enum PasteExpireDate {
NEVER("N", -1), TEN_MINUTES("10M", 10 * 60), ONE_HOUR("1H", 60 * 60), ONE_DAY(
@ -23,29 +21,18 @@ public enum PasteExpireDate {
/**
* Creates a new <code>PasteExpireDate</code> instance.
*
* @param val
* a valid expire date value
* @param val a valid expire date value
*/
PasteExpireDate(String val, int timeSeconds) {
this.val = val;
this.timeSeconds = timeSeconds;
}
/**
* Get's the valid value for the 'api_paste_expire_date' parameter
*
* @return the valid value for the 'api_paste_expire_date' parameter
*/
public String getValue() {
return val;
}
/**
* Gets PasteExpireDate based on: paste expire date minus paste date (in
* seconds)
*
* @param timeSeconds
* seconds between expire date and paste date
* @param timeSeconds seconds between expire date and paste date
* @return PasteExpireDate
*/
public static PasteExpireDate getExpireDate(int timeSeconds) {
@ -57,4 +44,13 @@ public enum PasteExpireDate {
return ONE_MONTH;
}
/**
* Get's the valid value for the 'api_paste_expire_date' parameter
*
* @return the valid value for the 'api_paste_expire_date' parameter
*/
public String getValue() {
return val;
}
}

View File

@ -19,15 +19,13 @@ import java.util.ArrayList;
import java.util.Date;
/**
*
* A global representation of the pastebin site
*
* <p>
* <p>
* Holds various constants and method shortcuts
* </p>
*
* @author Brian B
*
*/
public class Pastebin {
/**
@ -42,8 +40,7 @@ public class Pastebin {
/**
* Fetches a paste text from pastebin
*
* @param pasteKey
* the unique paste key
* @param pasteKey the unique paste key
* @return contents of the paste
*/
public static String getContents(String pasteKey) {
@ -53,14 +50,11 @@ public class Pastebin {
/**
* Generates a paste on pastebin and returns the URL to it
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param contents
* contents of the paste
* @param contents contents of the paste
* @return URL to paste
* @throws PasteException
* if it failed to push the paste
* @throws PasteException if it failed to push the paste
*/
public static URL pastePaste(String developerKey, String contents)
throws PasteException {
@ -70,16 +64,12 @@ public class Pastebin {
/**
* Generates a paste on pastebin and returns the URL to it
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param contents
* contents of the paste
* @param title
* title of the paste
* @param contents contents of the paste
* @param title title of the paste
* @return URL to paste
* @throws PasteException
* if it failed to push the paste
* @throws PasteException if it failed to push the paste
*/
public static URL pastePaste(String developerKey, String contents,
String title) throws PasteException {
@ -89,13 +79,10 @@ public class Pastebin {
/**
* Generates a new paste and returns it
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param contents
* contents of the paste
* @param title
* title of the paste
* @param contents contents of the paste
* @param title title of the paste
* @return a new paste
*/
public static PastebinPaste newPaste(String developerKey, String contents,
@ -108,11 +95,9 @@ public class Pastebin {
/**
* Generates a new paste and returns it
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param contents
* contents of the paste
* @param contents contents of the paste
* @return a new paste
*/
public static PastebinPaste newPaste(String developerKey, String contents) {
@ -122,12 +107,10 @@ public class Pastebin {
/**
* Gets the current trending pastebin pastes
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @return an array of {@link PastebinLink}
* @throws ParseException
* if it failed to parse the trending pastes
* @throws ParseException if it failed to parse the trending pastes
*/
public static PastebinLink[] getTrending(String developerKey)
throws ParseException {

View File

@ -11,16 +11,14 @@ import java.net.URL;
import java.util.Date;
/**
*
* A representation of an online pastebin paste.
*
*
* <p>
* <p>
* <p>
* This class represents an existing pastebin paste URL
* </p>
*
* @author Brian B
*
*/
public class PastebinLink extends AbstractPasteLink {
private PastebinPaste paste;
@ -33,10 +31,8 @@ public class PastebinLink extends AbstractPasteLink {
* Creates a new <code>PastebinLink</code> object, representing an existing
* paste
*
* @param paste
* paste details
* @param url
* link to paste
* @param paste paste details
* @param url link to paste
*/
public PastebinLink(PastebinPaste paste, URL url) {
this(paste, url, new Date((System.currentTimeMillis() / 1000) * 1000));
@ -46,12 +42,9 @@ public class PastebinLink extends AbstractPasteLink {
* Creates a new <code>PastebinLink</code> object, representing an existing
* paste
*
* @param paste
* paste details
* @param url
* link to paste
* @param pasteDate
* date the paste has been pasted
* @param paste paste details
* @param url link to paste
* @param pasteDate date the paste has been pasted
*/
public PastebinLink(PastebinPaste paste, URL url, Date pasteDate) {
this.paste = paste;
@ -64,6 +57,16 @@ public class PastebinLink extends AbstractPasteLink {
}
}
/**
* Fetches a paste text from pastebin
*
* @param pasteKey the unique paste key
* @return contents of the paste
*/
public static String getContents(String pasteKey) {
return Web.getContents("http://pastebin.com/raw.php?i=" + pasteKey);
}
/**
* {@inheritDoc}
*/
@ -83,6 +86,7 @@ public class PastebinLink extends AbstractPasteLink {
/**
* Gets pastebin unique paste key
*
* @return unique paste key
*/
public String getKey() {
@ -101,19 +105,6 @@ public class PastebinLink extends AbstractPasteLink {
getPaste().setContents(getContents(getKey()));
}
/**
* Sets the paste page hits
*
* @param hits
* amount of times paste has been visited
*/
public void setHits(int hits) {
if (hits < 0) {
throw new IllegalArgumentException("Hits must be positive: " + hits);
}
this.hits = hits;
}
/**
* Gets the paste page hits
*
@ -123,6 +114,18 @@ public class PastebinLink extends AbstractPasteLink {
return this.hits;
}
/**
* Sets the paste page hits
*
* @param hits amount of times paste has been visited
*/
public void setHits(int hits) {
if (hits < 0) {
throw new IllegalArgumentException("Hits must be positive: " + hits);
}
this.hits = hits;
}
/**
* Gets the paste date
*
@ -135,10 +138,8 @@ public class PastebinLink extends AbstractPasteLink {
/**
* Deletes this paste
*
* @param account
* the account which was used to create this paste
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param account the account which was used to create this paste
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @throws PasteException if it failed to delete the paste
*/
@ -164,21 +165,11 @@ public class PastebinLink extends AbstractPasteLink {
/**
* Deletes this paste
*
* @throws PasteException if it failed to delete the paste
*/
public void delete() throws PasteException {
delete(getPaste().getDeveloperKey(), getPaste().getAccount());
}
/**
* Fetches a paste text from pastebin
*
* @param pasteKey
* the unique paste key
* @return contents of the paste
*/
public static String getContents(String pasteKey) {
return Web.getContents("http://pastebin.com/raw.php?i=" + pasteKey);
}
}

View File

@ -10,22 +10,20 @@ import java.net.MalformedURLException;
import java.net.URL;
/**
*
* A representation of a new or existing paste.
*
* <p>
* <p>
* This class holds the contents of the paste itself. You can get and modify
* settings and then 'push' this paste onto <a
* href="http://pastebin.com/">pastebin.</a>
* </p>
*
* <p>
* <p>
* This class has been programmed with the help of the <a
* href="http://pastebin.com/api/">pastebin API manual.</a>
* </p>
*
* @author Brian B
*
*/
public class PastebinPaste extends AbstractPaste<PastebinLink> {
/**
@ -61,8 +59,7 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
/**
* Creates a new <code>PastebinPaste</code> instance.
*
* @param contents
* the paste contents
* @param contents the paste contents
*/
public PastebinPaste(String contents) {
this(null, contents, null);
@ -71,8 +68,7 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
/**
* Creates a new <code>PastebinPaste</code> instance.
*
* @param account
* a pastebin account
* @param account a pastebin account
*/
public PastebinPaste(PastebinAccount account) {
this(account.getDeveloperKey(), null, account);
@ -81,11 +77,9 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
/**
* Creates a new <code>PastebinPaste</code> instance.
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param contents
* the contents of the paste
* @param contents the contents of the paste
*/
public PastebinPaste(String developerKey, String contents) {
this(developerKey, contents, null);
@ -94,13 +88,10 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
/**
* Creates a new <code>PastebinPaste</code> instance.
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param contents
* the contents of the paste
* @param account
* a pastebin account
* @param contents the contents of the paste
* @param account a pastebin account
*/
public PastebinPaste(String developerKey, String contents,
PastebinAccount account) {
@ -109,17 +100,6 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
this.account = account;
}
/**
* Sets the pastebin account If you set an account the pastes will be listed
* on your account.
*
* @param account
* a pastebin account
*/
public void setAccount(PastebinAccount account) {
this.account = account;
}
/**
* Gets the pastebin account
*
@ -130,29 +110,13 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
}
/**
* Sets the developer key The developer key is required to paste contents on
* pastebin
* Sets the pastebin account If you set an account the pastes will be listed
* on your account.
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* page
* @param account a pastebin account
*/
public void setDeveloperKey(String developerKey) {
if (developerKey == null || developerKey.isEmpty()) {
throw new IllegalArgumentException(
"Developer key can not be null or empty.");
}
this.developerKey = developerKey;
}
/**
* Sets the paste expire date
*
* @param date
* date when the paste will be removed
*/
public void setPasteExpireDate(PasteExpireDate date) {
this.expireDate = date;
public void setAccount(PastebinAccount account) {
this.account = account;
}
/**
@ -165,13 +129,18 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
}
/**
* Sets the paste title
* Sets the developer key The developer key is required to paste contents on
* pastebin
*
* @param title
* title of the paste
* @param developerKey a developer key which can be fetched from the pastebin API
* page
*/
public void setPasteTitle(String title) {
this.pasteTitle = title;
public void setDeveloperKey(String developerKey) {
if (developerKey == null || developerKey.isEmpty()) {
throw new IllegalArgumentException(
"Developer key can not be null or empty.");
}
this.developerKey = developerKey;
}
/**
@ -183,8 +152,18 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
return this.pasteTitle;
}
/**
* Sets the paste title
*
* @param title title of the paste
*/
public void setPasteTitle(String title) {
this.pasteTitle = title;
}
/**
* Gets paste expire date
*
* @return paste expire date
*/
public PasteExpireDate getPasteExpireDate() {
@ -192,15 +171,12 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
}
/**
* Sets the paste format The format is used for syntax highlighting
* Sets the paste expire date
*
* @see <a href="http://pastebin.com/api#5">available syntax highlighting
* formats</a>
* @param format
* format of the paste
* @param date date when the paste will be removed
*/
public void setPasteFormat(String format) {
this.pasteFormat = format;
public void setPasteExpireDate(PasteExpireDate date) {
this.expireDate = date;
}
/**
@ -213,29 +189,14 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
}
/**
* Makes this paste private, unlisted or public Default visibility is public
* <p>
* <strong>Valid visibilities</strong>
* </p>
* <p>
* {@link PastebinPaste#VISIBILITY_PUBLIC}
* </p>
* <p>
* {@link PastebinPaste#VISIBILITY_UNLISTED}
* </p>
* <p>
* {@link PastebinPaste#VISIBILITY_PRIVATE}
* </p>
* Sets the paste format The format is used for syntax highlighting
*
* @param visibility
* the paste it's visibility
* @param format format of the paste
* @see <a href="http://pastebin.com/api#5">available syntax highlighting
* formats</a>
*/
public void setVisibility(int visibility) {
if (visibility < 0 || visibility > 2) {
throw new IllegalArgumentException("Unknown visibility: "
+ visibility);
}
this.visibility = visibility;
public void setPasteFormat(String format) {
this.pasteFormat = format;
}
/**
@ -259,6 +220,31 @@ public class PastebinPaste extends AbstractPaste<PastebinLink> {
return this.visibility;
}
/**
* Makes this paste private, unlisted or public Default visibility is public
* <p>
* <strong>Valid visibilities</strong>
* </p>
* <p>
* {@link PastebinPaste#VISIBILITY_PUBLIC}
* </p>
* <p>
* {@link PastebinPaste#VISIBILITY_UNLISTED}
* </p>
* <p>
* {@link PastebinPaste#VISIBILITY_PRIVATE}
* </p>
*
* @param visibility the paste it's visibility
*/
public void setVisibility(int visibility) {
if (visibility < 0 || visibility > 2) {
throw new IllegalArgumentException("Unknown visibility: "
+ visibility);
}
this.visibility = visibility;
}
/**
* {@inheritDoc}
*/

View File

@ -23,21 +23,19 @@ import java.util.ArrayList;
import java.util.Date;
/**
*
* Represents an account on <a href="http://pastebin.com/">Pastebin</a>.
*
* <p>
* <p>
* This class can fetch a non-expiring user session id. This session id is used
* for generating private pasted, fetching user details, fetching user his
* pastes, adding pastes to his account & more account based interactions.
* </p>
*
* <p>
* <p>
* A reference manual for generating a user session id can be found <a
* href="http://pastebin.com/api#8">here</a>.
*
* @author Brian B
*
*/
public class PastebinAccount {
private String username, password, userSessionId, developerKey;
@ -51,17 +49,14 @@ public class PastebinAccount {
/**
* Creates a new <code>PastebinAccount</code> instance.
*
* <p>
* When you use this constructor, you'll need to use the {@link #login()} to
* fetch an user session id
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param username
* the username of the pastebin account
* @param password
* the password of the pastebin account
* @param username the username of the pastebin account
* @param password the password of the pastebin account
*/
public PastebinAccount(String developerKey, String username, String password) {
this.developerKey = developerKey;
@ -72,8 +67,7 @@ public class PastebinAccount {
/**
* Creates a new <code>PastebinAccount</code> instance.
*
* @param userSessionId
* the user session id of the pastebin account.
* @param userSessionId the user session id of the pastebin account.
*/
public PastebinAccount(String userSessionId) {
this(null, userSessionId);
@ -82,28 +76,15 @@ public class PastebinAccount {
/**
* Creates a new <code>PastebinAccount</code> instance.
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* @param developerKey a developer key which can be fetched from the pastebin API
* page
* @param userSessionId
* the user session id of the pastebin account.
* @param userSessionId the user session id of the pastebin account.
*/
public PastebinAccount(String developerKey, String userSessionId) {
this.developerKey = developerKey;
this.userSessionId = userSessionId;
}
/**
* Sets the user session id The user session id can be used to paste private
* pastes and will add pastes to your account
*
* @param userSessionId
* the user session id of the pastebin account
*/
public void setUserSessionId(String userSessionId) {
this.userSessionId = userSessionId;
}
/**
* Gets the user session id
*
@ -114,13 +95,13 @@ public class PastebinAccount {
}
/**
* Sets the username
* Sets the user session id The user session id can be used to paste private
* pastes and will add pastes to your account
*
* @param username
* the username of the pastebin account
* @param userSessionId the user session id of the pastebin account
*/
public void setUsername(String username) {
this.username = username;
public void setUserSessionId(String userSessionId) {
this.userSessionId = userSessionId;
}
/**
@ -134,13 +115,12 @@ public class PastebinAccount {
}
/**
* Sets the password
* Sets the username
*
* @param password
* the password of the pastebin account
* @param username the username of the pastebin account
*/
public void setPassword(String password) {
this.password = password;
public void setUsername(String username) {
this.username = username;
}
/**
@ -154,19 +134,12 @@ public class PastebinAccount {
}
/**
* Sets the developer key The developer key is required to paste contents on
* pastebin
* Sets the password
*
* @param developerKey
* a developer key which can be fetched from the pastebin API
* page
* @param password the password of the pastebin account
*/
public void setDeveloperKey(String developerKey) {
if (developerKey == null || developerKey.isEmpty()) {
throw new IllegalArgumentException(
"Developer key can not be null or empty.");
}
this.developerKey = developerKey;
public void setPassword(String password) {
this.password = password;
}
/**
@ -178,11 +151,25 @@ public class PastebinAccount {
return this.developerKey;
}
/**
* Sets the developer key The developer key is required to paste contents on
* pastebin
*
* @param developerKey a developer key which can be fetched from the pastebin API
* page
*/
public void setDeveloperKey(String developerKey) {
if (developerKey == null || developerKey.isEmpty()) {
throw new IllegalArgumentException(
"Developer key can not be null or empty.");
}
this.developerKey = developerKey;
}
/**
* Fetches an user session id.
*
* @throws LoginException
* if fetching the user session id failed
* @throws LoginException if fetching the user session id failed
*/
public void login() throws LoginException {
if (getUserSessionId() != null) {
@ -215,14 +202,12 @@ public class PastebinAccount {
/**
* Gets all pasted pastes by this user
*
* @param limit
* maximum amount of pastes to receive
* @param limit maximum amount of pastes to receive
* <p>
* <code>0 > limit > 1000</code>
* </p>
* @return all pasted pastes made by this user/account
* @throws ParseException
* if it failed to parse the pastes
* @throws ParseException if it failed to parse the pastes
*/
public PastebinLink[] getPastes(int limit) throws ParseException {
if (limit > 1000) {
@ -317,8 +302,7 @@ public class PastebinAccount {
* Gets pasted pastes (max 50) by this user
*
* @return all pasted pastes made by this user/account
* @throws ParseException
* if it failed to parse the pastes
* @throws ParseException if it failed to parse the pastes
*/
public PastebinLink[] getPastes() throws ParseException {
return getPastes(50);
@ -328,8 +312,7 @@ public class PastebinAccount {
* Fetches the account details of this account
*
* @return account details
* @throws ParseException
* if it failed to parse the account details
* @throws ParseException if it failed to parse the account details
*/
public PastebinAccountDetails getAccountDetails() throws ParseException {
if (getUserSessionId() == null) {

View File

@ -10,11 +10,9 @@ import java.net.MalformedURLException;
import java.net.URL;
/**
*
* Holds information and settings of a pastebin account.
*
* @author Brian B
*
*/
public class PastebinAccountDetails {
private String username, format, expiration, avatarURL, website, email, location;
@ -23,8 +21,7 @@ public class PastebinAccountDetails {
/**
* Creates a new <code>PastebinAccountDetails</code> instance.
*
* @param userElement
* the 'user' xml elements received from the pastebin API
* @param userElement the 'user' xml elements received from the pastebin API
*/
public PastebinAccountDetails(Element userElement) {
this.username = XMLUtils.getText(userElement, "user_name");
@ -40,6 +37,7 @@ public class PastebinAccountDetails {
/**
* Gets the username of this account
*
* @return username
*/
public String getUsername() {
@ -48,6 +46,7 @@ public class PastebinAccountDetails {
/**
* Gets user text format
*
* @return user text format
*/
public String getFormat() {
@ -59,6 +58,7 @@ public class PastebinAccountDetails {
* <p>
* <code>N = never (default)</code>
* </p>
*
* @return account expiration time
*/
public String getExpiration() {
@ -67,6 +67,7 @@ public class PastebinAccountDetails {
/**
* Gets URL to avatar image
*
* @return URL to avatar image
* @throws MalformedURLException
*/
@ -81,6 +82,7 @@ public class PastebinAccountDetails {
* 1 = unlisted
* 2 = private
* </pre>
*
* @return visibility of account
*/
public int getPrivate() {
@ -89,6 +91,7 @@ public class PastebinAccountDetails {
/**
* Gets the user's set website
*
* @return url to website
* @throws MalformedURLException
*/
@ -101,6 +104,7 @@ public class PastebinAccountDetails {
/**
* Gets the user e-mail
*
* @return user account e-mail
*/
public String getEmail() {
@ -109,6 +113,7 @@ public class PastebinAccountDetails {
/**
* Gets the user's set location
*
* @return location, city
*/
public String getLocation() {
@ -117,6 +122,7 @@ public class PastebinAccountDetails {
/**
* Determines if this account is a 'pro' account
*
* @return <code>true</code> if this account is a pro account, otherwise <code>false</code>.
*/
public boolean isPro() {
@ -125,6 +131,7 @@ public class PastebinAccountDetails {
/**
* Fetches the user his avatar from {@link #getAvatarURL()}
*
* @return image
* @throws IOException if image was not read
*/

View File

@ -6,19 +6,17 @@ import java.util.HashMap;
import java.util.Map.Entry;
/**
*
* A representation of a HTTP post
*
* <p>
* <p>
* Encodes parameters with the UTF-8 Charset.
* </p>
*
* <p>
* <p>
* <a href="http://en.wikipedia.org/wiki/POST_(HTTP)">Reference manual</a>
* </p>
*
* @author Brian B
*
*/
public class Post {
private static final String ENCODING = "UTF-8";
@ -34,10 +32,8 @@ public class Post {
/**
* Adds a key value pair to the post parameters
*
* @param key
* the key
* @param value
* the value
* @param key the key
* @param value the value
*/
public void put(String key, String value) {
try {

View File

@ -9,21 +9,17 @@ import java.net.URL;
import java.net.URLConnection;
/**
*
* Web utility class
*
* @author Brian B
*
*/
public class Web {
/**
* Submits a HTTP post and fetches and returns the response
*
* @param link
* The link/URL
* @param post
* the HTTP post representation
* @param link The link/URL
* @param post the HTTP post representation
* @return response of the web page
*/
public static String getContents(String link, Post post) {
@ -64,8 +60,7 @@ public class Web {
/**
* Gets text from a link
*
* @param link
* The link/URL
* @param link The link/URL
* @return response of the web page
*/
public static String getContents(String link) {

View File

@ -3,21 +3,17 @@ package org.jpaste.utils.xml;
import org.w3c.dom.Element;
/**
*
* Holds various XML utility methods
*
* @author Brian B
*
*/
public class XMLUtils {
/**
* Fetches text from a element
*
* @param parent
* the parent of the element you want to fetch text from
* @param tagName
* name of the element you want to fetch text from
* @param parent the parent of the element you want to fetch text from
* @param tagName name of the element you want to fetch text from
* @return text of tag
*/
public static String getText(Element parent, String tagName) {