Add javadocs

pull/2/head
Hammy 3 years ago
parent d6a6c59a24
commit 40f4cdbb8d

@ -8,6 +8,10 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/**
* Abstract class containing common operations between {@link WindowsOrUnixClipboardListener} and
* {@link MacClipboardListener}
*/
abstract class ClipboardListener { abstract class ClipboardListener {
Clipboard clipboard; Clipboard clipboard;
Logger logger; Logger logger;
@ -105,14 +109,23 @@ abstract class ClipboardListener {
*/ */
abstract void insertAndNotify(List<File> fileContent); abstract void insertAndNotify(List<File> fileContent);
/**
* Toggles the current value of text monitoring, the default value is set to {@code True}
*/
void toggleTextMonitored() { void toggleTextMonitored() {
this.textMonitored = !textMonitored; this.textMonitored = !textMonitored;
} }
/**
* Toggles the current value of image monitoring, the default value is set to {@code True}
*/
void toggleImagesMonitored() { void toggleImagesMonitored() {
this.imageMonitored = !imageMonitored; this.imageMonitored = !imageMonitored;
} }
/**
* Toggles the current value of file monitoring, the default value is set to {@code True}
*/
void toggleFileMonitored() { void toggleFileMonitored() {
this.fileMonitored = !fileMonitored; this.fileMonitored = !fileMonitored;
} }

@ -19,6 +19,9 @@ import static me.goudham.Contents.FILE;
import static me.goudham.Contents.IMAGE; import static me.goudham.Contents.IMAGE;
import static me.goudham.Contents.TEXT; import static me.goudham.Contents.TEXT;
/**
* Clipboard Listener for the macOS operating system
*/
class MacClipboardListener extends ClipboardListener implements Runnable { class MacClipboardListener extends ClipboardListener implements Runnable {
ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
GenericClipboardContent<?>[] genericClipboardContents; GenericClipboardContent<?>[] genericClipboardContents;

@ -68,26 +68,80 @@ public class MyClipboard {
clipboardListener.stopListening(); clipboardListener.stopListening();
} }
/**
* Insert the given {@link String} into the system clipboard
* <p>
* Due to the underlying {@link MacClipboardListener#insert(String)} implementation, inserting
* clipboard contents will always result in event notifications being sent
*
* @param stringContent The given {@link String} to insert
* @see WindowsOrUnixClipboardListener#insert(String)
* @see MacClipboardListener#insert(String)
*/
public void insert(String stringContent) { public void insert(String stringContent) {
clipboardListener.insert(stringContent); clipboardListener.insert(stringContent);
} }
/**
* Insert the given {@link Image} into the system clipboard
* <p>
* Due to the underlying {@link MacClipboardListener#insert(Image)} implementation, inserting
* clipboard contents will always result in event notifications being sent
*
* @param imageContent The given {@link Image} to insert
* @see WindowsOrUnixClipboardListener#insert(Image)
* @see MacClipboardListener#insert(Image)
*/
public void insert(Image imageContent) { public void insert(Image imageContent) {
clipboardListener.insert(imageContent); clipboardListener.insert(imageContent);
} }
/**
* Insert the given {@link List} of {@link File} into the system clipboard
* <p>
* Due to the underlying {@link MacClipboardListener#insert(List)} implementation, inserting
* clipboard contents will always result in event notifications being sent
*
* @param fileContent The given {@link List} of {@link File} to insert
* @see WindowsOrUnixClipboardListener#insert(List)
* @see MacClipboardListener#insert(List)
*/
public void insert(List<File> fileContent) { public void insert(List<File> fileContent) {
clipboardListener.insert(fileContent); clipboardListener.insert(fileContent);
} }
/**
* Insert the given {@link String} into the system clipboard
* and notify the user about the new contents within the clipboard
*
* @param stringContent The given {@link String} to insert
* @see WindowsOrUnixClipboardListener#insertAndNotify(String)
* @see MacClipboardListener#insertAndNotify(String)
*/
public void insertAndNotify(String stringContent) { public void insertAndNotify(String stringContent) {
clipboardListener.insertAndNotify(stringContent); clipboardListener.insertAndNotify(stringContent);
} }
/**
* Insert the given {@link Image} into the system clipboard
* and notify the user about the new contents within the clipboard
*
* @param imageContent The given {@link Image} to insert
* @see WindowsOrUnixClipboardListener#insertAndNotify(Image)
* @see MacClipboardListener#insertAndNotify(Image)
*/
public void insertAndNotify(Image imageContent) { public void insertAndNotify(Image imageContent) {
clipboardListener.insertAndNotify(imageContent); clipboardListener.insertAndNotify(imageContent);
} }
/**
* Insert the given {@link List} of {@link File} into the system clipboard
* and notify the user about the new contents within the clipboard
*
* @param fileContent The given {@link List} of {@link File} to insert
* @see WindowsOrUnixClipboardListener#insertAndNotify(List)
* @see MacClipboardListener#insertAndNotify(List)
*/
public void insertAndNotify(List<File> fileContent) { public void insertAndNotify(List<File> fileContent) {
clipboardListener.insertAndNotify(fileContent); clipboardListener.insertAndNotify(fileContent);
} }
@ -96,7 +150,7 @@ public class MyClipboard {
* Adds a {@link TextEvent} to the underlying {@link ClipboardListener} * Adds a {@link TextEvent} to the underlying {@link ClipboardListener}
* *
* @param textEvent The {@link TextEvent} to be added * @param textEvent The {@link TextEvent} to be added
* @see EventManager#addEventListener(TextEvent) * @see EventManager#addEventListener(TextEvent)
*/ */
public void addEventListener(TextEvent textEvent) { public void addEventListener(TextEvent textEvent) {
clipboardListener.getEventManager().addEventListener(textEvent); clipboardListener.getEventManager().addEventListener(textEvent);
@ -106,7 +160,7 @@ public class MyClipboard {
* Adds a {@link ImageEvent} to the underlying {@link ClipboardListener} * Adds a {@link ImageEvent} to the underlying {@link ClipboardListener}
* *
* @param imageEvent The {@link ImageEvent} to be added * @param imageEvent The {@link ImageEvent} to be added
* @see EventManager#addEventListener(ImageEvent) * @see EventManager#addEventListener(ImageEvent)
*/ */
public void addEventListener(ImageEvent imageEvent) { public void addEventListener(ImageEvent imageEvent) {
clipboardListener.getEventManager().addEventListener(imageEvent); clipboardListener.getEventManager().addEventListener(imageEvent);
@ -116,7 +170,7 @@ public class MyClipboard {
* Adds a {@link FileEvent} to the underlying {@link ClipboardListener} * Adds a {@link FileEvent} to the underlying {@link ClipboardListener}
* *
* @param fileEvent The {@link FileEvent} to be added * @param fileEvent The {@link FileEvent} to be added
* @see EventManager#addEventListener(FileEvent) * @see EventManager#addEventListener(FileEvent)
*/ */
public void addEventListener(FileEvent fileEvent) { public void addEventListener(FileEvent fileEvent) {
clipboardListener.getEventManager().addEventListener(fileEvent); clipboardListener.getEventManager().addEventListener(fileEvent);
@ -126,7 +180,7 @@ public class MyClipboard {
* Removes a {@link TextEvent} from the underlying {@link ClipboardListener} * Removes a {@link TextEvent} from the underlying {@link ClipboardListener}
* *
* @param textEvent The {@link TextEvent} to be removed * @param textEvent The {@link TextEvent} to be removed
* @see EventManager#removeEventListener(TextEvent) * @see EventManager#removeEventListener(TextEvent)
*/ */
public void removeEventListener(TextEvent textEvent) { public void removeEventListener(TextEvent textEvent) {
clipboardListener.getEventManager().removeEventListener(textEvent); clipboardListener.getEventManager().removeEventListener(textEvent);
@ -136,7 +190,7 @@ public class MyClipboard {
* Removes a {@link ImageEvent} from the underlying {@link ClipboardListener} * Removes a {@link ImageEvent} from the underlying {@link ClipboardListener}
* *
* @param imageEvent The {@link ImageEvent} to be removed * @param imageEvent The {@link ImageEvent} to be removed
* @see EventManager#removeEventListener(ImageEvent) * @see EventManager#removeEventListener(ImageEvent)
*/ */
public void removeEventListener(ImageEvent imageEvent) { public void removeEventListener(ImageEvent imageEvent) {
clipboardListener.getEventManager().removeEventListener(imageEvent); clipboardListener.getEventManager().removeEventListener(imageEvent);
@ -152,14 +206,29 @@ public class MyClipboard {
clipboardListener.getEventManager().removeEventListener(fileEvent); clipboardListener.getEventManager().removeEventListener(fileEvent);
} }
/**
* Toggles the current value of text monitoring, the default value is set to {@code True}
*
* @see ClipboardListener#toggleTextMonitored()
*/
public void toggleTextMonitored() { public void toggleTextMonitored() {
clipboardListener.toggleTextMonitored(); clipboardListener.toggleTextMonitored();
} }
/**
* Toggles the current value of image monitoring, the default value is set to {@code True}
*
* @see ClipboardListener#toggleImagesMonitored()
*/
public void toggleImagesMonitored() { public void toggleImagesMonitored() {
clipboardListener.toggleImagesMonitored(); clipboardListener.toggleImagesMonitored();
} }
/**
* Toggles the current value of file monitoring, the default value is set to {@code True}
*
* @see ClipboardListener#toggleFileMonitored()
*/
public void toggleFilesMonitored() { public void toggleFilesMonitored() {
clipboardListener.toggleFileMonitored(); clipboardListener.toggleFileMonitored();
} }
@ -196,11 +265,11 @@ public class MyClipboard {
this.clipboardListener = clipboardListener; this.clipboardListener = clipboardListener;
} }
protected static SystemUtils getSystemUtils() { static SystemUtils getSystemUtils() {
return systemUtils; return systemUtils;
} }
protected static void setSystemUtils(SystemUtils systemUtils) { static void setSystemUtils(SystemUtils systemUtils) {
MyClipboard.systemUtils = systemUtils; MyClipboard.systemUtils = systemUtils;
} }
} }

@ -19,6 +19,9 @@ import static me.goudham.Contents.FILE;
import static me.goudham.Contents.IMAGE; import static me.goudham.Contents.IMAGE;
import static me.goudham.Contents.TEXT; import static me.goudham.Contents.TEXT;
/**
* Clipboard Listener for Windows and Unix operating systems
*/
class WindowsOrUnixClipboardListener extends ClipboardListener implements Runnable, ClipboardOwner { class WindowsOrUnixClipboardListener extends ClipboardListener implements Runnable, ClipboardOwner {
private ExecutorService executorService = Executors.newSingleThreadExecutor(); private ExecutorService executorService = Executors.newSingleThreadExecutor();
private boolean listening = false; private boolean listening = false;

Loading…
Cancel
Save