# Class SV

java.lang.Object
org.jmol.script.T
org.jmol.script.SV

All Implemented Interfaces:
  `JSONEncodable`

public class SV extends T implements JSONEncodable
ScriptVariable class

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected class`
`SV.Sort`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`FORMAT_ABC`
`static final int`
`FORMAT_ARRAY`
`static final int`
`FORMAT_BASE64`
`static final int`
`FORMAT_BYTEARRAY`
`static final int`
`FORMAT_JSON`
`static final int`
`FORMAT_RXYZ`
`static final int`
`FORMAT_STRING`
`static final int`
`FORMAT_UVW`
`static final int`
`FORMAT_XYZ`
`int`
`index`
`String`
`myName`
`static final SV`
`vF`
`static final SV`
`vNaN`
`static final SV`
`vT`

### Fields inherited from class T

`__, _args, abs, absolute, acos, add, addhydrogens, adpmax, adpmin, align, all, allconnected, allfloat, allowaudio, allowembeddedscripts, allowgestures, allowkeystrokes, allowmodelkit, allowmoveatoms, allowmultitouch, allowrotateselected, altloc, ambientocclusion, ambientpercent, amino, andequals, angle, angstroms, animation, animationfps, animationmode, anisotropy, antialiasdisplay, antialiasimages, antialiastranslucent, apivot, append, appendnew, appletproxy, applysymmetrytobonds, arc, area, aromatic, array, arrow, as, assign, astrType, async, atomExpressionCommand, atomicorbital, atomid, atomindex, atomname, atomno, atompicking, atomproperty, atoms, atomtype, atomtypes, atomx, atomy, atomz, audio, auto, autobond, autofps, autoplaymovie, average, axes, axescolor, axesmode, axesmolecular, axesoffset, axesorientationrasmol, axesscale, axesunitcell, axeswindow, axis, axis1color, axis2color, axis3color, axisangle, babel, babel21, back, backbone, background, backgroundcolor, backgroundmodel, backlit, backshell, balls, barb, barray, basemodel, basepair, best, beta, bin, binary, bind, bitset, blockdata, bondcount, bonded, bondingradius, bondingversion, bondmode, bondmodeor, bondorder, bondpicking, bondradiusmilliangstroms, bonds, bondset, bondtolerance, booleanparam, bottom, boundbox, boundboxcolor, branch, breakcmd, brillouin, cache, calculate, cameradepth, cancel, cap, capture, carbohydrate, cartoon, cartoonbaseedges, cartoonblockheight, cartoonblocks, cartoonladders, cartoonribose, cartoonrockets, cartoonsfancy, cartoonsteps, casecmd, catchcmd, cavity, cd, cell, celshading, celshadingpower, center, centerat, centroid, cgo, chain, chaincasesensitive, chainno, check, checkcir, chemical, chemicalshift, chirality, ciprule, ciprule6full, circle, clash, clear, clickable, clipboard, col, collapsed, colon, color, colorrasmol, colorscheme, comma, command, commands, comparator, compare, configuration, connect, connected, console, constraint, contact, context, contextdepthmax, continuecmd, contour, contourlines, contours, coord, corners, cos, count, covalentradius, create, criterion, cross, crossed, currentlocalpath, curve, cutoff, cylinder, data, dataseparator, debug, debughigh, debugscript, decimal, defaultanglelabel, defaultcmd, defaultcolorscheme, defaultdirectory, defaultdistancelabel, defaultdrawarrowscale, defaultdropscript, defaultlabelpdb, defaultlabelxyz, defaultlattice, defaultloadfilter, defaultloadscript, defaultON, defaults, defaultstructuredssp, defaulttorsionlabel, defaulttranslucent, defaultvdw, define, delay, delaymaximumms, delete, density, deprecatedparam, depth, diameter, diffusepercent, dipole, dipolescale, direction, disablepopupmenu, discrete, displacement, display, displaycellparameters, displayed, distance, distancefactor, div, divide, dna, dollarsign, domains, dot, dotdensity, dots, dotscale, dotsselectedonly, dotsurface, dotted, doubleprecision, downsample, dragselected, draw, drawfontsize, drawhover, drawing, drawpicking, dssp, dsspcalchydrogen, dssr, dynamicmeasurements, eccentricity, echo, ed, edges, edgesonly, eds, edsdiff, element, elementkey, elemisono, elemno, ellipsoid, ellipsoidarcs, ellipsoidarrows, ellipsoidaxes, ellipsoidaxisdiameter, ellipsoidball, ellipsoiddotcount, ellipsoiddots, ellipsoidfill, elsecmd, elseif, end, endifcmd, energy, energyunits, error, eta, eval, exit, exitjmol, exportscale, expressionBegin, expressionEnd, facecenteroffset, file, filecachedirectory, filecaching, fill, filter, find, first, fixed, fixedtemp, flat, floatparam, floatproperty, flowCommand, font, fontcaching, fontscaling, fontsize, forceautobond, forcefield, forcmd, formalcharge, format, fps, fractionalrelative, fracx, fracxyz, fracy, fracz, frame, frank, from, front, frontedges, frontlit, frontonly, full, fullplane, fullylit, function, functionxy, functionxyz, fux, fuxyz, fuy, fuz, geosurface, gestureswipefactor, getproperty, gotocmd, greyscalerendering, gridpoints, group, group1, groupid, groupindex, halo, hash, hbond, hbondhxdistancemaximum, hbondnodistancemaximum, hbondsangleminimum, hbondsbackbone, hbondsrasmol, hbondssolid, helix, helix310, helixalpha, helixpi, helixstep, help, helppath, hermitelevel, hetero, hidden, hiddenlinesdashed, hide, hidenameinpopup, hidenavigationpoint, hidenotselected, highlight, highresolution, history, historylevel, hkl, homo, hover, hoverdelay, hoverlabel, hydrogen, hydrophobicity, id, identifier, identify, ifcmd, ignore, image, imagestate, implicitStringCommand, in, inchi, inchikey, increment, info, infofontsize, initialize, inline, inscode, insertion, insideout, integer, interior, intermolecular, internal, intersection, intparam, intproperty, intramolecular, intValue, invertSelected, isaromatic, iskiosk, isosurface, isosurfacekey, isosurfacepropertysmoothing, isosurfacepropertysmoothingpower, javascript, jmol, jmolinjspecview, join, json, justifymeasurements, keys, label, labelkey, labelpointerwidth, language, languagetranslation, last, lattice, lcaocartoon, leadatom, left, leftbrace, leftdivide, leftparen, leftsquare, legacyautobonding, legacyhaddition, legacyjavafloat, length, lighting, line, linedata, lines, link, list, listf, load, loadatomdatatolerance, loadformat, loadligandformat, lobe, log, logcommands, logfile, loggestures, loglevel, lonepair, loop, lp, lumo, macro, macrodirectory, magneticshielding, manifest, mapproperty, mass, mathExpressionCommand, mathfunc, mathop, mathproperty, matrix, matrix3f, matrix4f, max, maxset, measure, measureallmodels, measurementlabels, measurementnumbers, measurements, measurementunits, menu, mep, mesh, meshRibbon, meshscale, message, messagestylechime, middle, min, minbonddistance, minimizationcriterion, minimizationmaxatoms, minimizationrefresh, minimizationreportsteps, minimizationsilent, minimizationsteps, minimize, minmaxmask, minpixelselradius, minset, minus, minusMinus, misc, mlp, mo, mode, mode2d, model, modelbased, modelindex, modelkitmode, modify, modifyorcreate, modo, modt1, modt2, modt3, modulateoccupancy, modulation, modulationscale, modx, modxyz, mody, modz, molecular, molecule, monitorenergy, monomer, morph, mouse, mousedragfactor, mousewheelfactor, move, moveto, movie, mrc, msms, mul, mul3, multiplebondbananas, multiplebondradiusfactor, multiplebondspacing, multiprocessor, mutate, nada, name, navfps, navigate, navigationdepth, navigationmode, navigationperiodic, navigationslab, navigationspeed, navx, navy, navz, nbo, nbocharges, nci, next, nihresolverformat, nmr, nmrpredictformat, nmrurlformat, noArgs, nobackshell, nocontourlines, nocross, nodebug, nodelay, nodots, noedges, nofill, nohead, noload, nomesh, none, noplane, normal, notfrontonly, notriangles, now, nucleic, obj, object, occupancy, occupancythreshold, off, offset, offsetside, omega, on, once, only, opAnd, opAND, opaque, opEQ, opGE, opGT, opIf, opLE, opLIKE, opLT, opNE, opNot, opOr, options, opToggle, opXor, orbital, orientation, origin, out, packed, palindrome, parallel, parameters, paramTypes, partialcharge, partialdots, particleradius, path, pathforallfiles, pattern, pause, pdb, pdbaddhydrogens, pdbgetheader, pdbheader, pdbsequential, per, percent, percentvdwatom, period, perpendicular, perper, perspectivedepth, perspectivemodel, phase, phi, phongexponent, picking, pickingspinrate, pickingstyle, picklabel, pivot, pivot2, planarparam, plane, platformspeed, play, playrev, plot, plot3d, plus, plusPlus, pmesh, pocket, point, point3f, point4f, pointgroup, pointgroupdistancetolerance, pointgrouplineartolerance, pointsperangstrom, polygon, polyhedra, polymer, polymerlength, pop, predefinedset, preservestate, prev, print, privat, probe, process, prompt, property, propertyatomnumbercolumncount, propertyatomnumberfield, propertycolorscheme, propertydatacolumncount, propertydatafield, PROPERTYFLAGS, propselector, protein, psi, purine, push, pymol, pyrimidine, quaternion, quaternionframe, quit, rad, radical, radius, ramachandran, random, range, rangeselected, rasmol, redo, redomove, reference, refresh, refreshing, remove, repaintwaitms, replace, reset, residue, resno, resolution, restore, restrict, resume, returncmd, reverse, reversecolor, rewind, ribbon, ribbonaspectratio, ribbonborder, right, rightbrace, rightparen, rightsquare, rmsd, rna, rna3d, rock, rocket, rocketbarrels, rotate, rotate45, rotateSelected, rotation, rotationradius, row, rubberband, rxyz, sasurface, save, saved, saveproteinstructurestate, scale, scale3d, scaleangstromsperinch, scene, screenx, screenxyz, screeny, screenz, script, scriptCommand, scriptqueue, scriptreportinglevel, search, select, selectallmodels, selected, selectedfloat, selecthetero, selecthydrogen, selection, selectionhalos, semicolon, seqcode, seqid, sequence, set, setparam, settable, shape, shapeCommand, shapely, sheet, sheetsmoothing, show, showaxes, showboundbox, showfrank, showhiddenselectionhalos, showhydrogens, showkeystrokes, showmeasurements, showmodvecs, showmultiplebonds, shownavigationpointalways, showscript, showtiming, showunitcell, showunitcelldetails, sidechain, sigma, sign, silent, sin, site, size, slab, slabbyatom, slabbymolecule, slabenabled, slabrange, smallmoleculemaxatoms, smartaromatic, smiles, smiles2dimageformat, smilesurlformat, solid, solvent, solventprobe, solventproberadius, sort, spacebeforesquare, spacefill, spacegroup, spec_alternate, spec_atom, spec_chain, spec_model, spec_model2, spec_name_pattern, spec_resid, spec_seqcode, spec_seqcode_range, specialposition, specular, specularexponent, specularpercent, specularpower, sphere, spin, spine, spinfps, spinop, spinx, spiny, spinz, split, sqrt, squared, ssbond, ssbondsbackbone, star, starwidth, state, statusreporting, stddev, stdinchi, stdinchikey, step, stereo, stereodegrees, stop, straightness, strandcount, strandcountformeshribbon, strandcountforstrands, strands, string, strparam, strproperty, strucid, strucno, structure, strutdefaultradius, strutlengthmaximum, struts, strutsmultiple, strutspacing, sub, subset, substructure, subsystem, sum, sum2, supercell, surface, surfacedistance, switchcmd, symbol, symmetry, symmetryhermannmauguin, symop, sync, syncmouse, syncscript, tan, temperature, tensor, testflag1, testflag2, testflag3, testflag4, theta, this_, thismodel, throwcmd, ticks, timeout, times, timestimes, title, titleformat, to, togglelabel, tok, tokenAll, tokenAnd, tokenAndFALSE, tokenAndSpec, tokenArrayClose, tokenArrayOpen, tokenArraySquare, tokenColon, tokenComma, tokenConnected, tokenCoordinateBegin, tokenCoordinateEnd, tokenDefineString, tokenDivide, tokenEquals, tokenExpressionBegin, tokenExpressionEnd, tokenIf, tokenLeftBrace, tokenLeftParen, tokenLength, tokenMinus, tokenMul3, tokenOff, tokenOn, tokenOpIf, tokenOr, tokenOrTRUE, tokenPlus, tokenRightBrace, tokenRightParen, tokenScript, tokenSet, tokenSetArray, tokenSetCmd, tokenSetProperty, tokenSetVar, tokenSpaceBeforeSquare, tokenSwitch, tokenTimes, top, torsion, trace, tracealpha, trajectory, transform, translate, translateSelected, translation, translucent, triangles, trim, trycmd, twistedsheets, type, unaryMinus, unbind, undo, undoauto, undomax, undomove, unitcell, unitcellcolor, unitx, unitxyz, unity, unitz, url, useminimizationthread, usenumberlocalization, user, usercolorscheme, val, valence, validation, value, vanderwaals, var, variable, variables, varray, vector, vectorscale, vectorscentered, vectorsymmetry, vectortrail, vertices, vibration, vibrationperiod, vibrationscale, vibx, vibxyz, viby, vibz, visible, visualrange, volume, w, waitformoveto, whilecmd, width, wigner, window, windowcentered, wireframe, wireframerotation, within, write, wyckoff, wyckoffm, x, xyz, y, z, zap, zdepth, zerobasedxyzrasmol, zoom, zoomenabled, zoomheight, zoomlarge, zoomTo, zshade, zshadepower, zslab`

## Constructor Summary

Constructors
Constructor
Description
`SV()`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`areEqual(SV x1, SV x2)`
For legacy reasons, "x" == "X" but see isLike()
`SV`
`arrayToList(SV target)`
`boolean`
`asBoolean()`
`float`
`asFloat()`
`int`
`asInt()`
`String`
`asString()`
`static boolean`
`bValue(T x)`
`static SV`
`concatList(SV x1, SV x2, boolean asNew)`
`static SV`
`copySafely(SV v)`
Make a copy if this is a variable -- if it has myName != null.
`static Object`
`deepCopy(Object v, boolean isHash, boolean isDeep)`
Copies a hash or array deeply; invoked by Jmol script x = @a where a.type == "hash" or a.type == "varray"
`String`
`escape()`
`static float[][]`
`fflistValue(T x, int nMin)`
`static float[]`
`flistValue(T x, int nMin)`
`static Object`
`format(SV[] args, int pt)`
Accepts arguments from the format() function First argument is a format string.
`static float`
`fValue(T x)`
`static int`
`getArrayDepth(T x)`
`static BS`
`getBitSet(SV x, boolean allowNull)`
`static SV`
`getBoolean(boolean value)`
`static Object`
`getFormat(SV sv, int pt)`
`static int`
`getFormatType(String format)`
`String[]`
`getKeys(boolean isAll)`
`Lst<SV>`
`getList()`
`Map<String,SV>`
`getMap()`
`String`
`getMapKeys(int nLevels, boolean skipEmpty)`
`static SV`
`getVariable(Object x)`
`static SV`
`getVariableAD(double[] f)`
`static SV`
`getVariableList(Lst<?> v)`
`static SV`
`getVariableMap(Map<String,?> x)`
`static boolean`
`isLike(SV x1, SV x2)`
a LIKE "x" a is a string and equals x a LIKE "*x" a is a string and ends with x a LIKE "x*" a is a string and starts with x a LIKE "*x*" a is a string and contains x
`boolean`
`isNaN()`
`static boolean`
`isScalar(SV x)`
`static boolean`
`isVariableType(Object x)`
Must be updated if getVariable is updated!
`static int`
`iValue(T x)`
`SV`
`mapGet(String key)`
`void`
`mapPut(String key, SV v)`
`static SV`
`newF(float f)`
`static SV`
`newI(int i)`
`static SV`
`newS(String s)`
`static SV`
`newT(T x)`
`static SV`
`newV(int tok, Object value)`
`static Object`
`oValue(Object xx)`
`static P4`
`pt4Value(SV x)`
`static P3`
`ptValue(SV x)`
`SV`
`pushPop(SV mapKey, SV value)`
Script variables are pushed after cloning, because the name comes with them when we do otherwise they are not mutable anyway.
`static Object`
`safeJSON(String key, Object property)`
Safely create a JSON key - object pair, allowing for already-named arrays
`SV`
`setName(String name)`
`SV`
`sortMapArray(String key)`
`SV`
`sortOrReverse(int arrayPt)`
`static Object`
`sprintf(String strFormat, SV var)`
`static String[]`
`strListValue(T x)`
`static String`
`sValue(T x)`
`SV`
`toArray()`
`String`
`toJSON()`
`String`
`toString()`
`static Object`
`unescapePointOrBitsetAsVariable(Object o)`

### Methods inherited from class T

`addToken, completeCommand, equals, getAtomPropertiesLike, getCommandSet, getParamType, getSettableTokFromString, getTokenFromName, getTokensLike, getTokensType, getTokFromName, hashCode, i, isIDcmd, n, nameOf, o, t, tokAttr, tokAttrOr, toString2, tv`

### Methods inherited from class Object

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

## Field Details

### vT

public static final SV vT

### vF

public static final SV vF

### vNaN

public static final SV vNaN

### index

public int index

### myName

public String myName

### FORMAT_JSON

public static final int FORMAT_JSON

See Also:
  - Constant Field Values

### FORMAT_BASE64

public static final int FORMAT_BASE64

See Also:
  - Constant Field Values

### FORMAT_BYTEARRAY

public static final int FORMAT_BYTEARRAY

See Also:
  - Constant Field Values

### FORMAT_ARRAY

public static final int FORMAT_ARRAY

See Also:
  - Constant Field Values

### FORMAT_STRING

public static final int FORMAT_STRING

See Also:
  - Constant Field Values

### FORMAT_XYZ

public static final int FORMAT_XYZ

See Also:
  - Constant Field Values

### FORMAT_ABC

public static final int FORMAT_ABC

See Also:
  - Constant Field Values

### FORMAT_UVW

public static final int FORMAT_UVW

See Also:
  - Constant Field Values

### FORMAT_RXYZ

public static final int FORMAT_RXYZ

See Also:
  - Constant Field Values

## Constructor Details

### SV

public SV()

## Method Details

### newV

public static SV newV(int tok, Object value)

### newI

public static SV newI(int i)

### newF

public static SV newF(float f)

### newS

public static SV newS(String s)

### newT

public static SV newT(T x)

### copySafely

public static SV copySafely(SV v)
Make a copy if this is a variable -- if it has myName != null.

Parameters:
  `v` -
Returns:
  v or a copy of it

### isVariableType

public static boolean isVariableType(Object x)
Must be updated if getVariable is updated!

Parameters:
  `x` -
Returns:
  if we recognize this as a variable

### getVariable

public static SV getVariable(Object x)

Parameters:
  `x` -
Returns:
  a ScriptVariable of the input type, or if x is null, then a new ScriptVariable, or, if the type is not found, a string version

### getVariableMap

public static SV getVariableMap(Map<String,?> x)

### getVariableList

public static SV getVariableList(Lst<?> v)

### getVariableAD

public static SV getVariableAD(double[] f)

### setName

public SV setName(String name)

### asBoolean

public boolean asBoolean()

### asInt

public int asInt()

### asFloat

public float asFloat()

### asString

public String asString()

### oValue

public static Object oValue(Object xx)

Parameters:
  `xx` -
Returns:
  Object-wrapped value

### bValue

public static boolean bValue(T x)

### iValue

public static int iValue(T x)

### fValue

public static float fValue(T x)

### sValue

public static String sValue(T x)

### ptValue

public static P3 ptValue(SV x)

### pt4Value

public static P4 pt4Value(SV x)

### concatList

public static SV concatList(SV x1, SV x2, boolean asNew)

### escape

public String escape()

### unescapePointOrBitsetAsVariable

public static Object unescapePointOrBitsetAsVariable(Object o)

### getBoolean

public static SV getBoolean(boolean value)

### sprintf

public static Object sprintf(String strFormat, SV var)

### getFormatType

public static int getFormatType(String format)

Parameters:
  `format` -
Returns:
  0: JSON, 5: base64, 12: bytearray, 22: array, 28:string, etc.

### format

public static Object format(SV[] args, int pt)
Accepts arguments from the format() function First argument is a format string.

Parameters:
  `args` -
  `pt` - 0: to JSON, 5: to base64, 12: to bytearray, 22: to array
Returns:
  formatted string

### getFormat

public static Object getFormat(SV sv, int pt)

### getBitSet

public static BS getBitSet(SV x, boolean allowNull)

### areEqual

public static boolean areEqual(SV x1, SV x2)
For legacy reasons, "x" == "X" but see isLike()

Parameters:
  `x1` -
  `x2` -
Returns:
  x1 == x2

### isLike

public static boolean isLike(SV x1, SV x2)
a LIKE "x" a is a string and equals x a LIKE "*x" a is a string and ends with x a LIKE "x*" a is a string and starts with x a LIKE "*x*" a is a string and contains x

Parameters:
  `x1` -
  `x2` -
Returns:
  x1 LIKE x2

### sortOrReverse

public SV sortOrReverse(int arrayPt)

Parameters:
  `arrayPt` - 1-based or Integer.MIN_VALUE to reverse
Returns:
  sorted or reversed array

### pushPop

public SV pushPop(SV mapKey, SV value)
Script variables are pushed after cloning, because the name comes with them when we do otherwise they are not mutable anyway. We do want to have actual references to points, lists, and associative arrays

Parameters:
  `mapKey` -
  `value` - null to pop
Returns:
  array

### strListValue

public static String[] strListValue(T x)

### getArrayDepth

public static int getArrayDepth(T x)

### fflistValue

public static float[][] fflistValue(T x, int nMin)

### flistValue

public static float[] flistValue(T x, int nMin)

### toArray

public SV toArray()

### arrayToList

public SV arrayToList(SV target)

### getList

public Lst<SV> getList()

### isScalar

public static boolean isScalar(SV x)

### toJSON

public String toJSON()

Specified by:
  `toJSON` in interface `JSONEncodable`

### mapGet

public SV mapGet(String key)

### mapPut

public void mapPut(String key, SV v)

### getMap

public Map<String,SV> getMap()

### getMapKeys

public String getMapKeys(int nLevels, boolean skipEmpty)

### toString

public String toString()

Overrides:
  `toString` in class `T`

### getKeys

public String[] getKeys(boolean isAll)

### deepCopy

public static Object deepCopy(Object v, boolean isHash, boolean isDeep)
Copies a hash or array deeply; invoked by Jmol script x = @a where a.type == "hash" or a.type == "varray"

Parameters:
  `v` - hash or array
  `isHash` -
  `isDeep` - TODO
Returns:
  deeply copied variable

### sortMapArray

public SV sortMapArray(String key)

### safeJSON

public static Object safeJSON(String key, Object property)
Safely create a JSON key - object pair, allowing for already-named arrays

Parameters:
  `key` -
  `property` -
Returns:
  JSON object

### isNaN

public boolean isNaN()