[Webfunds-commits] java/webfunds/utils ClipboardHelper.java

Jeroen C. van Gelderen gelderen@cypherpunks.ai
Wed, 14 Mar 2001 15:15:01 -0400 (AST)


gelderen    01/03/14 15:15:01

  Modified:    webfunds/utils ClipboardHelper.java
  Log:
  Practise what I preach: name methods after interface, not after implementation
  details (toUnixText -> toClipboardableText).

Revision  Changes    Path
1.2       +10 -9     java/webfunds/utils/ClipboardHelper.java

Index: ClipboardHelper.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/utils/ClipboardHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClipboardHelper.java	2001/03/14 17:44:32	1.1
+++ ClipboardHelper.java	2001/03/14 19:15:00	1.2
@@ -1,4 +1,4 @@
-/* $Id: ClipboardHelper.java,v 1.1 2001/03/14 17:44:32 gelderen Exp $
+/* $Id: ClipboardHelper.java,v 1.2 2001/03/14 19:15:00 gelderen Exp $
  *
  * Copyright (c) Systemics Inc. 2001 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -20,7 +20,7 @@
  * text with UNIX line endings so that the Clipboard can then reconvert to
  * platform line endings. Thanks Sun!
  *
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
  * @author  Jeroen C. van Gelderen (gelderen@systemics.com)
  */
 public final class ClipboardHelper {
@@ -47,19 +47,20 @@
      * clipboard.
      */
     public static void setClipboardText(String text) {
-        String unixText = toUnixText(text);
+        String unixText = toClipboardableText(text);
         StringSelection sel = new StringSelection(unixText);
         clip.setContents(sel, null);
     }
 
 
     /**
-     * Convert the given text from platform line endings to UNIX line endings.
+     * Convert the given text from platform line endings to clipboard
+     * compatible line endings.
      *
      * Currently only CR, LF and CR/LF are handled correctly and mixed line
      * endings are not detected.
      */
-    public static String toUnixText(String text) {
+    public static String toClipboardableText(String text) {
 
         StringBuffer buf = new StringBuffer( text.length() );
         boolean lineFeedPending = false;
@@ -91,24 +92,24 @@
 
         NEWLINECHARS = "\n".toCharArray();
         String unixText = makeText("\n");
-        if( !unixText.equals( toUnixText(unixText) ) )
+        if( !unixText.equals( toClipboardableText(unixText) ) )
             throw new RuntimeException("unixText != unixText");
 
         NEWLINECHARS = "\r\n".toCharArray();
         String dosText = makeText("\r\n");
-        if( !unixText.equals( toUnixText(dosText) ) )
+        if( !unixText.equals( toClipboardableText(dosText) ) )
             throw new RuntimeException("unixText != dosText");
 
         NEWLINECHARS = "\r".toCharArray();
         String macText = makeText("\r");
-        if( !unixText.equals( toUnixText(macText) ) )
+        if( !unixText.equals( toClipboardableText(macText) ) )
             throw new RuntimeException("unixText != macText");
 
         /*
 XXX: we need a scanner in order to handle this correctly
         NEWLINECHARS = "\r\r".toCharArray();
         String weirdText = makeText("\r\r");
-        if( !unixText.equals( toUnixText(weirdText) ) )
+        if( !unixText.equals( toClipboardableText(weirdText) ) )
             throw new RuntimeException("unixText != weirdText");
         */