Commits

P_W999 committed 68423ef

- hiding the action implementations using interfaces

  • Participants
  • Parent commits 87ab6a8

Comments (0)

Files changed (17)

src/be/pw/jexif/internal/action/ITagReadAction.java

+package be.pw.jexif.internal.action;
+
+public interface ITagReadAction extends IAction {
+
+}

src/be/pw/jexif/internal/action/ITagReadAllAction.java

+package be.pw.jexif.internal.action;
+
+public interface ITagReadAllAction extends IAction {
+
+}

src/be/pw/jexif/internal/action/ITagReadExactAction.java

+package be.pw.jexif.internal.action;
+
+public interface ITagReadExactAction extends IAction {
+
+}

src/be/pw/jexif/internal/action/ITagReadExactAllAction.java

+package be.pw.jexif.internal.action;
+
+
+public interface ITagReadExactAllAction extends IAction {
+
+}

src/be/pw/jexif/internal/action/ITagWriteAction.java

+package be.pw.jexif.internal.action;
+
+public interface ITagWriteAction extends IAction {
+
+}

src/be/pw/jexif/internal/action/impl/ActionFactory.java

 
 import be.pw.jexif.enums.tag.Tag;
 import be.pw.jexif.exception.JExifValidationException;
+import be.pw.jexif.internal.action.ITagReadAction;
+import be.pw.jexif.internal.action.ITagReadAllAction;
+import be.pw.jexif.internal.action.ITagReadExactAllAction;
+import be.pw.jexif.internal.action.ITagWriteAction;
 
 /**
  * Factory for the different action.
 	 * @return an instance of a TagReadAction or null if validation failed.
 	 * @throws IOException if the given file does not exist
 	 */
