# SimpleAtom

Summary:[Nested Classes](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#nestedclasses)\|[Ctors](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#pubctors)\|[Methods](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#)  

# SimpleAtom

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
SimpleAtom
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


implements

`[Atom](https://developer.android.com/reference/android/support/test/espresso/web/model/Atom)`<`[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)`>


`

|---|----------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.espresso.web.model.SimpleAtom |

<br />

*** ** * ** ***

A simple implementation of Atom suitable for subclassing.

## Summary

|                                                                                                                       ### Nested classes                                                                                                                        ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` enum` | [SimpleAtom.ElementReferencePlacement](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom.ElementReferencePlacement) Controls whether the ElementReference appears as the first arg or last arg to the script. |

|                                                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                                                            ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[SimpleAtom](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#SimpleAtom(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` script) ` Creates a SimpleAtom which runs the given script and places any ElementReference as the first argument to the script.                                                                                                                                                                                                                                                                                        |
| ` `[SimpleAtom](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#SimpleAtom(java.lang.String, android.support.test.espresso.web.model.SimpleAtom.ElementReferencePlacement))`(`[String](https://developer.android.com/reference/java/lang/String.html)` script, `[SimpleAtom.ElementReferencePlacement](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom.ElementReferencePlacement)` elementPlacement) ` Creates a SimpleAtom which runs the given script and places any supplied ElementReference either as the first or last argument to the script. |

|                                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                                 ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final `[List](https://developer.android.com/reference/java/util/List.html)`<`[Object](https://developer.android.com/reference/java/lang/Object.html)`>` | ` `[getArguments](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#getArguments(android.support.test.espresso.web.model.ElementReference))`(`[ElementReference](https://developer.android.com/reference/android/support/test/espresso/web/model/ElementReference)` elementRef) ` The SimpleAtom presents an argument list to the script which follows some basic conventions. |
| ` final `[String](https://developer.android.com/reference/java/lang/String.html)                                                                          | ` `[getScript](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#getScript())`() ` Returns the script this SimpleAtom was created with.                                                                                                                                                                                                                                        |
| ` final `[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)                                         | ` `[transform](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#transform(android.support.test.espresso.web.model.Evaluation))`(`[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)` e) ` The SimpleAtom's transform method checks the Evaluation object for success.                                                   |

|                                                                                                                                                                                                                                                          ### Protected methods                                                                                                                                                                                                                                                           ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[List](https://developer.android.com/reference/java/util/List.html)`<`[Object](https://developer.android.com/reference/java/lang/Object.html)`>` | ` `[getNonContextualArguments](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#getNonContextualArguments())`() ` Extend this method to pass additional arguments to the script.                                                                                                                                                          |
| ` `[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)                                         | ` `[handleBadEvaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#handleBadEvaluation(android.support.test.espresso.web.model.Evaluation))`(`[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)` e) ` Extend this method to handle a failure code in the Evaluation object. |
| ` void`                                                                                                                                             | ` `[handleNoElementReference](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#handleNoElementReference())`() ` Extend this method to handle the case where getArguments() has been called without an ElementReference.                                                                                                                   |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom#)From interface` `[android.support.test.espresso.web.model.Atom](https://developer.android.com/reference/android/support/test/espresso/web/model/Atom)` ` |--------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[List](https://developer.android.com/reference/java/util/List.html)`<`[Object](https://developer.android.com/reference/java/lang/Object.html)`>` | ` `[getArguments](https://developer.android.com/reference/android/support/test/espresso/web/model/Atom#getArguments(android.support.test.espresso.web.model.ElementReference))`(`[ElementReference](https://developer.android.com/reference/android/support/test/espresso/web/model/ElementReference)` elementContext) ` Creates a list of arguments to pass to the script. | | ` abstract `[String](https://developer.android.com/reference/java/lang/String.html)                                                                          | ` `[getScript](https://developer.android.com/reference/android/support/test/espresso/web/model/Atom#getScript())`() ` Provides the script to be evaluated.                                                                                                                                                                                                                  | | ` abstract `[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)                                         | ` `[transform](https://developer.android.com/reference/android/support/test/espresso/web/model/Atom#transform(android.support.test.espresso.web.model.Evaluation))`(`[Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)` evaluation) ` Converts an Evaluation into another more suitable type.                        | ||

## Public constructors

### SimpleAtom

```
SimpleAtom (String script)
```

Creates a SimpleAtom which runs the given script and places any ElementReference as the first argument to the script.

<br />

|        Parameters         ||
|----------|-----------------|
| `script` | `String` <br /> |

### SimpleAtom

```
SimpleAtom (String script, 
                SimpleAtom.ElementReferencePlacement elementPlacement)
```

Creates a SimpleAtom which runs the given script and places any supplied ElementReference either as the first or last argument to the script.

<br />

|                            Parameters                             ||
|--------------------|-----------------------------------------------|
| `script`           | `String` <br />                               |
| `elementPlacement` | `SimpleAtom.ElementReferencePlacement` <br /> |

## Public methods

### getArguments

```
List<Object> getArguments (ElementReference elementRef)
```

The SimpleAtom presents an argument list to the script which follows some basic conventions.

If an ElementReference is provided, it is placed either in the first or last position based on the ElementReferencePlacement provided to the constructor.

The nonContextualArguments (if provided via getNonContextualArguments) will appear after the ElementReference.

<br />

|                                                      Parameters                                                       ||
|--------------|---------------------------------------------------------------------------------------------------------|
| `elementRef` | `ElementReference`: null unless an ElementReference has been supplied to execute this atom with. <br /> |

|                                                                                                     Returns                                                                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List.html)`<`[Object](https://developer.android.com/reference/java/lang/Object.html)`>` | the List of objects to pass to the script as arguments. <br /> |

### getScript

```
String getScript ()
```

Returns the script this SimpleAtom was created with.

<br />

|                                     Returns                                     ||
|-------------------------------------------------------------------------|--------|
| [String](https://developer.android.com/reference/java/lang/String.html) | <br /> |

### transform

```
Evaluation transform (Evaluation e)
```

The SimpleAtom's transform method checks the Evaluation object for success.

If the Evaluation object has an error, the default behaviour is to throw an exception, subclasses may change this behaviour via the handleBadEvaluation method.

<br />

|        Parameters        ||
|-----|---------------------|
| `e` | `Evaluation` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| [Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation) | <br /> |

## Protected methods

### getNonContextualArguments

```
List<Object> getNonContextualArguments ()
```

Extend this method to pass additional arguments to the script.

<br />

|                                                                                         Returns                                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| [List](https://developer.android.com/reference/java/util/List.html)`<`[Object](https://developer.android.com/reference/java/lang/Object.html)`>` | a list of arguments (non-null) <br /> |

### handleBadEvaluation

```
Evaluation handleBadEvaluation (Evaluation e)
```

Extend this method to handle a failure code in the Evaluation object.

The default implementation will throw an exception, subclasses may want to ignore certain failure cases.

<br />

|        Parameters        ||
|-----|---------------------|
| `e` | `Evaluation` <br /> |

|                                                                               Returns                                                                                ||
|----------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation) | Evaluation the evaluation object (must be non-null) <br /> |

|                                                             Throws                                                             ||
|---------------------------------------------------------------------------------------------|-----------------------------------|
| [RuntimeException](https://developer.android.com/reference/java/lang/RuntimeException.html) | if the badness level is too high. |

### handleNoElementReference

```
void handleNoElementReference ()
```

Extend this method to handle the case where getArguments() has been called without an ElementReference. Implementors may want to throw an exception here if they require an ElementReference to evaluate properly.

<br />

-

  ## Interfaces

  - [Atom](https://developer.android.com/reference/android/support/test/espresso/web/model/Atom)
  - [JSONAble](https://developer.android.com/reference/android/support/test/espresso/web/model/JSONAble)
  - [JSONAble.DeJSONFactory](https://developer.android.com/reference/android/support/test/espresso/web/model/JSONAble.DeJSONFactory)
  - [TransformingAtom.Transformer](https://developer.android.com/reference/android/support/test/espresso/web/model/TransformingAtom.Transformer)
-

  ## Classes

  - [Atoms](https://developer.android.com/reference/android/support/test/espresso/web/model/Atoms)
  - [ElementReference](https://developer.android.com/reference/android/support/test/espresso/web/model/ElementReference)
  - [Evaluation](https://developer.android.com/reference/android/support/test/espresso/web/model/Evaluation)
  - [ModelCodec](https://developer.android.com/reference/android/support/test/espresso/web/model/ModelCodec)
  - [SimpleAtom](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom)
  - [TransformingAtom](https://developer.android.com/reference/android/support/test/espresso/web/model/TransformingAtom)
  - [WindowReference](https://developer.android.com/reference/android/support/test/espresso/web/model/WindowReference)
-

  ## Enums

  - [SimpleAtom.ElementReferencePlacement](https://developer.android.com/reference/android/support/test/espresso/web/model/SimpleAtom.ElementReferencePlacement)