[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] RFC: Code formatting of java.awt.datatransfer.DataFlavo
From: |
Mark Wielaard |
Subject: |
Re: [cp-patches] RFC: Code formatting of java.awt.datatransfer.DataFlavor |
Date: |
Sun, 20 Nov 2005 20:07:11 +0100 |
Hi Jan,
On Sun, 2005-11-20 at 14:57 +0100, Jan Röhrich wrote:
> I fixed many code formatting issues in java.awt.datatransfer.DataFlavor.
> Because I'm not that familiar with GNU code formatting I thought it
> would be better to make this an RFC.
>
> 2005-11-20 Jan Röhrich <address@hidden>
>
> * java/awt/datatransfer/DataFlavor.java: fixed code
> formatting issues
Thanks a lot for going over this class. It was just indented horribly.
I went over it another time and fixed some more minor things (mainly
removing brackets around return statements). Attached is a patch against
your patch. I believe it is now according to our current styleguide:
http://www.gnu.org/software/classpath/docs/hacking.html#SEC7
Please check this in.
Thanks,
Mark
--- java/awt/datatransfer/DataFlavor.java.jan 2005-11-20 19:07:11.000000000
+0100
+++ java/awt/datatransfer/DataFlavor.java 2005-11-20 20:04:01.000000000
+0100
@@ -1,5 +1,5 @@
/* DataFlavor.java -- A type of data to transfer via the clipboard.
- Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -119,25 +119,23 @@
{
plainTextFlavor
= new DataFlavor(java.io.InputStream.class,
- "text/plain; charset=unicode",
- "plain unicode text");
+ "text/plain; charset=unicode",
+ "plain unicode text");
stringFlavor
= new DataFlavor(java.lang.String.class,
- "Java Unicode String");
+ "Java Unicode String");
javaFileListFlavor
= new DataFlavor(java.util.List.class,
- "application/x-java-file-list; class=java.util.List",
- "Java File List");
+ "application/x-java-file-list; class=java.util.List",
+ "Java File List");
imageFlavor
= new DataFlavor(java.awt.Image.class,
"Java Image");
}
-/*************************************************************************/
-
/*
* Instance Variables
*/
@@ -151,8 +149,6 @@
// The human readable name of this flavor
private String humanPresentableName;
-/*************************************************************************/
-
/*
* Static Methods
*/
@@ -169,9 +165,9 @@
*
* @exception ClassNotFoundException If the class cannot be loaded.
*/
- protected static final Class
- tryToLoadClass(String className, ClassLoader classLoader)
- throws ClassNotFoundException
+ protected static final Class tryToLoadClass(String className,
+ ClassLoader classLoader)
+ throws ClassNotFoundException
{
try
{
@@ -207,8 +203,6 @@
throw new ClassNotFoundException(className);
}
-/*************************************************************************/
-
/*
* Constructors
*/
@@ -217,30 +211,26 @@
* Empty public constructor needed for externalization.
* Should not be used for normal instantiation.
*/
- public
- DataFlavor()
+ public DataFlavor()
{
- mimeType = null;
- representationClass = null;
- humanPresentableName = null;
+ mimeType = null;
+ representationClass = null;
+ humanPresentableName = null;
}
-/*************************************************************************/
-
/**
* Private constructor.
*/
- private
- DataFlavor(Class representationClass,
- String mimeType,
- String humanPresentableName)
- {
- this.representationClass = representationClass;
- this.mimeType = mimeType;
- if (humanPresentableName != null)
- this.humanPresentableName = humanPresentableName;
- else
- this.humanPresentableName = mimeType;
+ private DataFlavor(Class representationClass,
+ String mimeType,
+ String humanPresentableName)
+ {
+ this.representationClass = representationClass;
+ this.mimeType = mimeType;
+ if (humanPresentableName != null)
+ this.humanPresentableName = humanPresentableName;
+ else
+ this.humanPresentableName = mimeType;
}
/**
@@ -253,10 +243,9 @@
* @param representationClass The representation class for this object.
* @param humanPresentableName The display name of the object.
*/
- public
- DataFlavor(Class representationClass, String humanPresentableName)
+ public DataFlavor(Class representationClass, String humanPresentableName)
{
- this(representationClass,
+ this(representationClass,
"application/x-java-serialized-object"
+ "; class="
+ representationClass.getName(),
@@ -281,16 +270,16 @@
* specified cannot be loaded.
* @exception ClassNotFoundException If the class is not loaded.
*/
- public
- DataFlavor(String mimeType, String humanPresentableName,
- ClassLoader classLoader) throws ClassNotFoundException
+ public DataFlavor(String mimeType, String humanPresentableName,
+ ClassLoader classLoader)
+ throws ClassNotFoundException
{
this(getRepresentationClassFromMime(mimeType, classLoader),
mimeType, humanPresentableName);
}
- private static Class
- getRepresentationClassFromMime(String mimeString, ClassLoader classLoader)
+ private static Class getRepresentationClassFromMime(String mimeString,
+ ClassLoader classLoader)
{
String classname = getParameter("class", mimeString);
if (classname != null)
@@ -305,9 +294,7 @@
}
}
else
- {
- return java.io.InputStream.class;
- }
+ return java.io.InputStream.class;
}
/**
@@ -328,8 +315,8 @@
*/
public DataFlavor(String mimeType, String humanPresentableName)
{
- this (getRepresentationClassFromMime (mimeType, null),
- mimeType, humanPresentableName);
+ this(getRepresentationClassFromMime (mimeType, null),
+ mimeType, humanPresentableName);
}
/**
@@ -500,7 +487,7 @@
*/
public final boolean isMimeTypeEqual(DataFlavor flavor)
{
- return(isMimeTypeEqual(flavor.getMimeType()));
+ return isMimeTypeEqual(flavor.getMimeType());
}
/**
@@ -511,7 +498,7 @@
*/
public boolean isMimeTypeSerializedObject()
{
- return(mimeType.startsWith(javaSerializedObjectMimeType));
+ return mimeType.startsWith(javaSerializedObjectMimeType);
}
/**
@@ -523,7 +510,7 @@
*/
public boolean isRepresentationClassInputStream()
{
- return(representationClass.getName().equals("java.io.InputStream"));
+ return representationClass.getName().equals("java.io.InputStream");
}
/**
@@ -541,11 +528,11 @@
while (i < interfaces.length)
{
if (interfaces[i].getName().equals("java.io.Serializable"))
- return(true);
+ return true;
++i;
}
- return(false);
+ return false;
}
/**
@@ -590,11 +577,11 @@
*/
public boolean isFlavorJavaFileListType()
{
- if (this.mimeType.equals(javaFileListFlavor.mimeType) &&
-
this.representationClass.equals(javaFileListFlavor.representationClass))
- return(true);
+ if (mimeType.equals(javaFileListFlavor.mimeType)
+ && representationClass.equals(javaFileListFlavor.representationClass))
+ return true;
- return(false);
+ return false ;
}
/**
@@ -608,13 +595,14 @@
*/
public Object clone () throws CloneNotSupportedException
{
+ // FIXME - This cannot be right.
try
{
- return(super.clone());
+ return super.clone();
}
catch(Exception e)
{
- return(null);
+ return null;
}
}
@@ -631,15 +619,15 @@
public boolean equals(DataFlavor flavor)
{
if (flavor == null)
- return(false);
+ return false;
- if (!this.mimeType.toLowerCase().equals(flavor.mimeType.toLowerCase()))
- return(false);
+ if (! this.mimeType.toLowerCase().equals(flavor.mimeType.toLowerCase()))
+ return false;
- if (!this.representationClass.equals(flavor.representationClass))
- return(false);
+ if (! this.representationClass.equals(flavor.representationClass))
+ return false;
- return(true);
+ return true;
}
/**
@@ -661,10 +649,10 @@
*/
public boolean equals(Object obj)
{
- if (!(obj instanceof DataFlavor))
- return(false);
+ if (! (obj instanceof DataFlavor))
+ return false;
- return(equals((DataFlavor)obj));
+ return equals((DataFlavor) obj);
}
/**
@@ -681,7 +669,7 @@
*/
public boolean equals(String str)
{
- return(isMimeTypeEqual(str));
+ return isMimeTypeEqual(str);
}
/**
@@ -691,7 +679,7 @@
*/
public int hashCode()
{
- return(mimeType.toLowerCase().hashCode()^representationClass.hashCode());
+ return mimeType.toLowerCase().hashCode() ^ representationClass.hashCode();
}
/**
@@ -701,7 +689,7 @@
public boolean match(DataFlavor dataFlavor)
{
// XXX - How is this different from equals?
- return(equals(dataFlavor));
+ return equals(dataFlavor);
}
/**
@@ -717,7 +705,7 @@
*/
protected String normalizeMimeTypeParameter(String name, String value)
{
- return(name + "=" + value);
+ return name + "=" + value;
}
/**
@@ -732,7 +720,7 @@
*/
protected String normalizeMimeType(String type)
{
- return(type);
+ return type;
}
/**
@@ -769,11 +757,11 @@
*/
public String toString()
{
- return(getClass().getName()
- + "[representationClass=" + getRepresentationClass().getName()
- + ",mimeType=" + getMimeType()
- + ",humanPresentableName=" + getHumanPresentableName()
- + "]");
+ return (getClass().getName()
+ + "[representationClass=" + getRepresentationClass().getName()
+ + ",mimeType=" + getMimeType()
+ + ",humanPresentableName=" + getHumanPresentableName()
+ + "]");
}
/**
@@ -781,7 +769,7 @@
*/
public static final DataFlavor getTextPlainUnicodeFlavor()
{
- return(plainTextFlavor);
+ return plainTextFlavor;
}
/**
@@ -791,7 +779,7 @@
*/
public final Class getDefaultRepresentationClass()
{
- return(java.io.InputStream.class);
+ return java.io.InputStream.class;
}
/**
@@ -799,7 +787,7 @@
*/
public final String getDefaultRepresentationClassAsString()
{
- return(getDefaultRepresentationClass().getName());
+ return getDefaultRepresentationClass().getName();
}
/**
@@ -815,21 +803,19 @@
public static final DataFlavor
selectBestTextFlavor(DataFlavor[] availableFlavors)
{
- for(int i=0; i<availableFlavors.length; i++)
+ for(int i = 0; i < availableFlavors.length; i++)
{
DataFlavor df = availableFlavors[i];
Class c = df.representationClass;
// A Reader or String is good.
if ((Reader.class.isAssignableFrom(c))
- || (String.class.isAssignableFrom(c)))
- {
+ || (String.class.isAssignableFrom(c)))
return df;
- }
// A InputStream is good if the mime primary type is "text"
if ((InputStream.class.isAssignableFrom(c))
- && ("text".equals(df.getPrimaryType())))
+ && ("text".equals(df.getPrimaryType())))
{
String encoding = availableFlavors[i].getParameter("charset");
if (encoding == null)
@@ -842,13 +828,14 @@
(new ByteArrayInputStream(new byte[0]), encoding);
}
catch(UnsupportedEncodingException uee) { /* ignore */ }
+
if (r != null)
return df;
}
}
// Nothing found
- return(null);
+ return null;
}
/**
@@ -883,10 +870,10 @@
throw new UnsupportedFlavorException(this);
if (Reader.class.isAssignableFrom(representationClass))
- return((Reader)transferable.getTransferData(this));
+ return (Reader)transferable.getTransferData(this);
if (String.class.isAssignableFrom(representationClass))
- return(new StringReader((String)transferable.getTransferData(this)));
+ return new StringReader((String)transferable.getTransferData(this));
if (InputStream.class.isAssignableFrom(representationClass)
&& "text".equals(getPrimaryType()))
@@ -895,7 +882,7 @@
String encoding = getParameter("charset");
if (encoding == null)
encoding = "us-ascii";
- return(new InputStreamReader(in, encoding));
+ return new InputStreamReader(in, encoding);
}
throw new UnsupportedFlavorException(this);
@@ -907,9 +894,9 @@
*
* @since 1.4
*/
- public boolean isRepresentationClassByteBuffer ()
+ public boolean isRepresentationClassByteBuffer()
{
- return ByteBuffer.class.isAssignableFrom (representationClass);
+ return ByteBuffer.class.isAssignableFrom(representationClass);
}
/**
@@ -918,9 +905,9 @@
*
* @since 1.4
*/
- public boolean isRepresentationClassCharBuffer ()
+ public boolean isRepresentationClassCharBuffer()
{
- return CharBuffer.class.isAssignableFrom (representationClass);
+ return CharBuffer.class.isAssignableFrom(representationClass);
}
/**
@@ -929,9 +916,9 @@
*
* @since 1.4
*/
- public boolean isRepresentationClassReader ()
+ public boolean isRepresentationClassReader()
{
- return Reader.class.isAssignableFrom (representationClass);
+ return Reader.class.isAssignableFrom(representationClass);
}
} // class DataFlavor
signature.asc
Description: This is a digitally signed message part