import static org.tizen.common.core.command.Policy.EXIST_OUT_FILE;
import static org.tizen.common.core.command.Policy.NONEXIST_IN_FILE;
+import static org.tizen.common.core.command.Policy.EXCEPTION_UNHANDLED;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.core.command.policy.MessagePolicy;
import org.tizen.common.core.command.policy.OptionPolicy;
import org.tizen.common.core.command.policy.PolicyRegistry;
+import org.tizen.common.core.command.policy.UncaughtExceptionHandlingPolicy;
import org.tizen.common.core.command.prompter.FileHandlingOption;
/**
PolicyRegistryFactory
implements Factory<PolicyRegistry>
{
- /**
- * Logger for this instance
- */
- protected final Logger logger =
- LoggerFactory.getLogger( PolicyRegistryFactory.class );
-
- /**
- * <p>
- * CLIPolicy.
- *
- * {@link Policy} when command line interface
- * </p>
- *
- * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
- *
- * @see PolicyRegistry, {@link Policy}
- */
- class CLIPolicy
- extends AbstractPolicy
- {
- /**
- * <p>
- * Constructor with <code>name</code>
- * </p>
- *
- * @param name policy name
- */
- public CLIPolicy( final String name )
- {
- super( name );
- }
+ /**
+ * Logger for this instance
+ */
+ protected final Logger logger =
+ LoggerFactory.getLogger( PolicyRegistryFactory.class );
+
+ /**
+ * <p>
+ * CLIPolicy.
+ *
+ * {@link Policy} when command line interface
+ * </p>
+ *
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ *
+ * @see PolicyRegistry, {@link Policy}
+ */
+ class CLIPolicy
+ extends AbstractPolicy
+ {
+ /**
+ * <p>
+ * Constructor with <code>name</code>
+ * </p>
+ *
+ * @param name policy name
+ */
+ public CLIPolicy( final String name )
+ {
+ super( name );
+ }
- /* (non-Javadoc)
- * @see org.tizen.common.Adaptable#adapt(java.lang.Class)
- */
- @Override
- @SuppressWarnings("unchecked")
- public <T>
- T
- adapt(
- final Class<T> clazz
- )
- {
- if ( clazz.isAssignableFrom( FilePolicy.class ) )
- {
- return (T) FilePolicy.STOP_PROCESS;
- }
- else if ( clazz.isAssignableFrom( MessagePolicy.class) )
- {
- return (T) MessagePolicy.PROMPTER;
- }
- return null;
- }
+ /* (non-Javadoc)
+ * @see org.tizen.common.Adaptable#adapt(java.lang.Class)
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T>
+ T
+ adapt(
+ final Class<T> clazz
+ )
+ {
+ if ( clazz.isAssignableFrom( FilePolicy.class ) )
+ {
+ return (T) FilePolicy.STOP_PROCESS;
+ }
+ else if ( clazz.isAssignableFrom( MessagePolicy.class) )
+ {
+ return (T) MessagePolicy.PROMPTER;
+ }
+ else if ( clazz.isAssignableFrom( UncaughtExceptionHandlingPolicy.class ) )
+ {
+ return (T) UncaughtExceptionHandlingPolicy.INSTANCE;
+ }
+ return null;
+ }
- }
- /* (non-Javadoc)
- * @see org.tizen.common.Factory#create()
- */
- @Override
- public
- PolicyRegistry
- create()
- {
- final PolicyRegistry registry = new PolicyRegistry();
-
- registry.register( new CLIPolicy( EXIST_OUT_FILE ) );
- registry.register( new CLIPolicy( NONEXIST_IN_FILE ) );
-
- CLIPolicy existFileWhenCopy = new CLIPolicy(Policy.EXIST_FILE_WHEN_COPY) {
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T adapt(Class<T> clazz) {
- return (T)(new OptionPolicy(FileHandlingOption.OVERWRITE, FileHandlingOption.IGNORE, FileHandlingOption.OVERWRITE_ALL, FileHandlingOption.IGNORE_ALL, FileHandlingOption.CANCEL));
- }
- };
-
- registry.register(existFileWhenCopy);
- return registry;
- }
+ }
+ /* (non-Javadoc)
+ * @see org.tizen.common.Factory#create()
+ */
+ @Override
+ public
+ PolicyRegistry
+ create()
+ {
+ final PolicyRegistry registry = new PolicyRegistry();
+
+ registry.register( new CLIPolicy( EXIST_OUT_FILE ) );
+ registry.register( new CLIPolicy( NONEXIST_IN_FILE ) );
+ registry.register( new CLIPolicy( EXCEPTION_UNHANDLED ) );
+
+ CLIPolicy existFileWhenCopy = new CLIPolicy(Policy.EXIST_FILE_WHEN_COPY) {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(Class<T> clazz) {
+ return (T)(new OptionPolicy(FileHandlingOption.OVERWRITE, FileHandlingOption.IGNORE, FileHandlingOption.OVERWRITE_ALL, FileHandlingOption.IGNORE_ALL, FileHandlingOption.CANCEL));
+ }
+ };
+
+ registry.register(existFileWhenCopy);
+ return registry;
+ }
}