diff --git a/FileSync-test/.settings/org.eclipse.jdt.ui.prefs b/FileSync-test/.settings/org.eclipse.jdt.ui.prefs
index b8cce28..91f18bf 100644
--- a/FileSync-test/.settings/org.eclipse.jdt.ui.prefs
+++ b/FileSync-test/.settings/org.eclipse.jdt.ui.prefs
@@ -12,12 +12,12 @@ org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.text.custom_code_templates=/**\r\n * @return the ${bare_field_name}\r\n *//**\r\n * @param ${param} the ${bare_field_name} to set\r\n *//**\r\n * ${tags}\r\n *//*******************************************************************************\r\n * Copyright (c) 2009 Andrei Loskutov.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors\:\r\n * Andrei Loskutov - initial API and implementation\r\n *******************************************************************************//**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n *//**\r\n * \r\n *//**\r\n * ${tags}\r\n *//**\r\n * ${tags}\r\n * ${see_to_target}\r\n */${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}\r\n\r\n\r\n\r\n// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();// ${todo} Auto-generated method stub\r\n${body_statement}${body_statement}\r\n// ${todo} Auto-generated constructor stubreturn ${field};${field} \= ${param};
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=false
+sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
diff --git a/FileSync-test/src/test/CopyDelegate2.java b/FileSync-test/src/test/CopyDelegate2.java
index e635739..49c736c 100644
--- a/FileSync-test/src/test/CopyDelegate2.java
+++ b/FileSync-test/src/test/CopyDelegate2.java
@@ -31,99 +31,100 @@
* @author Andrei
*/
public class CopyDelegate2 extends CopyDelegate {
- private Map/**/ patternToValue;
- private Map/**/ patternToKey;
+ private Map patternToValue;
+ private Map patternToKey;
- public void setPropertiesMap(Properties propertiesMap) {
- if(getPropertiesMap() != propertiesMap) {
- super.setPropertiesMap(propertiesMap);
- initPatterns();
- }
- }
+ @Override
+ public void setPropertiesMap(Properties propertiesMap) {
+ if(getPropertiesMap() != propertiesMap) {
+ super.setPropertiesMap(propertiesMap);
+ initPatterns();
+ }
+ }
- /**
- * Single file copy operation with replacement of variables on the fly.
- * Implementation reads and writes line by line, so that bug files could be proceeded
- * @param source - should be file only
- * @param destination - should be already created
- * @return true if source was successfully copied
- */
- protected boolean copyInternal(File source, File destination) {
+ /**
+ * Single file copy operation with replacement of variables on the fly.
+ * Implementation reads and writes line by line, so that bug files could be proceeded
+ * @param source - should be file only
+ * @param destination - should be already created
+ * @return true if source was successfully copied
+ */
+ @Override
+ protected boolean copyInternal(File source, File destination) {
- boolean success = true;
- FileInputStream fin = null;
- FileOutputStream fout = null;
+ boolean success = true;
+ FileInputStream fin = null;
+ FileOutputStream fout = null;
- try {
- // Open the file and then get a channel from the stream
- fin = new FileInputStream(source);
- fout = new FileOutputStream(destination);
+ try {
+ // Open the file and then get a channel from the stream
+ fin = new FileInputStream(source);
+ fout = new FileOutputStream(destination);
- LineReader reader = new LineReader(fin, encoding);
- LineWriter writer = new LineWriter(fout, encoding);
- String line = null;
- while((line = reader.readLineToString()) != null){
- for (Iterator i = patternToValue.keySet().iterator(); i.hasNext();) {
- Pattern pattern = (Pattern) i.next();
- if(line.indexOf((String) patternToKey.get(pattern)) < 0 ){
- continue;
- }
- String value = (String) patternToValue.get(pattern);
- line = pattern.matcher(line).replaceAll(value);
- }
- writer.writeLine(line);
- }
- writer.flush();
- } catch (IOException e) {
- if (FS.enableLogging) {
- FileSyncPlugin.log("Could not copy file '" + source + "' to '"
- + destination + "'", e, IStatus.WARNING);
- }
- success = false;
- } finally {
- // Always close input and output streams.
- if (fin != null) {
- try {
- fin.close();
- } catch (IOException e) {
- if (FS.enableLogging) {
- FileSyncPlugin.log("Could not close file stream for file '"
- + source + "'", e, IStatus.WARNING);
- }
- success = false;
- }
- }
- if (fout != null) {
- try {
- fout.close();
- if (!useCurrentDateForDestinationFiles) {
- destination.setLastModified(source.lastModified());
- } else {
- // should be updated by system I/O
- }
- } catch (IOException e) {
- if (FS.enableLogging) {
- FileSyncPlugin.log("Could not close file stream for file '"
- + destination + "'", e, IStatus.WARNING);
- }
- success = false;
- }
- }
- }
- return success;
- }
+ LineReader reader = new LineReader(fin, encoding);
+ LineWriter writer = new LineWriter(fout, encoding);
+ String line = null;
+ while((line = reader.readLineToString()) != null){
+ for (Iterator i = patternToValue.keySet().iterator(); i.hasNext();) {
+ Pattern pattern = (Pattern) i.next();
+ if(line.indexOf(patternToKey.get(pattern)) < 0 ){
+ continue;
+ }
+ String value = patternToValue.get(pattern);
+ line = pattern.matcher(line).replaceAll(value);
+ }
+ writer.writeLine(line);
+ }
+ writer.flush();
+ } catch (IOException e) {
+ if (FS.enableLogging) {
+ FileSyncPlugin.log("Could not copy file '" + source + "' to '"
+ + destination + "'", e, IStatus.WARNING);
+ }
+ success = false;
+ } finally {
+ // Always close input and output streams.
+ if (fin != null) {
+ try {
+ fin.close();
+ } catch (IOException e) {
+ if (FS.enableLogging) {
+ FileSyncPlugin.log("Could not close file stream for file '"
+ + source + "'", e, IStatus.WARNING);
+ }
+ success = false;
+ }
+ }
+ if (fout != null) {
+ try {
+ fout.close();
+ if (!useCurrentDateForDestinationFiles) {
+ destination.setLastModified(source.lastModified());
+ } else {
+ // should be updated by system I/O
+ }
+ } catch (IOException e) {
+ if (FS.enableLogging) {
+ FileSyncPlugin.log("Could not close file stream for file '"
+ + destination + "'", e, IStatus.WARNING);
+ }
+ success = false;
+ }
+ }
+ }
+ return success;
+ }
- private void initPatterns() {
- patternToValue = new HashMap();
- patternToKey = new HashMap();
- Set keySet = variablesMap.keySet();
- for (Iterator i = keySet.iterator(); i.hasNext();) {
- String key = (String) i.next();
- Pattern pattern = Pattern.compile("\\$\\{" + key + "\\}");
- patternToValue.put(pattern, variablesMap.get(key));
- patternToKey.put(pattern, key);
- }
- }
+ private void initPatterns() {
+ patternToValue = new HashMap();
+ patternToKey = new HashMap();
+ Set keySet = variablesMap.stringPropertyNames();
+ for (String key : keySet) {
+ Pattern pattern = Pattern.compile("\\$\\{" + key + "\\}");
+ patternToValue.put(pattern, variablesMap.getProperty(key));
+ patternToKey.put(pattern, key);
+ }
+ }
}
diff --git a/FileSync-test/src/test/TestBuilder.java b/FileSync-test/src/test/TestBuilder.java
index 01cfb89..230b6cb 100644
--- a/FileSync-test/src/test/TestBuilder.java
+++ b/FileSync-test/src/test/TestBuilder.java
@@ -710,9 +710,10 @@ public boolean visit(IResource resource) throws CoreException {
if (!absolutePath.endsWith(SUFFIX_ORIG_FILE)) {
File origFile = new File(absolutePath + SUFFIX_ORIG_FILE);
if (origFile.exists()) {
- assertEquals(origFile.length(), destFile.length());
+ String message = "File content differ: Expected: " + origFile + ", \n\tSeen: " + destFile;
+ assertEquals(message, origFile.length(), destFile.length());
boolean same = TestFS.isSame(destFile, origFile, true, false);
- assertTrue(same);
+ assertTrue(message, same);
} else {
assertEquals(srcFile.length(), destFile.length());
}
diff --git a/FileSync/.settings/org.eclipse.jdt.ui.prefs b/FileSync/.settings/org.eclipse.jdt.ui.prefs
index 7efa61f..e95ffa5 100644
--- a/FileSync/.settings/org.eclipse.jdt.ui.prefs
+++ b/FileSync/.settings/org.eclipse.jdt.ui.prefs
@@ -1,62 +1,63 @@
-#Sun May 30 17:21:00 CEST 2010
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_Andrei (Eclipse [built-in])
-formatter_settings_version=11
-internal.default.compliance=default
-org.eclipse.jdt.ui.exception.name=e
-org.eclipse.jdt.ui.gettersetter.use.is=true
-org.eclipse.jdt.ui.keywordthis=false
-org.eclipse.jdt.ui.overrideannotation=true
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=false
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=false
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=false
-sp_cleanup.always_use_this_for_non_static_field_access=false
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_to_enhanced_for_loop=false
-sp_cleanup.correct_indentation=true
-sp_cleanup.format_source_code=false
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.make_local_variable_final=false
-sp_cleanup.make_parameters_final=false
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=true
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=true
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=true
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
-sp_cleanup.remove_private_constructors=false
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=true
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=true
-sp_cleanup.remove_unnecessary_nls_tags=true
-sp_cleanup.remove_unused_imports=true
-sp_cleanup.remove_unused_local_variables=true
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=true
-sp_cleanup.remove_unused_private_methods=false
-sp_cleanup.remove_unused_private_types=false
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_blocks=true
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_parentheses_in_expressions=false
-sp_cleanup.use_this_for_non_static_field_access=false
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-sp_cleanup.use_this_for_non_static_method_access=false
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+#Sat Oct 02 13:19:37 CEST 2010
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Andrei (Eclipse [built-in])
+formatter_settings_version=11
+internal.default.compliance=default
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=false
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=true
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=true
+sp_cleanup.remove_unused_private_methods=false
+sp_cleanup.remove_unused_private_types=false
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/FileSync/src/de/loskutov/fs/command/CopyDelegate.java b/FileSync/src/de/loskutov/fs/command/CopyDelegate.java
index 5ab770a..72a2ed1 100644
--- a/FileSync/src/de/loskutov/fs/command/CopyDelegate.java
+++ b/FileSync/src/de/loskutov/fs/command/CopyDelegate.java
@@ -4,7 +4,6 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Iterator;
import java.util.Properties;
import org.eclipse.core.runtime.IStatus;
@@ -33,7 +32,7 @@ public class CopyDelegate {
public CopyDelegate() {
super();
-// setEncoding("ISO-8859-1");
+ // setEncoding("ISO-8859-1");
}
@@ -87,8 +86,8 @@ protected boolean copyInternal(File source, File destination) {
byte[] array = new byte[size];
fin.read(array, 0, size);
String string = new String(array, encoding);
- for (Iterator i = variablesMap.keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
+ for (Object name : variablesMap.keySet()) {
+ String key = (String) name;
String value = (String) variablesMap.get(key);
if(string.indexOf(key) >= 0) {
string = string.replaceAll("\\$\\{" + key + "\\}", value);
diff --git a/FileSync/src/de/loskutov/fs/command/CopyDelegate1.java b/FileSync/src/de/loskutov/fs/command/CopyDelegate1.java
index 87364e6..5528f25 100644
--- a/FileSync/src/de/loskutov/fs/command/CopyDelegate1.java
+++ b/FileSync/src/de/loskutov/fs/command/CopyDelegate1.java
@@ -27,9 +27,10 @@
* @author Andrei
*/
public class CopyDelegate1 extends CopyDelegate {
- private Map/**/ patternToValue;
- private Map/**/ patternToKey;
+ private Map patternToValue;
+ private Map patternToKey;
+ @Override
public void setPropertiesMap(Properties propertiesMap) {
if(getPropertiesMap() != propertiesMap) {
super.setPropertiesMap(propertiesMap);
@@ -44,6 +45,7 @@ public void setPropertiesMap(Properties propertiesMap) {
* @param destination - should be already created
* @return true if source was successfully copied
*/
+ @Override
protected boolean copyInternal(File source, File destination) {
boolean success = true;
@@ -56,12 +58,12 @@ protected boolean copyInternal(File source, File destination) {
writer = new LineWriter(new FileOutputStream(destination), encoding);
String line = null;
while((line = reader.readLineToString()) != null){
- for (Iterator i = patternToValue.keySet().iterator(); i.hasNext();) {
- Pattern pattern = (Pattern) i.next();
- if(line.indexOf((String) patternToKey.get(pattern)) < 0 ){
+ for (Iterator i = patternToValue.keySet().iterator(); i.hasNext();) {
+ Pattern pattern = i.next();
+ if(line.indexOf(patternToKey.get(pattern)) < 0 ){
continue;
}
- String value = (String) patternToValue.get(pattern);
+ String value = patternToValue.get(pattern);
line = pattern.matcher(line).replaceAll(value);
}
writer.writeLine(line);
@@ -111,13 +113,12 @@ protected boolean copyInternal(File source, File destination) {
}
private void initPatterns() {
- patternToValue = new HashMap();
- patternToKey = new HashMap();
- Set keySet = variablesMap.keySet();
- for (Iterator i = keySet.iterator(); i.hasNext();) {
- String key = (String) i.next();
+ patternToValue = new HashMap();
+ patternToKey = new HashMap();
+ Set keySet = variablesMap.stringPropertyNames();
+ for (String key : keySet) {
Pattern pattern = Pattern.compile("\\$\\{" + key + "\\}");
- patternToValue.put(pattern, variablesMap.get(key));
+ patternToValue.put(pattern, variablesMap.getProperty(key));
patternToKey.put(pattern, key);
}
}