]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentFunctionNamingStrategy.java
Replace System.err and System.out with SLF4J Logging
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / services / CaseInsensitiveComponentFunctionNamingStrategy.java
index 40115a1ac393c564017d21420dae13fe20302dea..feef9c8992fce52eec3e4417e45897762bf06b03 100644 (file)
@@ -32,9 +32,10 @@ import org.simantics.db.service.GraphChangeListenerSupport;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.function.Function1;
-import org.simantics.scl.runtime.tuple.Tuple3;
 import org.simantics.scl.runtime.tuple.Tuple4;
 import org.simantics.structural.stubs.StructuralResource2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.set.hash.THashSet;
 
@@ -52,6 +53,7 @@ import gnu.trove.set.hash.THashSet;
  */
 public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNamingStrategyBase {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentFunctionNamingStrategy.class);
     protected static final boolean                                  DEBUG_INDEX_SEARCH = false | DEBUG_ALL;
 
     @SuppressWarnings("rawtypes")
@@ -140,7 +142,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                         Set<Resource> rs = new THashSet<Resource>();
                         for (Resource componentResult : components) {
                             if (DEBUG_INDEX_SEARCH)
-                                System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+                                LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
                             String n = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
                             if (n != null && n.toLowerCase().equals(lowercaseName))
                                rs.add(componentResult);
@@ -194,13 +196,13 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
             Layer0 L0 = Layer0.getInstance(graph);
             for (Resource componentResult : components) {
                 if (DEBUG_INDEX_SEARCH)
-                    System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+                    LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
                 String name = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
                 if (name != null)
                     reserved.add(name);
             }
             
-            System.err.println("found " + reserved.size() + " components");
+            LOGGER.warn("found " + reserved.size() + " components");
             
             return reserved;
 
@@ -213,7 +215,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
             Resource componentType, String proposition, boolean acceptProposition) throws NamingException, DatabaseException {
         Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(configurationRoot));
         if (indexRoot == null) {
-            System.err.println("Could not find index root from configuration root '" + NameUtils.getSafeName(graph, configurationRoot, true) + "'");
+            LOGGER.warn("Could not find index root from configuration root '" + NameUtils.getSafeName(graph, configurationRoot, true) + "'");
             if(fallbackStrategy == null)
                 fallbackStrategy = 
                     new CaseInsensitiveComponentNamingStrategy2(graph.getService(GraphChangeListenerSupport.class), generatedNameFormat);
@@ -237,7 +239,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
             cache.addRequested(result);
 
             if (DEBUG_INDEX_SEARCH)
-                System.out.println(getClass().getSimpleName() + ": validated instance name " + result);
+                LOGGER.info(getClass().getSimpleName() + ": validated instance name " + result);
 
             return result;
         }
@@ -270,14 +272,14 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                 List<Resource> components = (List<Resource>) index.apply(graph, indexRoot, search, Integer.MAX_VALUE);
 
                 if (DEBUG_INDEX_SEARCH)
-                    System.out.println(getClass().getSimpleName() + ": found " + components.size()
+                    LOGGER.info(getClass().getSimpleName() + ": found " + components.size()
                             + " index results for index root " + indexRoot + " & configurationRoot " + configurationRoot
                             + " & proposition '" + proposition + "':");
 
                 reserved.clear();
                 for (Resource componentResult : components) {
                     if (DEBUG_INDEX_SEARCH)
-                        System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+                        LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
                     String name = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
                     if (name != null)
                         reserved.add(name);
@@ -291,11 +293,11 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                 result.add(name);
 
                 if (DEBUG_INDEX_SEARCH)
-                    System.out.println(getClass().getSimpleName() + ": validated instance name " + proposition + " -> " + name);
+                    LOGGER.info(getClass().getSimpleName() + ": validated instance name " + proposition + " -> " + name);
             }
 
             if (DEBUG_INDEX_SEARCH)
-                System.out.println(getClass().getSimpleName() + ": validated instance names " + propositions + " -> " + result);
+                LOGGER.info(getClass().getSimpleName() + ": validated instance names " + propositions + " -> " + result);
 
             return result;
         }