Class ValidatingIntent

java.lang.Object
com.streamwide.smartms.lib.template.serialization.ValidatingIntent

public class ValidatingIntent extends Object
An Intent that's restricted to deserialize a limited set of classes.

Various accept/reject methods allow for specifying which classes can be deserialized.

  • Constructor Details

    • ValidatingIntent

      public ValidatingIntent(@Nullable android.content.Intent intent)
      Constructs an object to deserialize the specified intent. At least one accept method needs to be called to specify which classes can be deserialized, as by default no classes are accepted.
      Parameters:
      intent - an intent
  • Method Details

    • hasCategory

      public boolean hasCategory(@NonNull String category)
      Check if a category exists in the intent.
      Parameters:
      category - The category to check.
      Returns:
      boolean True if the intent contains the category, else false.
    • getAction

      @Nullable public String getAction() throws InvalidClassException
      Retrieve the general action to be performed, such as Intent.ACTION_VIEW. The action describes the general way the rest of the information in the intent should be interpreted -- most importantly, what to do with the data returned by getData().
      Returns:
      The action of this intent or null if none is specified.
      Throws:
      InvalidClassException
    • getData

      @Nullable public android.net.Uri getData() throws InvalidClassException
      Retrieve data this intent is operating on. This URI specifies the name of the data; often it uses the content: scheme, specifying data in a content provider. Other schemes may be handled by specific activities, such as http: by the web browser.
      Returns:
      The URI of the data this intent is targeting or null.
      Throws:
      InvalidClassException
    • getClipData

      @Nullable public android.content.ClipData getClipData() throws InvalidClassException
      Throws:
      InvalidClassException
    • getType

      @Nullable public String getType() throws InvalidClassException
      Retrieve any explicit MIME type included in the intent. This is usually null, as the type is determined by the intent data.
      Returns:
      If a type was manually set, it is returned; else null is returned.
      Throws:
      InvalidClassException
    • getExtras

      @Nullable public android.os.Bundle getExtras() throws InvalidClassException
      Retrieves a map of extended data from the intent.
      Returns:
      the map of all extras previously added with putExtra(), or null if none have been added.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • getKeyEvent

      @Nullable public android.view.KeyEvent getKeyEvent(@NonNull String name) throws InvalidClassException
      Parameters:
      name - The name of the desired item.
      Returns:
      The value of an item previously added with putExtra(), or null if no Parcelable value was found.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • getParcelableExtra

      @Nullable public <T extends android.os.Parcelable> T getParcelableExtra(@NonNull String name) throws InvalidClassException
      Type Parameters:
      T - The KeyEvent
      Parameters:
      name - The name of the desired item.
      Returns:
      The value of an item previously added with putExtra(), or null if no Parcelable value was found.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • getParcelableArrayListExtra

      @Nullable public <T extends android.os.Parcelable> ArrayList<T> getParcelableArrayListExtra(@NonNull String name) throws InvalidClassException
      Type Parameters:
      T - The KeyEvent
      Parameters:
      name - The name of the desired item.
      Returns:
      The value of an item previously added with putExtra(), or null if no Parcelable value was found.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • getIntExtra

      public int getIntExtra(@NonNull String name, int defaultValue) throws InvalidClassException
      Retrieve extended data from the intent.
      Parameters:
      name - The name of the desired item.
      defaultValue - the value to be returned if no value of the desired type is stored with the given name.
      Returns:
      the value of an item previously added with putExtra(), or the default value if none was found.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • getBooleanExtra

      public boolean getBooleanExtra(@NonNull String name, boolean defaultValue) throws InvalidClassException
      Retrieve extended data from the intent.
      Parameters:
      name - The name of the desired item.
      defaultValue - the value to be returned if no value of the desired type is stored with the given name.
      Returns:
      the value of an item previously added with putExtra(), or the default value if none was found.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • getStringExtra

      @Nullable public String getStringExtra(@NonNull String name) throws InvalidClassException
      Retrieve extended data from the intent.
      Parameters:
      name - The name of the desired item.
      Returns:
      the value of an item previously added with putExtra(), or the default value if none was found.
      Throws:
      InvalidClassException - when a non-accepted class is encountered
    • containsKey

      public boolean containsKey(@NonNull String key)
      Returns true if the given key is contained in the mapping of this Bundle.
      Parameters:
      key - a String key
      Returns:
      true if the key is part of the mapping, false otherwise
    • accept

      @NonNull public ValidatingIntent accept(@NonNull Class<?>... classes) throws OperationNotAllowed
      Accept the specified classes for deserialization, unless they are otherwise rejected.
      Parameters:
      classes - Classes to accept
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • reject

      @NonNull public ValidatingIntent reject(@NonNull Class<?>... classes) throws OperationNotAllowed
      Reject the specified classes for deserialization, even if they are otherwise accepted.
      Parameters:
      classes - Classes to reject
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • accept

      @NonNull public ValidatingIntent accept(@NonNull String... patterns) throws OperationNotAllowed
      Accept the wildcard specified classes for deserialization, unless they are otherwise rejected.
      Parameters:
      patterns - Wildcard file name patterns as defined by FilenameUtils.wildcardMatch
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • reject

      @NonNull public ValidatingIntent reject(@NonNull String... patterns) throws OperationNotAllowed
      Reject the wildcard specified classes for deserialization, even if they are otherwise accepted.
      Parameters:
      patterns - Wildcard file name patterns as defined by FilenameUtils.wildcardMatch
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • accept

      @NonNull public ValidatingIntent accept(@NonNull Pattern pattern) throws OperationNotAllowed
      Accept class names that match the supplied pattern for deserialization, unless they are otherwise rejected.
      Parameters:
      pattern - standard Java regexp
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • reject

      @NonNull public ValidatingIntent reject(@NonNull Pattern pattern) throws OperationNotAllowed
      Reject class names that match the supplied pattern for deserialization, even if they are otherwise accepted.
      Parameters:
      pattern - standard Java regexp
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • accept

      @NonNull public ValidatingIntent accept(@NonNull ClassNameMatcher m) throws OperationNotAllowed
      Accept class names where the supplied ClassNameMatcher matches for deserialization, unless they are otherwise rejected.
      Parameters:
      m - the matcher to use
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • reject

      @NonNull public ValidatingIntent reject(@NonNull ClassNameMatcher m) throws OperationNotAllowed
      Reject class names where the supplied ClassNameMatcher matches for deserialization, even if they are otherwise accepted.
      Parameters:
      m - the matcher to use
      Returns:
      this object
      Throws:
      OperationNotAllowed
    • ready

      public void ready()