-	public static TagReadAction createReadAction(final File file, final Tag... tags) throws IOException {
+	public static ITagReadAction createReadAction(final File file, final Tag... tags) throws IOException {
 		TagReadAction read = new TagReadAction();
 		read.setParams(file, tags);
 		return read;
 	 * @return an instance of a TagReadAction or null if validation failed.
 	 * @throws IOException if the given file does not exist
 	 */
-	public static TagReadAction createExactReadAction(final File file, final Tag... tags) throws IOException {
+	public static ITagReadAction createExactReadAction(final File file, final Tag... tags) throws IOException {
 		TagReadExactAction read = new TagReadExactAction();
 		read.setParams(file, tags);
 		return read;
 	}
 
-	public static TagWriteAction createTagWriteAction(final File file, final Map<Tag, String> valuesToWrite) throws JExifValidationException, IOException {
+	public static ITagWriteAction createTagWriteAction(final File file, final Map<Tag, String> valuesToWrite) throws JExifValidationException, IOException {
 		TagWriteAction read = new TagWriteAction();
 		read.setParams(file, valuesToWrite);
 		return read;
 	}
 	
-	public static TagReadAllAction createTagReadAllAction(final File file) {
+	public static ITagReadAllAction createTagReadAllAction(final File file) {
 		TagReadAllAction readAll = new TagReadAllAction();
 		readAll.setParams(file);
 		return readAll;
 	}
 	
-	public static TagReadExactAllAction createTagReadExactAllAction(final File file) {
+	public static ITagReadExactAllAction createTagReadExactAllAction(final File file) {
 		TagReadExactAllAction readExactAll = new TagReadExactAllAction();
 		readExactAll.setParams(file);
 		return readExactAll;

src/be/pw/jexif/internal/action/impl/TagReadAction.java

 import be.pw.jexif.enums.tag.Tag;
 import be.pw.jexif.exception.JExifException;
 import be.pw.jexif.internal.action.AbstractAction;
-import be.pw.jexif.internal.action.IAction;
+import be.pw.jexif.internal.action.ITagReadAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.util.ArrayUtil;
 import be.pw.jexif.internal.util.Cal10nUtil;
  * Action to read an EXIF-tag.
  * @author phillip
  */
-public class TagReadAction extends AbstractAction implements IAction {
+class TagReadAction extends AbstractAction implements ITagReadAction {
 	/**
 	 * The logger for this class.
 	 */

src/be/pw/jexif/internal/action/impl/TagReadAllAction.java

 import be.pw.jexif.enums.Errors;
 import be.pw.jexif.exception.JExifException;
 import be.pw.jexif.internal.action.AbstractAction;
+import be.pw.jexif.internal.action.ITagReadAllAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.util.ArrayUtil;
 import be.pw.jexif.internal.util.Cal10nUtil;
  * @author phillip
  *
  */
-public class TagReadAllAction extends AbstractAction {
+class TagReadAllAction extends AbstractAction implements ITagReadAllAction {
 
 	/**
 	 * The logger for this class.

src/be/pw/jexif/internal/action/impl/TagReadExactAction.java

 import org.slf4j.LoggerFactory;
 
 import be.pw.jexif.exception.JExifException;
-import be.pw.jexif.internal.action.IAction;
+import be.pw.jexif.internal.action.ITagReadExactAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.util.ArrayUtil;
 
  * The TagReadExactAction will read out a Tag with it's exact value. So instead of an aperture of 2.8 you might get 2.79999456.
  * @author phillip
  */
-public class TagReadExactAction extends TagReadAction implements IAction {
+class TagReadExactAction extends TagReadAction implements ITagReadExactAction {
 
 	/**
 	 * The logger for this class.

src/be/pw/jexif/internal/action/impl/TagReadExactAllAction.java

 import org.slf4j.LoggerFactory;
 
 import be.pw.jexif.exception.JExifException;
+import be.pw.jexif.internal.action.ITagReadExactAllAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.util.ArrayUtil;
 
  * @author phillip
  *
  */
-public class TagReadExactAllAction extends TagReadAllAction {
+class TagReadExactAllAction extends TagReadAllAction implements ITagReadExactAllAction {
 
 	/**
 	 * The logger for this class.

src/be/pw/jexif/internal/action/impl/TagWriteAction.java

 import be.pw.jexif.exception.JExifException;
 import be.pw.jexif.exception.JExifValidationException;
 import be.pw.jexif.internal.action.AbstractAction;
-import be.pw.jexif.internal.action.IAction;
+import be.pw.jexif.internal.action.ITagWriteAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.util.ArrayUtil;
 import be.pw.jexif.internal.util.Cal10nUtil;
  * Action to write an Exif-Tag
  * @author phillip
  */
-public class TagWriteAction extends AbstractAction implements IAction {
+class TagWriteAction extends AbstractAction implements ITagWriteAction {
 
 	TagWriteAction() {
 

src/be/pw/jexif/internal/result/impl/ParserFactory.java

 import be.pw.jexif.enums.Errors;
 import be.pw.jexif.exception.JExifException;
 import be.pw.jexif.internal.action.IAction;
-import be.pw.jexif.internal.action.impl.TagReadAction;
-import be.pw.jexif.internal.action.impl.TagReadAllAction;
-import be.pw.jexif.internal.action.impl.TagReadExactAction;
-import be.pw.jexif.internal.action.impl.TagReadExactAllAction;
-import be.pw.jexif.internal.action.impl.TagWriteAction;
+import be.pw.jexif.internal.action.ITagReadAction;
+import be.pw.jexif.internal.action.ITagReadAllAction;
+import be.pw.jexif.internal.action.ITagReadExactAction;
+import be.pw.jexif.internal.action.ITagReadExactAllAction;
+import be.pw.jexif.internal.action.ITagWriteAction;
 import be.pw.jexif.internal.result.IResultParser;
 import be.pw.jexif.internal.util.Cal10nUtil;
 
 	 */
 	public static IResultParser getInstance(final IAction action) throws JExifException {
 		Preconditions.checkNotNull(action);
-		if (action.getClass().equals(TagReadAction.class)) {
+		if (action instanceof ITagReadAction) {
 			return new TagReadParser();
 		}
-		if (action.getClass().equals(TagReadExactAction.class)) {
+		if (action instanceof ITagReadExactAction) {
 			return new TagReadExactParser();
 		}
-		if (action.getClass().equals(TagWriteAction.class)) {
+		if (action instanceof ITagWriteAction) {
 			return new TagWriteParser();
 		}
-		if (action.getClass().equals(TagReadAllAction.class)) {
+		if (action instanceof ITagReadAllAction) {
 			return new TagReadAllParser();
 		}
-		if (action.getClass().equals(TagReadExactAllAction.class)) {
+		if (action instanceof ITagReadExactAllAction) {
 			return new TagReadExactAllParser();
 		}
 		LOG.error(Cal10nUtil.get(Errors.PARSER_UNKNOWNTYPE, action.getClass().getName()));

src/be/pw/jexif/internal/result/impl/TagReadAllParser.java

 import be.pw.jexif.enums.Errors;
 import be.pw.jexif.enums.tag.Tag;
 import be.pw.jexif.internal.action.IAction;
-import be.pw.jexif.internal.action.impl.TagReadAllAction;
+import be.pw.jexif.internal.action.ITagReadAllAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.result.IResultParser;
 import be.pw.jexif.internal.util.Cal10nUtil;
 	 */
 	@Override
 	public void parse(IAction action, String actionUID, List<String> result) {
-		Preconditions.checkArgument(action.getClass().equals(validFor()), Cal10nUtil.get(Errors.PARSER_MISMATCH, getClass().getSimpleName(), action.getClass().getSimpleName()));
+		Preconditions.checkArgument(validFor().isAssignableFrom(action.getClass()), Cal10nUtil.get(Errors.PARSER_MISMATCH, getClass().getSimpleName(), action.getClass().getSimpleName()));
 		Preconditions.checkArgument(action.getId().equals(actionUID), "Invalid action UID");
 		
 		Tag t;
 				} else {
 					if (t == null) {
 						LOG.trace("Found unsupported tag: {}", u);
-						((TagReadAllAction) action).addUnsupportedResult(u, r);
+						((ITagReadAllAction) action).addUnsupportedResult(u, r);
 					} else {
 						LOG.warn("Could not add result {}", line);
 					}
 	 */
 	@Override
 	public Class<? extends IAction> validFor() {
-		return TagReadAllAction.class;
+		return ITagReadAllAction.class;
 	}
 
 }

src/be/pw/jexif/internal/result/impl/TagReadExactAllParser.java

 package be.pw.jexif.internal.result.impl;
 
 import be.pw.jexif.internal.action.IAction;
-import be.pw.jexif.internal.action.impl.TagReadExactAllAction;
+import be.pw.jexif.internal.action.ITagReadExactAllAction;
 import be.pw.jexif.internal.result.IResultParser;
 /**
  * Parses the result for the {@link TagReadExactAllAction}
 	 */
 	@Override
 	public Class<? extends IAction> validFor() {
-		return TagReadExactAllAction.class;
+		return ITagReadExactAllAction.class;
 	}
 
 }

src/be/pw/jexif/internal/result/impl/TagReadExactParser.java

 package be.pw.jexif.internal.result.impl;
 
 import be.pw.jexif.internal.action.IAction;
-import be.pw.jexif.internal.action.impl.TagReadExactAction;
+import be.pw.jexif.internal.action.ITagReadExactAction;
 
 /**
  * Parses the result for the {@link TagReadExactAction}
 	 */
 	@Override
 	public Class<? extends IAction> validFor() {
-		return TagReadExactAction.class;
+		return ITagReadExactAction.class;
 	}
 
 }

src/be/pw/jexif/internal/result/impl/TagReadParser.java

 import be.pw.jexif.enums.Errors;
 import be.pw.jexif.enums.tag.Tag;
 import be.pw.jexif.internal.action.IAction;
-import be.pw.jexif.internal.action.impl.TagReadAction;
+import be.pw.jexif.internal.action.ITagReadAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.result.IResultParser;
 import be.pw.jexif.internal.util.Cal10nUtil;
 	 */
 	@Override
 	public final void parse(final IAction action, final String actionUID, final List<String> result)  {
-		Preconditions.checkArgument(action.getClass().equals(validFor()), Cal10nUtil.get(Errors.PARSER_MISMATCH, getClass().getSimpleName(), action.getClass().getSimpleName()));
+		Preconditions.checkArgument(validFor().isAssignableFrom(action.getClass()), Cal10nUtil.get(Errors.PARSER_MISMATCH, getClass().getSimpleName(), action.getClass().getSimpleName()));
 		Preconditions.checkArgument(action.getId().equals(actionUID), "Invalid action UID");
 		
 		Tag t;
 	 */
 	@Override
 	public Class<? extends IAction> validFor() {
-		return TagReadAction.class;
+		return ITagReadAction.class;
 	}
 }

src/be/pw/jexif/internal/result/impl/TagWriteParser.java

 
 import be.pw.jexif.enums.Errors;
 import be.pw.jexif.internal.action.IAction;
-import be.pw.jexif.internal.action.impl.TagWriteAction;
+import be.pw.jexif.internal.action.ITagWriteAction;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.result.IResultParser;
 import be.pw.jexif.internal.util.Cal10nUtil;
 	 */
 	@Override
 	public void parse(final IAction action, final String actionUID, final List<String> result) {
-		Preconditions.checkArgument(action.getClass().equals(validFor()), Cal10nUtil.get(Errors.PARSER_MISMATCH, getClass().getSimpleName(), action.getClass().getSimpleName()));
+		Preconditions.checkArgument(validFor().isAssignableFrom(action.getClass()), Cal10nUtil.get(Errors.PARSER_MISMATCH, getClass().getSimpleName(), action.getClass().getSimpleName()));
 		Preconditions.checkArgument(action.getId().equals(actionUID), "Invalid action UID");
 
 		for (String line : result) {
 	 */
 	@Override
 	public Class<? extends IAction> validFor() {
-		return TagWriteAction.class;
+		return ITagWriteAction.class;
 	}
 }