package net.pterodactylus.sone.text;
/**
- * TODO
+ * {@link LinkPart} implementation that stores an additional attribute: if the
+ * link is an SSK or USK link and the post was created by an identity that owns
+ * the keyspace in question.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class FreenetLinkPart extends LinkPart {
+ /** Whether the link is trusted. */
private final boolean trusted;
+ /**
+ * Creates a new freenet link part.
+ *
+ * @param link
+ * The link of the part
+ * @param text
+ * The text of the part
+ * @param trusted
+ * {@code true} if the link is trusted, {@code false} otherwise
+ */
public FreenetLinkPart(String link, String text, boolean trusted) {
this(link, text, text, trusted);
}
+ /**
+ * Creates a new freenet link part.
+ *
+ * @param link
+ * The link of the part
+ * @param text
+ * The text of the part
+ * @param title
+ * The title of the part
+ * @param trusted
+ * {@code true} if the link is trusted, {@code false} otherwise
+ */
public FreenetLinkPart(String link, String text, String title, boolean trusted) {
super(link, text, title);
this.trusted = trusted;
}
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns whether the link is trusted.
+ *
+ * @return {@code true} if the link is trusted, {@code false} otherwise
+ */
public boolean isTrusted() {
return trusted;
}
package net.pterodactylus.sone.text;
/**
- * TODO
+ * {@link Part} implementation that can hold a link. A link contains of three
+ * attributes: the link itself, the text that is shown instead of the link, and
+ * an explanatory text that can be displayed e.g. as a tooltip.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class LinkPart implements Part {
+ /** The link of this part. */
private final String link;
+
+ /** The text of this part. */
private final String text;
+
+ /** The title of this part. */
private final String title;
+ /**
+ * Creates a new link part.
+ *
+ * @param link
+ * The link of the link part
+ * @param text
+ * The text of the link part
+ */
public LinkPart(String link, String text) {
this(link, text, text);
}
+ /**
+ * Creates a new link part.
+ *
+ * @param link
+ * The link of the link part
+ * @param text
+ * The text of the link part
+ * @param title
+ * The title of the link part
+ */
public LinkPart(String link, String text, String title) {
this.link = link;
this.text = text;
// ACCESSORS
//
+ /**
+ * Returns the link of this part.
+ *
+ * @return The link of this part
+ */
public String getLink() {
return link;
}
+ /**
+ * Returns the text of this part.
+ *
+ * @return The text of this part
+ */
public String getText() {
return text;
}
+ /**
+ * Returns the title of this part.
+ *
+ * @return The title of this part
+ */
public String getTitle() {
return title;
}
package net.pterodactylus.sone.text;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Iterator;
-
-import net.pterodactylus.util.collection.ObjectIterator;
-
/**
- * TODO
+ * {@link Part} implementation that holds a single piece of text.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class PlainTextPart implements Part {
+ /** The text of the part. */
private final String text;
+ /**
+ * Creates a new plain-text part.
+ *
+ * @param text
+ * The text of the part
+ */
public PlainTextPart(String text) {
this.text = text;
}
// ACCESSORS
//
+ /**
+ * Returns the text of this part.
+ *
+ * @return The text of this part
+ */
public String getText() {
return text;
}
import net.pterodactylus.sone.data.Post;
/**
- * TODO
+ * {@link Part} implementation that stores a reference to a {@link Post}.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class PostPart implements Part {
+ /** The post this part refers to. */
private final Post post;
+ /**
+ * Creates a new post part.
+ *
+ * @param post
+ * The referenced post
+ */
public PostPart(Post post) {
this.post = post;
}
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the post referenced by this part.
+ *
+ * @return The post referenced by this part
+ */
public Post getPost() {
return post;
}
package net.pterodactylus.sone.text;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.template.SoneAccessor;
/**
- * TODO
+ * {@link Part} implementation that stores a reference to a {@link Sone}.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class SonePart implements Part {
+ /** The referenced {@link Sone}. */
private final Sone sone;
+ /**
+ * Creates a new Sone part.
+ *
+ * @param sone
+ * The referenced Sone
+ */
public SonePart(Sone sone) {
this.sone = sone;
}
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the referenced Sone.
+ *
+ * @return The referenced Sone
+ */
public Sone getSone() {
return sone;
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
-import java.io.StringReader;
-import java.io.Writer;
import java.net.MalformedURLException;
-import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.util.logging.Logging;
-import net.pterodactylus.util.template.Template;
-import net.pterodactylus.util.template.TemplateContextFactory;
-import net.pterodactylus.util.template.TemplateParser;
import freenet.keys.FreenetURI;
/**