X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fservices%2FComponentNamingStrategyBase.java;h=a669fb4650679aaac5cf8771f55df2048f222fdc;hb=d85a4d990c5cac9d0c70781a265f02888b3aaa43;hp=0d9f1fe5260cc7e324cda88a62a4ebb7c188806e;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/services/ComponentNamingStrategyBase.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/services/ComponentNamingStrategyBase.java
index 0d9f1fe52..a669fb465 100644
--- a/bundles/org.simantics.modeling/src/org/simantics/modeling/services/ComponentNamingStrategyBase.java
+++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/services/ComponentNamingStrategyBase.java
@@ -1,276 +1,276 @@
-package org.simantics.modeling.services;
-
-import java.nio.CharBuffer;
-import java.util.Comparator;
-import java.util.Formatter;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.simantics.db.ReadGraph;
-import org.simantics.db.Resource;
-import org.simantics.db.exception.DatabaseException;
-
-/**
- * An abstract base class that contains some helpers for implementing your own
- * {@link ComponentNamingStrategy}. A default implementation is also provided
- * for {@link #findFreshInstanceName(ReadGraph, Resource, Resource, Resource)}
- * based on the Layer0 ontology HasGeneratedNamePrefix property.
- *
- * @author Tuukka Lehtonen
- */
-public abstract class ComponentNamingStrategyBase implements ComponentNamingStrategy {
-
- protected static final boolean DEBUG_ALL = false;
- protected static final boolean DEBUG_NAME_MATCHING = false | DEBUG_ALL;
-
- protected final String generatedNameFormat;
- protected final boolean caseInsensitive;
-
- /**
- * Base constructor for a naming strategy with the specified format as the
- * generated name format. The format will receive two arguments:
- *
- *
proposed name as {@link String}
- *
an {@link Integer} that attempts to make the name unique within a
- * context
- *
- * The simplest format specification utilizing both values is
- * "%s %d", producing "FOO 1". Another example of a useful name
- * format is "%s%04d", producing "FOO0001". Reordering the
- * arguments is also possible, e.g. "%2$03d %1$s", producing
- * "001 FOO".
- *
- *
- * See {@link Formatter} for the format specification and how to customize
- * it.
- *
- *
- * This constructor will create a case-insensitive naming strategy.
- *
- * @param generatedNameFormat the format to use for generated names
- */
- public ComponentNamingStrategyBase(String generatedNameFormat) {
- this(generatedNameFormat, true);
- }
-
- /**
- * Base constructor for a naming strategy with the specified format as the
- * generated name format. The format will receive two arguments:
- *
- *
proposed name as {@link String}
- *
an {@link Integer} that attempts to make the name unique within a
- * context
- *
- * The simplest format specification utilizing both values is
- * "%s %d", producing "FOO 1". Another example of a useful name
- * format is "%s%04d", producing "FOO0001". Reordering the
- * arguments is also possible, e.g. "%2$03d %1$s", producing
- * "001 FOO".
- *
- *
- * See {@link Formatter} for the format specification and how to customize
- * it.
- *
- * @param generatedNameFormat the format to use for generated names
- * @param caseInsensitive controls whether the strategy shall be case-insensitive or not
- */
- public ComponentNamingStrategyBase(String generatedNameFormat, boolean caseInsensitive) {
- this.generatedNameFormat = generatedNameFormat;
- this.caseInsensitive = caseInsensitive;
- }
-
- @Override
- public String findFreshInstanceName(ReadGraph graph, Resource configurationRoot, Resource container,
- Resource componentType) throws NamingException, DatabaseException {
- String proposition = ComponentNamingUtil.generateProposition(graph, container, componentType);
- return validateInstanceName(graph, configurationRoot, container, componentType, proposition);
- }
-
- @Override
- public String validateInstanceName(ReadGraph graph, Resource configurationRoot, Resource container,
- Resource componentType, String proposition) throws NamingException, DatabaseException {
- return validateInstanceName(graph, configurationRoot, container, componentType, proposition, false);
- }
-
- @Override
- public List validateInstanceNames(
- ReadGraph graph,
- Resource configurationRoot,
- List propositions,
- boolean acceptProposition,
- Set externallyReserved)
- throws NamingException, DatabaseException
- {
- throw new UnsupportedOperationException();
- }
-
- protected Comparator