Package org.apache.solr.common.util

## Class CommandOperation

- java.lang.Object
- - org.apache.solr.common.util.CommandOperation

    public class CommandOperation
    extends Object

### Field Summary

Fields
`static String` `ERR_MSGS`
`String` `name`
`static String` `ROOT_OBJ`

### Constructor Summary

Constructors
`CommandOperation​(String operationName, Object metaData)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addError​(String s)`
`static List<Map<String,​Object>>` `captureErrors​(List<CommandOperation> ops)`
`static List<CommandOperation>` `clone​(List<CommandOperation> ops)`
`boolean` `getBoolean​(String key, boolean def)`
`Object` `getCommandData()`
`CommandOperation` `getCopy()`
`Map<String,​Object>` `getDataMap()`
`List<String>` `getErrors()`
`Integer` `getInt​(String name)`
`Integer` `getInt​(String name, Integer def)`
`Map` `getMap​(String key, Map def)`
`String` `getStr​(String key)` Get a required field.
`String` `getStr​(String key, String def)`
`List<String>` `getStrs​(String key)`
`List<String>` `getStrs​(String key, List<String> def)` Get collection of values for a key.
`Object` `getVal​(String key)`
`Map<String,​Object>` `getValuesExcluding​(String... keys)` Get all the values from the metadata for the command without the specified keys
`boolean` `hasError()`
`static List<CommandOperation>` `parse​(InputStream in, Set<String> singletonCommands)` Parse the command operations into command objects from javabin payload * @param singletonCommands commands that cannot be repeated
`static List<CommandOperation>` `parse​(Reader rdr)`
`static List<CommandOperation>` `parse​(Reader rdr, Set<String> singletonCommands)` Parse the command operations into command objects from a json payload
`static List<CommandOperation>` `readCommands​(Iterable<ContentStream> streams, NamedList resp)`
`static List<CommandOperation>` `readCommands​(Iterable<ContentStream> streams, NamedList resp, Set<String> singletonCommands)` Read commands from request streams
`void` `setCommandData​(Object o)`
`String` `toString()`
`void` `unknownOperation()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### name

    public final String name

#### ERR_MSGS

    public static final String ERR_MSGS

See Also:
  Constant Field Values

#### ROOT_OBJ

    public static final String ROOT_OBJ

See Also:
  Constant Field Values

### Constructor Detail

#### CommandOperation

    public CommandOperation​(String operationName,
                            Object metaData)

### Method Detail

#### getCommandData

    public Object getCommandData()

#### getStr

    public String getStr​(String key,
                         String def)

#### getBoolean

    public boolean getBoolean​(String key,
                              boolean def)

#### setCommandData

    public void setCommandData​(Object o)

#### getDataMap

    public Map<String,​Object> getDataMap()

#### getVal

    public Object getVal​(String key)

#### getStrs

    public List<String> getStrs​(String key)

#### unknownOperation

    public void unknownOperation()

#### getStrs

    public List<String> getStrs​(String key,
                                List<String> def)

Get collection of values for a key. If only one val is present a single value collection is returned

#### getStr

    public String getStr​(String key)

Get a required field. If missing it adds to the errors

#### hasError

    public boolean hasError()

#### addError

    public void addError​(String s)

#### getValuesExcluding

    public Map<String,​Object> getValuesExcluding​(String... keys)

Get all the values from the metadata for the command without the specified keys

#### getErrors

    public List<String> getErrors()

#### captureErrors

    public static List<Map<String,​Object>> captureErrors​(List<CommandOperation> ops)

#### parse

    public static List<CommandOperation> parse​(Reader rdr)
                                        throws IOException

Throws:
  `IOException`

#### parse

    public static List<CommandOperation> parse​(InputStream in,
                                               Set<String> singletonCommands)
                                        throws IOException

Parse the command operations into command objects from javabin payload * @param singletonCommands commands that cannot be repeated

Throws:
  `IOException`

#### parse

    public static List<CommandOperation> parse​(Reader rdr,
                                               Set<String> singletonCommands)
                                        throws IOException

Parse the command operations into command objects from a json payload

Parameters:
  `rdr` - The payload
  `singletonCommands` - commands that cannot be repeated
Returns:
  parsed list of commands
Throws:
  `IOException`

#### getCopy

    public CommandOperation getCopy()

#### getMap

    public Map getMap​(String key,
                      Map def)

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### readCommands

    public static List<CommandOperation> readCommands​(Iterable<ContentStream> streams,
                                                      NamedList resp)
                                               throws IOException

Throws:
  `IOException`

#### readCommands

    public static List<CommandOperation> readCommands​(Iterable<ContentStream> streams,
                                                      NamedList resp,
                                                      Set<String> singletonCommands)
                                               throws IOException

Read commands from request streams

Parameters:
  `streams` - the streams
  `resp` - solr query response
  `singletonCommands` - , commands that cannot be repeated
Returns:
  parsed list of commands
Throws:
  `IOException` - if there is an error while parsing the stream

#### clone

    public static List<CommandOperation> clone​(List<CommandOperation> ops)

#### getInt

    public Integer getInt​(String name,
                          Integer def)

#### getInt

    public Integer getInt​(String name)