* The text to encode
* @return The encoded text
*/
- protected String encodeString(String text) {
+ protected static String encodeString(String text) {
return text.replaceAll("\\\\", "\\\\").replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r");
}
* such as if the Sone is followed by the local Sone
* @return The simple field set containing the given Sone
*/
- protected SimpleFieldSet encodeSone(Sone sone, String prefix, Sone localSone) {
+ protected static SimpleFieldSet encodeSone(Sone sone, String prefix, Sone localSone) {
SimpleFieldSetBuilder soneBuilder = new SimpleFieldSetBuilder();
soneBuilder.put(prefix + "Name", sone.getName());
* {@code null})
* @return The simple field set containing the given Sones
*/
- protected SimpleFieldSet encodeSones(Collection<? extends Sone> sones, String prefix) {
+ protected static SimpleFieldSet encodeSones(Collection<? extends Sone> sones, String prefix) {
SimpleFieldSetBuilder soneBuilder = new SimpleFieldSetBuilder();
int soneIndex = 0;
* {@code null})
* @return The simple field set containing the replies
*/
- protected SimpleFieldSet encodeReplies(Collection<? extends PostReply> replies, String prefix) {
+ protected static SimpleFieldSet encodeReplies(Collection<? extends PostReply> replies, String prefix) {
SimpleFieldSetBuilder replyBuilder = new SimpleFieldSetBuilder();
int replyIndex = 0;
* {@code null})
* @return The simple field set containing the likes
*/
- protected SimpleFieldSet encodeLikes(Collection<? extends Sone> likes, String prefix) {
+ protected static SimpleFieldSet encodeLikes(Collection<? extends Sone> likes, String prefix) {
SimpleFieldSetBuilder likesBuilder = new SimpleFieldSetBuilder();
int likeIndex = 0;
* @throws PluginNotFoundException
* if the plugin can not be found
*/
- private void sendReply(PluginReplySender pluginReplySender, String identifier, Response response) throws PluginNotFoundException {
+ private static void sendReply(PluginReplySender pluginReplySender, String identifier, Response response) throws PluginNotFoundException {
SimpleFieldSet replyParameters = response.getReplyParameters();
if (identifier != null) {
replyParameters.putOverwrite("Identifier", identifier);
* if there is no value for the given key in the simple field
* set, or the value can not be converted to a String
*/
- protected String getString(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
+ protected static String getString(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
try {
return simpleFieldSet.getString(key);
} catch (FSParseException fspe1) {
* if there is no value for the given key in the simple field
* set, or the value can not be converted to an int
*/
- protected int getInt(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
+ protected static int getInt(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
try {
return simpleFieldSet.getInt(key);
} catch (FSParseException fspe1) {
* The default value
* @return The int value
*/
- protected int getInt(SimpleFieldSet simpleFieldSet, String key, int defaultValue) {
+ protected static int getInt(SimpleFieldSet simpleFieldSet, String key, int defaultValue) {
return simpleFieldSet.getInt(key, defaultValue);
}
* if there is no value for the given key in the simple field
* set, or the value can not be converted to a boolean
*/
- protected boolean getBoolean(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
+ protected static boolean getBoolean(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
try {
return simpleFieldSet.getBoolean(key);
} catch (FSParseException fspe1) {
* The default value
* @return The boolean value
*/
- protected boolean getBoolean(SimpleFieldSet simpleFieldSet, String key, boolean defaultValue) {
+ protected static boolean getBoolean(SimpleFieldSet simpleFieldSet, String key, boolean defaultValue) {
return simpleFieldSet.getBoolean(key, defaultValue);
}
* The name of the link
* @return The created map containing the mappings
*/
- private Map<String, String> createLink(String target, String name) {
+ private static Map<String, String> createLink(String target, String name) {
Map<String, String> link = new HashMap<String, String>();
link.put("target", target);
link.put("name", name);
* append to the nickname
* @return The nickname with optional ID appendage
*/
- private String getAbbreviatedNickname(Identity identity, int length) {
+ private static String getAbbreviatedNickname(Identity identity, int length) {
return identity.getNickname() + ((length > 0) ? "@" + identity.getId().substring(0, length) : "");
}
* @return The parsed ID, or {@code null} if there was no part matching the
* given string
*/
- private String getFieldId(FreenetRequest request, String partNameStart) {
+ private static String getFieldId(FreenetRequest request, String partNameStart) {
for (String partName : request.getHttpRequest().getParts()) {
if (partName.startsWith(partNameStart)) {
return partName.substring(partNameStart.length());
* The string generator for the objects
* @return The hits for the given phrases
*/
- private <T> Set<Hit<T>> getHits(Collection<T> objects, List<Phrase> phrases, StringGenerator<T> stringGenerator) {
+ private static <T> Set<Hit<T>> getHits(Collection<T> objects, List<Phrase> phrases, StringGenerator<T> stringGenerator) {
Set<Hit<T>> hits = new HashSet<Hit<T>>();
for (T object : objects) {
String objectString = stringGenerator.generateString(object);
* The query to parse
* @return The parsed phrases
*/
- private List<Phrase> parseSearchPhrases(String query) {
+ private static List<Phrase> parseSearchPhrases(String query) {
List<String> parsedPhrases = null;
try {
parsedPhrases = StringEscaper.parseLine(query);
* The expression to search
* @return The score of the expression
*/
- private double calculateScore(List<Phrase> phrases, String expression) {
+ private static double calculateScore(List<Phrase> phrases, String expression) {
logger.log(Level.FINEST, String.format("Calculating Score for “%s”…", expression));
double optionalHits = 0;
double requiredHits = 0;
* @return The MIME type of the image, or “application/octet-stream” if the
* image type could not be detected
*/
- private String getMimeType(byte[] imageData) {
+ private static String getMimeType(byte[] imageData) {
ByteArrayInputStream imageDataInputStream = new ByteArrayInputStream(imageData);
try {
ImageInputStream imageInputStream = ImageIO.createImageInputStream(imageDataInputStream);
* The Sones to convert to an array
* @return The Sones, sorted by name
*/
- private JsonArray getSones(Set<Sone> sones) {
+ private static JsonArray getSones(Set<Sone> sones) {
JsonArray soneArray = new JsonArray();
List<Sone> sortedSones = new ArrayList<Sone>(sones);
Collections.sort(sortedSones, Sone.NICE_NAME_COMPARATOR);
* The current Sone (may be {@code null})
* @return The current options
*/
- private JsonObject createJsonOptions(Sone currentSone) {
+ private static JsonObject createJsonOptions(Sone currentSone) {
JsonObject options = new JsonObject();
if (currentSone != null) {
options.put("ShowNotification/NewSones", currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").get());
* The current Sone (may be {@code null})
* @return The current options
*/
- private JsonObject createJsonOptions(Sone currentSone) {
+ private static JsonObject createJsonOptions(Sone currentSone) {
JsonObject options = new JsonObject();
if (currentSone != null) {
options.put("ShowNotification/NewSones", currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").get());
*
* @return A reply signaling success
*/
- protected JsonObject createSuccessJsonObject() {
+ protected static JsonObject createSuccessJsonObject() {
return new JsonObject().put("success", true);
}
* The error that has occured
* @return The JSON object, signalling failure and the error code
*/
- protected JsonObject createErrorJsonObject(String error) {
+ protected static JsonObject createErrorJsonObject(String error) {
return new JsonObject().put("success", false).put("error", error);
}