chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1511250 [2/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ chemistry-opencmis-android/chemistry-opencmis-android-client/s...
Date Wed, 07 Aug 2013 11:35:43 GMT
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/Configurator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/Configurator.java?rev=1511250&r1=1511249&r2=1511250&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/Configurator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/Configurator.java
Wed Aug  7 11:35:42 2013
@@ -32,97 +32,102 @@ import org.slf4j.LoggerFactory;
 public class Configurator {
 
     private static final Logger LOG = LoggerFactory.getLogger(Configurator.class.getName());
-    
+
     private static Configurator INSTANCE;
-    static final String PREFIX = "mapping.contentType";
-    
+    private static final String PREFIX = "mapping.contentType";
+
     public static Configurator getInstance() {
-        if (null == INSTANCE)
+        if (null == INSTANCE) {
             INSTANCE = new Configurator();
+        }
+
         return INSTANCE;
     }
-    
+
     private Properties properties;
-    private Map<String, PropertyMapper> contentTypeMapperMap  = new HashMap<String,
PropertyMapper>();
+    private Map<String, PropertyMapper> contentTypeMapperMap = new HashMap<String,
PropertyMapper>();
     private Map<String, MetadataParser> parserMap = new HashMap<String, MetadataParser>();
     private String defaultDocumentType;
     private String defaultFolderType;
-    
-    private Configurator() {     
+
+    private Configurator() {
         loadProperties();
         loadDefaults();
         buildMapperMap();
         createParsers();
     }
-    
+
     // just for unit tests
     Configurator(Properties props) {
-//        contentTypeMapperMap = new HashMap<String, PropertyMapper>();
+        // contentTypeMapperMap = new HashMap<String, PropertyMapper>();
         this.properties = props;
     }
-    
-    
+
     public PropertyMapper getPropertyMapper(String contentType) {
         MetadataParser parser = getParser(contentType);
         return parser.getMapper();
     }
-    
+
     public MetadataParser getParser(String contentType) {
         MetadataParser parser = parserMap.get(contentType);
         if (null == parser) {
             // if not found try a more generic one
             String genericContentType = contentType.substring(0, contentType.indexOf('/'))
+ "/*";
-            for (String key: parserMap.keySet()) {
-                if (key.equals(genericContentType))
+            for (String key : parserMap.keySet()) {
+                if (key.equals(genericContentType)) {
                     return parserMap.get(key);
+                }
             }
         }
         return parser;
-        
-//        for (String contentType : contentTypes) {
-//            if (contentType.equals(mimeType))
-//                return cmisTypeId;
-//            boolean isStar = contentType.endsWith("/*");
-//            if (isStar) {
-//                String generalPartParam = mimeType.substring(0, mimeType.indexOf('/'));
-//                String generalPartCfg = contentType.substring(0, mimeType.indexOf('/'));
-//                if (generalPartParam.equals(generalPartCfg))
-//                    return cmisTypeId;
-//            }
-//        }
-//        return null;        
+
+        // for (String contentType : contentTypes) {
+        // if (contentType.equals(mimeType))
+        // return cmisTypeId;
+        // boolean isStar = contentType.endsWith("/*");
+        // if (isStar) {
+        // String generalPartParam = mimeType.substring(0,
+        // mimeType.indexOf('/'));
+        // String generalPartCfg = contentType.substring(0,
+        // mimeType.indexOf('/'));
+        // if (generalPartParam.equals(generalPartCfg))
+        // return cmisTypeId;
+        // }
+        // }
+        // return null;
     }
 
     private void loadProperties() {
         // Returns null on lookup failures:
-        InputStream in = Configurator.class.getResourceAsStream ("/mapping.properties");
-        if (in != null)
-        {
+        InputStream in = Configurator.class.getResourceAsStream("/mapping.properties");
+        if (in != null) {
             properties = new Properties();
             try {
-                properties.load (in);
+                properties.load(in);
             } catch (IOException e) {
                 LOG.error(e.toString(), e);
                 e.printStackTrace();
                 throw new MapperException("Could not load file mapping.properties as resource",
e);
-            } 
+            }
         }
     }
-    
+
     private void loadDefaults() {
         defaultDocumentType = properties.getProperty(PREFIX + ".default.document");
-        if (null == defaultDocumentType)
+        if (null == defaultDocumentType) {
             defaultDocumentType = "cmis:document";
-        
+        }
+
         defaultFolderType = properties.getProperty(PREFIX + ".default.folder");
-        if (null == defaultFolderType)
-            defaultFolderType = "cmis:folder";                
+        if (null == defaultFolderType) {
+            defaultFolderType = "cmis:folder";
+        }
     }
-    
+
     public String getDefaultDocumentType() {
         return defaultDocumentType;
     }
-    
+
     public String getDefaultFolderType() {
         return defaultFolderType;
     }
@@ -130,68 +135,77 @@ public class Configurator {
     public final Properties getProperties() {
         return properties;
     }
-    
+
     /**
      * return an overridden MIME type from a file extension
      * 
      * @param fileExtension
-     *      enforced or content-type or null if none is set
+     *            enforced or content-type or null if none is set
      */
     public String getContentType(String fileExtension) {
-        return properties.getProperty(PREFIX+ ".forceContentType." + fileExtension, null);
+        return properties.getProperty(PREFIX + ".forceContentType." + fileExtension, null);
     }
-    
+
     String[] getTypeKeys() {
         String s = properties.getProperty(PREFIX + "s");
-        
-        if (null == s)
+
+        if (null == s) {
             return null;
-        
+        }
+
         String[] keys = s.split(",");
-        
-        for (int i=0; i<keys.length; i++)
+
+        for (int i = 0; i < keys.length; i++) {
             keys[i] = keys[i].trim();
-        
+        }
+
         return keys;
     }
-    
-    void  buildMapperMap() {
-        
+
+    void buildMapperMap() {
+
         String[] typeKeys = getTypeKeys();
         for (String typeKey : typeKeys) {
             PropertyMapper mapper = loadMapperClass(typeKey);
             String contentType = properties.getProperty(PREFIX + "." + typeKey);
-            if (null == contentType) 
-                throw new MapperException("Missingt content type in properties: " + PREFIX
+ "." + contentType);
+            if (null == contentType) {
+                throw new MapperException("Missingt content type in properties: " + PREFIX
+ "." + typeKey);
+            }
             boolean ok = mapper.initialize(PREFIX, typeKey, properties);
 
-            if (ok)
+            if (ok) {
                 contentTypeMapperMap.put(typeKey, mapper);
-        }        
+            }
+        }
     }
-    
+
     void createParsers() {
         String[] typeKeys = getTypeKeys();
         for (String typeKey : typeKeys) {
             MetadataParser parser = loadParserClass(typeKey);
             String contentType = properties.getProperty(PREFIX + "." + typeKey);
-            if (null == contentType) 
-                throw new MapperException("Missing content type in properties: " + PREFIX
+ "." + contentType);
-            
+            if (null == contentType) {
+                throw new MapperException("Missing content type in properties: " + PREFIX
+ "." + typeKey);
+            }
+
             PropertyMapper mapper = contentTypeMapperMap.get(typeKey);
 
             parser.initialize(mapper, contentType);
             String[] contentTypes = parser.getContentTypes();
-            for (String ct : contentTypes)
+            for (String ct : contentTypes) {
                 parserMap.put(ct, parser);
-        }                
+            }
+        }
     }
-    
+
     MetadataParser loadParserClass(String typeKey) {
         String className = properties.getProperty(PREFIX + "." + typeKey + ".parserClass");
-        if (null == className) // use Tika as default parser if none is configured
+        if (null == className) {// use Tika as default parser if none is
+                                // configured
             className = MetadataParserTika.class.getName();
-//            throw new MapperException("Missing parser class in properties: " + PREFIX +
"." + typeKey + ".parserClass");
+        }
+        // throw new MapperException("Missing parser class in properties: " +
+        // PREFIX + "." + typeKey + ".parserClass");
 
         Object obj = null;
 
@@ -199,30 +213,30 @@ public class Configurator {
             obj = Class.forName(className).newInstance();
         } catch (InstantiationException e) {
             LOG.error(e.toString(), e);
-            throw new MapperException(
-                    "Illegal class to load metadata parser, cannot instantiate " + className,
e);
+            throw new MapperException("Illegal class to load metadata parser, cannot instantiate
" + className, e);
         } catch (IllegalAccessException e) {
             LOG.error(e.toString(), e);
-            throw new MapperException(
-                    "Illegal class to load metadata parser, cannot access " + className,
e);
+            throw new MapperException("Illegal class to load metadata parser, cannot access
" + className, e);
         } catch (ClassNotFoundException e) {
             LOG.error(e.toString(), e);
-            throw new MapperException(
-                    "Illegal class to load metadata parser, class not found: " + className,
e);
+            throw new MapperException("Illegal class to load metadata parser, class not found:
" + className, e);
         }
 
         if (obj instanceof MetadataParser) {
             return (MetadataParser) obj;
         } else {
-            throw new MapperException("Illegal class to create metadata parser: " + className
+ ", must implement MetadataParser interface.");
+            throw new MapperException("Illegal class to create metadata parser: " + className
+                    + ", must implement MetadataParser interface.");
         }
     }
 
     PropertyMapper loadMapperClass(String typeKey) {
         String className = properties.getProperty(PREFIX + "." + typeKey + ".mapperClass");
-        if (null == className) 
+        if (null == className) {
             className = PropertyMapperTika.class.getName();
-//            throw new MapperException("Missing property mapper in properties: " + PREFIX
+ "." + typeKey + ".mapperClass");
+        }
+        // throw new MapperException("Missing property mapper in properties: " +
+        // PREFIX + "." + typeKey + ".mapperClass");
 
         Object obj = null;
 
@@ -230,22 +244,20 @@ public class Configurator {
             obj = Class.forName(className).newInstance();
         } catch (InstantiationException e) {
             LOG.error(e.toString(), e);
-            throw new MapperException(
-                    "Illegal class to load mapping configuration, cannot instantiate " +
className, e);
+            throw new MapperException("Illegal class to load mapping configuration, cannot
instantiate " + className, e);
         } catch (IllegalAccessException e) {
             LOG.error(e.toString(), e);
-            throw new MapperException(
-                    "Illegal class to load mapping configuration, cannot access " + className,
e);
+            throw new MapperException("Illegal class to load mapping configuration, cannot
access " + className, e);
         } catch (ClassNotFoundException e) {
             LOG.error(e.toString(), e);
-            throw new MapperException(
-                    "Illegal class to load mapping configuration, class not found: " + className,
e);
+            throw new MapperException("Illegal class to load mapping configuration, class
not found: " + className, e);
         }
 
         if (obj instanceof PropertyMapper) {
             return (PropertyMapper) obj;
         } else {
-            throw new MapperException("Illegal class to create property mapper: " + className
+ ", must implement PropertyMapper interface.");
+            throw new MapperException("Illegal class to create property mapper: " + className
+                    + ", must implement PropertyMapper interface.");
         }
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java?rev=1511250&r1=1511249&r2=1511250&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
Wed Aug  7 11:35:42 2013
@@ -46,7 +46,7 @@ import com.drew.metadata.jpeg.JpegDirect
 public class PropertyMapperExif extends AbstractPropertyMapper {
 
     private static final Logger LOG = LoggerFactory.getLogger(PropertyMapperExif.class.getName());
-    private static String EXIF_DATE_FORMAT = "yyyy:MM:dd HH:mm:ss";
+    private static final String EXIF_DATE_FORMAT = "yyyy:MM:dd HH:mm:ss";
 
     private Map<String, String> propMapExif = new HashMap<String, String> ();
// tag to property id
     private Map<String, String> propMapGps = new HashMap<String, String> ();
 // tag to property id
@@ -104,8 +104,9 @@ public class PropertyMapperExif extends 
     private String getHexString(int tagType) {
         StringBuffer hexStr = new StringBuffer();
         hexStr.append(Integer.toHexString(tagType));
-        while (hexStr.length() < 4)
+        while (hexStr.length() < 4) {
             hexStr.insert(0, "0");
+        }
         hexStr.insert(0, "0x");
         return hexStr.toString();
     }
@@ -127,9 +128,10 @@ public class PropertyMapperExif extends 
             propId = propMapExif.get(hexStr);
         } else if (JpegDirectory.class.equals(dir.getClass())) {
             propId = propMapJpeg.get(hexStr);
-        } else
+        } else {
             propId = null;
-        
+        }
+            
         if (null != propId) {
             if (null != td) {
                 PropertyDefinition<?> pd = td.getPropertyDefinitions().get(propId);
@@ -138,8 +140,9 @@ public class PropertyMapperExif extends 
                 PropertyType pt = pd.getPropertyType();
                 Object convValue = convertValue(dir, tag, pt);
                 propMap.put(propId, convValue);
-            } else
+            } else {
                 propMap.put(propId, dir.getObject(tag.getTagType())); // omit conversion
if no type definition is available
+            }
         }
     }
     
@@ -305,11 +308,13 @@ public class PropertyMapperExif extends 
         
         Class<?> stringArrayClass = src.getClass();
         Class<?> stringArrayComponentType = stringArrayClass.getComponentType();
-        if (!stringArrayClass.isArray() || null == stringArrayComponentType || Array.getLength(src)
!= 3) 
+        if (!stringArrayClass.isArray() || null == stringArrayComponentType || Array.getLength(src)
!= 3) {
             throw new MapperException("GPS coordinate \"" + tag + "\" has unknown type.");
-        if (!stringArrayComponentType.equals(Rational.class))
+        }
+        if (!stringArrayComponentType.equals(Rational.class)) {
             throw new MapperException("GPS coordinate \"" + tag + "\" has unknown component
type (expected Rational, found: " + 
                     stringArrayComponentType.getName() + ")");
+        }
         // do conversion
         Rational[] components;
         components = (Rational[]) src;
@@ -317,8 +322,9 @@ public class PropertyMapperExif extends 
         double min = components[1].doubleValue();
         double sec = components[2].doubleValue();
         Double d = (deg + min / 60 + sec / 3600);
-        if (d > 0.0 && mustInvert)
+        if (d > 0.0 && mustInvert) {
             d = -d;
+        }
         res = d;
         return res;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java?rev=1511250&r1=1511249&r2=1511250&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
Wed Aug  7 11:35:42 2013
@@ -48,7 +48,6 @@ import javax.imageio.stream.ImageOutputS
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 public class FractalGenerator {
     private static final Logger LOG = LoggerFactory.getLogger(FractalGenerator.class);
 
@@ -73,9 +72,9 @@ public class FractalGenerator {
     private final String COLORS_WARPED = "warped";
     private final String COLORS_WILD = "wild";
     private final String COLORS_ZEBRA = "zebra";
-    private final String[] colorSchemes = {COLORS_BLACK_AND_WHITE, COLORS_BLUE_ICE, COLORS_FUNKY,
COLORS_PASTEL,
-        COLORS_PSYCHEDELIC, COLORS_PURPLE_HAZE, COLORS_RADICAL, COLORS_RAINBOW, COLORS_RAINBOWS,
-        COLORS_SCINTILLATION, COLORS_WARPED, COLORS_WILD, COLORS_ZEBRA};
+    private final String[] colorSchemes = { COLORS_BLACK_AND_WHITE, COLORS_BLUE_ICE, COLORS_FUNKY,
COLORS_PASTEL,
+            COLORS_PSYCHEDELIC, COLORS_PURPLE_HAZE, COLORS_RADICAL, COLORS_RAINBOW, COLORS_RAINBOWS,
+            COLORS_SCINTILLATION, COLORS_WARPED, COLORS_WILD, COLORS_ZEBRA };
     private final int imageHeight = 512; // default
     private final int imageWidth = 512; // default
     private final int numColors = 512; // colors per colormap
@@ -89,73 +88,73 @@ public class FractalGenerator {
     private int stepInBatch = 0;
     ComplexRectangle rect;
     ComplexPoint juliaPoint;
-    
+
     public FractalGenerator() {
         reset();
     }
-    
+
     private void reset() {
         rect = new ComplexRectangle(-1.6, -1.2, -0.1, 0.1);
         juliaPoint = null; // new ComplexPoint();
         maxIterations = DEFAULT_MAX_ITERATIONS;
-       
+
         Random ran = new Random();
         color = colorSchemes[ran.nextInt(colorSchemes.length)];
-        parts = ran.nextInt(13)+3;
+        parts = ran.nextInt(13) + 3;
         LOG.debug("Parts: " + parts);
         maxIterations = DEFAULT_MAX_ITERATIONS;
-        LOG.debug("Original rect " + ": (" + rect.getRMin() + "r," + rect.getRMax() +
-                "r, " + rect.getIMin() + "i, " + rect.getIMax() + "i)");
+        LOG.debug("Original rect " + ": (" + rect.getRMin() + "r," + rect.getRMax() + "r,
" + rect.getIMin() + "i, "
+                + rect.getIMax() + "i)");
         randomizeRect(rect);
     }
-    
+
     public ByteArrayOutputStream generateFractal() throws IOException {
         ByteArrayOutputStream bos = null;
-        
+
         if (stepInBatch == ZOOM_STEPS_PER_BATCH) {
             stepInBatch = 0;
             reset();
         }
 
         ++stepInBatch;
-        LOG.debug("Generating rect no " + stepInBatch + ": (" + rect.getRMin() + "r," + 
-                rect.getRMax() +  "r, " + rect.getIMin() + "i, " + rect.getIMax() + "i)");
+        LOG.debug("Generating rect no " + stepInBatch + ": (" + rect.getRMin() + "r," + rect.getRMax()
+ "r, "
+                + rect.getIMin() + "i, " + rect.getIMax() + "i)");
         LOG.debug("   width: " + rect.getWidth() + " height: " + rect.getHeight());
         bos = genFractal(rect, juliaPoint);
 
-        double r1New = rect.getWidth() * newColTile / parts +  rect.getRMin();
-        double r2New = rect.getWidth() * (newColTile+1) / parts +  rect.getRMin();
-        double i1New =  rect.getIMax() - (rect.getHeight() * newRowTile / parts);
-        double i2New =  rect.getIMax() - (rect.getHeight() * (newRowTile+1) / parts);
+        double r1New = rect.getWidth() * newColTile / parts + rect.getRMin();
+        double r2New = rect.getWidth() * (newColTile + 1) / parts + rect.getRMin();
+        double i1New = rect.getIMax() - (rect.getHeight() * newRowTile / parts);
+        double i2New = rect.getIMax() - (rect.getHeight() * (newRowTile + 1) / parts);
         rect.set(r1New, r2New, i1New, i2New);
         randomizeRect(rect);
         LOG.debug("Done generating fractals.");
-        
+
         return bos;
     }
 
-    private void randomizeRect( ComplexRectangle rect) {
+    private void randomizeRect(ComplexRectangle rect) {
         double jitterFactor = 0.15; // +/- 15%
-        double ran = Math.random() * jitterFactor +  (1.0 - jitterFactor);
+        double ran = Math.random() * jitterFactor + (1.0 - jitterFactor);
         double width = rect.getWidth() * ran;
-        ran = Math.random() * jitterFactor +  (1.0 - jitterFactor);
+        ran = Math.random() * jitterFactor + (1.0 - jitterFactor);
         double height = rect.getHeight() * ran;
-        ran = Math.random() * jitterFactor +  (1.0 - jitterFactor);
+        ran = Math.random() * jitterFactor + (1.0 - jitterFactor);
         double r1 = (rect.getWidth() - width) * ran + rect.getRMin();
-        ran = Math.random() * jitterFactor +  (1.0 - jitterFactor);
+        ran = Math.random() * jitterFactor + (1.0 - jitterFactor);
         double i1 = (rect.getHeight() - height) * ran + rect.getIMin();
-        rect.set(r1, r1+width, i1, i1+height);
+        rect.set(r1, r1 + width, i1, i1 + height);
     }
 
     /**
-     * Create a fractal image as JPEG in memory and return it  
+     * Create a fractal image as JPEG in memory and return it
+     * 
      * @param rect
-     *      rectangle of mandelbrot or julia set
+     *            rectangle of mandelbrot or julia set
      * @param juliaPoint
-     *      point in Julia set or null
-     * @return
-     *      byte array with JPEG stream
-     * @throws IOException 
+     *            point in Julia set or null
+     * @return byte array with JPEG stream
+     * @throws IOException
      */
     public ByteArrayOutputStream genFractal(ComplexRectangle rect, ComplexPoint juliaPoint)
throws IOException {
 
@@ -174,20 +173,21 @@ public class FractalGenerator {
         findNewRect(image, iterations);
 
         // fast method to write to a file with default options
-        // ImageIO.write((BufferedImage)(image), "jpg", new File("fractal-" + counter++ +
".jpg"));
+        // ImageIO.write((BufferedImage)(image), "jpg", new File("fractal-" +
+        // counter++ + ".jpg"));
 
         // create image in memory
-        ByteArrayOutputStream bos = new ByteArrayOutputStream(200*1024);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(200 * 1024);
         ImageOutputStream ios = ImageIO.createImageOutputStream(bos);
-        Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName( "jpg"
);
+        Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
         ImageWriter imageWriter = writers.next();
 
-        JPEGImageWriteParam params = new JPEGImageWriteParam( Locale.getDefault() );
-        params.setCompressionMode( ImageWriteParam.MODE_EXPLICIT );
-        params.setCompressionQuality( 0.9f );
+        JPEGImageWriteParam params = new JPEGImageWriteParam(Locale.getDefault());
+        params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+        params.setCompressionQuality(0.9f);
 
-        imageWriter.setOutput( ios );
-        imageWriter.write( null, new IIOImage( image, null, null ), params );
+        imageWriter.setOutput(ios);
+        imageWriter.write(null, new IIOImage(image, null, null), params);
         ios.close();
 
         // write memory block to a file
@@ -220,18 +220,21 @@ public class FractalGenerator {
         double complexWidth = rMax - rMin;
         double complexHeight = iMax - iMin;
 
-        if ((imageWidth != 0) && (imageHeight != 0)) {
+        if ((imageWidth > 0) && (imageHeight > 0)) {
             imageWHRatio = ((double) imageWidth / (double) imageHeight);
-        } else
+        } else {
             return;
+        }
 
-        if ((complexWidth != 0) && (complexHeight != 0)) {
+        if ((complexWidth > 0) && (complexHeight > 0)) {
             complexWHRatio = complexWidth / complexHeight;
-        } else
+        } else {
             return;
+        }
 
-        if (imageWHRatio == complexWHRatio)
+        if (Double.compare(imageWHRatio, complexWHRatio) == 0) {
             return;
+        }
 
         if (imageWHRatio < complexWHRatio) {
             // Expand vertically
@@ -263,8 +266,9 @@ public class FractalGenerator {
             magnitude = 1.0;
         }
         double iterations = INITIAL_ITERATIONS * (magnitude * logZoom + 1.0);
-        if (isJulia)
+        if (isJulia) {
             iterations *= 2.0; // Julia sets tend to need more iterations.
+        }
         return (int) iterations;
     }
 
@@ -427,38 +431,42 @@ public class FractalGenerator {
         for (int colorNum = 0; colorNum < numColors; colorNum++) {
             if (colorNum % 2 == 0) {
                 colorMap[colorNum] = Color.white.getRGB();
-                ;
             } else {
                 colorMap[colorNum] = Color.black.getRGB();
-                ;
             }
         }
         colorTable.put(COLORS_ZEBRA, colorMap);
     }
 
-
     private void findNewRect(BufferedImage image, int[][] iterations) {
 
         int newWidth = image.getWidth() / parts;
         int newHeight = image.getHeight() / parts;
-        int i=0, j=0;
-        int noTiles = (image.getWidth() / newWidth) * (image.getHeight() / newHeight); //
equals parts but be aware of rounding errors!;
-        double[] stdDev = new double [noTiles];
+        int i = 0, j = 0;
+        int noTiles = (image.getWidth() / newWidth) * (image.getHeight() / newHeight); //
equals
+                                                                                       //
parts
+                                                                                       //
but
+                                                                                       //
be
+                                                                                       //
aware
+                                                                                       //
of
+                                                                                       //
rounding
+                                                                                       //
errors!;
+        double[] stdDev = new double[noTiles];
 
-        for (int y = 0; y+newHeight <= image.getHeight(); y+=newHeight) {
-            for (int x = 0; x+newWidth <= image.getWidth(); x+=newWidth) {
+        for (int y = 0; y + newHeight <= image.getHeight(); y += newHeight) {
+            for (int x = 0; x + newWidth <= image.getWidth(); x += newWidth) {
                 Rectangle subRect = new Rectangle(x, y, newWidth, newHeight);
-                stdDev[i*parts+j] = calcStdDev(iterations, subRect);
+                stdDev[i * parts + j] = calcStdDev(iterations, subRect);
                 ++j;
             }
             ++i;
-            j=0;
+            j = 0;
         }
 
         // find tile with greatest std deviation:
         double max = 0;
         int index = 0;
-        for (i=0; i<noTiles; i++) {
+        for (i = 0; i < noTiles; i++) {
             if (stdDev[i] > max) {
                 index = i;
                 max = stdDev[i];
@@ -470,21 +478,21 @@ public class FractalGenerator {
 
     private double calcStdDev(int[][] iterations, Rectangle rect) {
 
-        int sum=0;
-        long sumSquare=0;
+        int sum = 0;
+        long sumSquare = 0;
 
-        for (int x = rect.x; x < rect.x+rect.width; x+=1) {
-            for (int y = rect.y; y < rect.y+rect.height; y+=1) {
+        for (int x = rect.x; x < rect.x + rect.width; x += 1) {
+            for (int y = rect.y; y < rect.y + rect.height; y += 1) {
                 int iters = iterations[x][y];
-                sum +=iters;
-                sumSquare +=iters*iters;
+                sum += iters;
+                sumSquare += iters * iters;
             }
         }
         int count = rect.width * rect.height;
         double mean = 0.0;
 
-        mean = sum / count;
-        return Math.sqrt(sumSquare/count - (mean * mean));
+        mean = (double) (sum / count);
+        return Math.sqrt(sumSquare / count - (mean * mean));
     }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java?rev=1511250&r1=1511249&r2=1511250&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java
Wed Aug  7 11:35:42 2013
@@ -31,8 +31,8 @@ import java.util.Set;
 
 /**
  * A generator of lorem ipsum text ported from the Python implementation at
- * http://code.google.com/p/lorem-ipsum-generator/. 
- * Note: original code licensed under the BSD license
+ * http://code.google.com/p/lorem-ipsum-generator/. Note: original code licensed
+ * under the BSD license
  * 
  */
 public class LoremIpsum {
@@ -52,14 +52,14 @@ public class LoremIpsum {
 
         @Override
         public boolean equals(Object other) {
-            if (this == null || other == null)
+            if (this == null || other == null) {
                 return false;
-            if (other.getClass() != WordLengthPair.class)
-                return false;
-            if (len1 == ((WordLengthPair) other).len1 && len2 == ((WordLengthPair)
other).len2)
-                return true;
-            else
+            }
+            if (other.getClass() != getClass()) {
                 return false;
+            }
+
+            return (len1 == ((WordLengthPair) other).len1 && len2 == ((WordLengthPair)
other).len2);
         }
 
         @Override
@@ -242,11 +242,11 @@ public class LoremIpsum {
     /**
      * Generates a single lorem ipsum paragraph, of random length.
      * 
-     * @param {boolean} opt_startWithLorem Whether to start the sentence with
+     * @param {boolean} optStartWithLorem Whether to start the sentence with
      *        the standard "Lorem ipsum..." first sentence.
      * @return {string} The generated sentence.
      */
-    public String generateParagraph(boolean opt_startWithLorem) {
+    public String generateParagraph(boolean optStartWithLorem) {
         // The length of the paragraph is a normally distributed random
         // Objectiable.
         Double paragraphLengthDbl = randomNormal(this.paragraphMean, this.paragraphSigma);
@@ -254,7 +254,7 @@ public class LoremIpsum {
 
         // Construct a paragraph from a number of sentences.
         List<String> paragraph = new ArrayList<String>();
-        boolean startWithLorem = opt_startWithLorem;
+        boolean startWithLorem = optStartWithLorem;
         while (paragraph.size() < paragraphLength) {
             String sentence = this.generateSentence(startWithLorem);
             paragraph.add(sentence);
@@ -273,11 +273,11 @@ public class LoremIpsum {
     /**
      * Generates a single sentence, of random length.
      * 
-     * @param {boolean} opt_startWithLorem Whether to start the setnence with
+     * @param {boolean} optStartWithLorem Whether to start the setnence with
      *        the standard "Lorem ipsum..." first sentence.
      * @return {string} The generated sentence.
      */
-    public String generateSentence(boolean opt_startWithLorem) {
+    public String generateSentence(boolean optStartWithLorem) {
         if (this.chains.size() == 0 || this.starts.size() == 0) {
             throw new RuntimeException("No chains created (Invalid sample text?)");
         }
@@ -296,8 +296,8 @@ public class LoremIpsum {
 
         // Start the sentence with "Lorem ipsum...", if desired
         List<String> sentence;
-        ;
-        if (opt_startWithLorem) {
+
+        if (optStartWithLorem) {
             String lorem = "lorem ipsum dolor sit amet, consecteteur adipiscing elit";
             sentence = new ArrayList<String>(Arrays.asList(splitWords(lorem)));
             if (sentence.size() > sentenceLength) {
@@ -405,11 +405,12 @@ public class LoremIpsum {
         text.append(end);
         return text.toString();
     }
-    
+
     /**
      * Generates multiple paragraphs of text, with begin before the paragraphs,
      * end after the paragraphs, and between between each two paragraphs.
-     * @throws IOException 
+     * 
+     * @throws IOException
      */
     private void generateMarkupParagraphs(Appendable writer, String begin, String end, String
between, int quantity,
             boolean startWithLorem) throws IOException {
@@ -431,6 +432,7 @@ public class LoremIpsum {
 
         writer.append(end);
     }
+
     /**
      * Generates multiple sentences of text, with begin before the sentences,
      * end after the sentences, and between between each two sentences.
@@ -446,8 +448,9 @@ public class LoremIpsum {
         while (text.length() < quantity) {
             sentence = generateSentence(false);
             text.append(sentence);
-            if (text.length() < quantity)
+            if (text.length() < quantity) {
                 text.append(between);
+            }
         }
 
         text.append(end);
@@ -470,17 +473,20 @@ public class LoremIpsum {
         Map<WordLengthPair, List<WordInfo>> chains = new HashMap<WordLengthPair,
List<WordInfo>>();
 
         for (WordInfo wi : wordInfos) {
-            if (wi.len == 0)
+            if (wi.len == 0) {
                 continue;
+            }
 
             List<WordInfo> value = chains.get(previous);
-            if (null == value)
+            if (null == value) {
                 chains.put(previous, new ArrayList<WordInfo>());
-            else
+            } else {
                 chains.get(previous).add(wi);
+            }
 
-            if (delimList.contains(wi.delim))
+            if (delimList.contains(wi.delim)) {
                 starts.add(previous);
+            }
 
             previous.len1 = previous.len2;
             previous.len2 = wi.len;
@@ -632,8 +638,9 @@ public class LoremIpsum {
     static int chooseClosest(Integer[] values, int target) {
         int closest = values[0];
         for (int value : values) {
-            if (Math.abs(target - value) < Math.abs(target - closest))
+            if (Math.abs(target - value) < Math.abs(target - closest)) {
                 closest = value;
+            }
         }
 
         return closest;
@@ -664,8 +671,9 @@ public class LoremIpsum {
     static private WordInfo[] generateWordInfo(String[] words) {
         WordInfo[] result = new WordInfo[words.length];
         int i = 0;
-        for (String word : words)
+        for (String word : words) {
             result[i++] = getWordInfo(word);
+        }
         return result;
     }
 
@@ -710,8 +718,9 @@ public class LoremIpsum {
         List<String> result = new ArrayList<String>();
         for (String s : arr) {
             String trims = s.trim();
-            if (trims.length() > 0)
+            if (trims.length() > 0) {
                 result.add(trims);
+            }
         }
         return result;
     }
@@ -726,8 +735,9 @@ public class LoremIpsum {
 
     public static double variance(double[] values) {
         double[] squared = new double[values.length];
-        for (int i = 0; i < values.length; i++)
+        for (int i = 0; i < values.length; i++) {
             squared[i] = values[i] * values[i];
+        }
 
         double meanVal = mean(values);
         return mean(squared) - (meanVal * meanVal);
@@ -735,8 +745,9 @@ public class LoremIpsum {
 
     public static double sigma(int[] values) {
         double[] d = new double[values.length];
-        for (int i = 0; i < values.length; i++)
+        for (int i = 0; i < values.length; i++) {
             d[i] = (double) values[i];
+        }
 
         return sigma(d);
     }
@@ -747,22 +758,25 @@ public class LoremIpsum {
 
     public static int sum(int[] values) {
         int sum = 0;
-        for (int val : values)
+        for (int val : values) {
             sum += val;
+        }
         return sum;
     }
 
     public static double sum(double[] values) {
         double sum = 0.0d;
-        for (double val : values)
+        for (double val : values) {
             sum += val;
+        }
         return sum;
     }
 
     public static boolean contains(String[] array, String val) {
         for (String s : array)
-            if (s.equals(val))
+            if (s.equals(val)) {
                 return true;
+            }
         return false;
     }
 
@@ -994,16 +1008,15 @@ public class LoremIpsum {
      * @param writer
      * @param quantity
      * @param startWithLorem
-     * @throws IOException 
+     * @throws IOException
      */
     public void generateParagraphsHtml(Appendable writer, int quantity, boolean startWithLorem)
throws IOException {
 
-        generateMarkupParagraphs(writer, "<p>" + LINE_SEPARATOR + "\t", LINE_SEPARATOR
+ "</p>", LINE_SEPARATOR + "</p>"
-                + LINE_SEPARATOR + "<p>" + LINE_SEPARATOR + "\t", quantity, startWithLorem);
+        generateMarkupParagraphs(writer, "<p>" + LINE_SEPARATOR + "\t", LINE_SEPARATOR
+ "</p>", LINE_SEPARATOR
+                + "</p>" + LINE_SEPARATOR + "<p>" + LINE_SEPARATOR + "\t", quantity,
startWithLorem);
 
     }
-    
-    
+
     /**
      * Generates one paragraph of HTML, surrounded by HTML pararaph tags.
      * 
@@ -1036,8 +1049,7 @@ public class LoremIpsum {
                 + "</p>" + LINE_SEPARATOR + postfix, LINE_SEPARATOR + "</p>"
+ LINE_SEPARATOR + "<p>" + LINE_SEPARATOR
                 + "\t", quantity, startWithLorem);
     }
-    
-    
+
     /**
      * Generates a number of paragraphs, with each paragraph surrounded by HTML
      * paragraph tags as a full HTML page.
@@ -1045,7 +1057,7 @@ public class LoremIpsum {
      * @param writer
      * @param quantity
      * @param startWithLorem
-     * @throws IOException 
+     * @throws IOException
      */
     public void generateParagraphsFullHtml(Appendable writer, int quantity, boolean startWithLorem)
throws IOException {
 
@@ -1057,8 +1069,7 @@ public class LoremIpsum {
                 + "</p>" + LINE_SEPARATOR + postfix, LINE_SEPARATOR + "</p>"
+ LINE_SEPARATOR + "<p>" + LINE_SEPARATOR
                 + "\t", quantity, startWithLorem);
     }
-    
-    
+
     /**
      * Generates a number of paragraphs, with each paragraph separated by two
      * newlines.
@@ -1079,7 +1090,7 @@ public class LoremIpsum {
      * @param writer
      * @param quantity
      * @param startWithLorem
-     * @throws IOException 
+     * @throws IOException
      */
     public void generateParagraphsPlainText(Appendable writer, int quantity, boolean startWithLorem)
throws IOException {
 
@@ -1112,17 +1123,18 @@ public class LoremIpsum {
      * @param writer
      * @param quantity
      * @param startWithLorem
-     * @throws IOException 
+     * @throws IOException
      */
-    public void generateParagraphsPlainText(Appendable writer, int quantity, int maxCols,
boolean startWithLorem) throws IOException {
+    public void generateParagraphsPlainText(Appendable writer, int quantity, int maxCols,
boolean startWithLorem)
+            throws IOException {
 
         String delims = " .,?!";
         String unformatted = generateMarkupParagraphs("", "", LINE_SEPARATOR + LINE_SEPARATOR,
quantity, startWithLorem);
         int len = unformatted.length();
 
-        if (maxCols <= 0)
+        if (maxCols <= 0) {
             writer.append(unformatted);
-        else {
+        } else {
             int startPos = 0;
             while (startPos < len - 1) {
                 int endPos = Math.min(startPos + maxCols, len - 1);
@@ -1148,8 +1160,9 @@ public class LoremIpsum {
                     }
                 }
                 writer.append(unformatted.substring(startPos, endPos + 1));
-                if (unformatted.charAt(endPos) != '\n')
+                if (unformatted.charAt(endPos) != '\n') {
                     writer.append(LINE_SEPARATOR);
+                }
                 startPos = endPos + 1;
             }
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1511250&r1=1511249&r2=1511250&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
Wed Aug  7 11:35:42 2013
@@ -396,7 +396,7 @@ public class TckDialog {
         }
     }
 
-    private class TestTreeNodeRender extends JCheckBox implements TreeCellRenderer {
+    private static class TestTreeNodeRender extends JCheckBox implements TreeCellRenderer
{
         private static final long serialVersionUID = 1L;
 
         private final Color textSelectionColor;
@@ -459,7 +459,7 @@ public class TckDialog {
         }
     }
 
-    private class TestTreeNodeEditor extends AbstractCellEditor implements TreeCellEditor
{
+    private static class TestTreeNodeEditor extends AbstractCellEditor implements TreeCellEditor
{
         private static final long serialVersionUID = 1L;
 
         private TestTreeNodeRender lastObject;



Mime
View raw message