@Override public String toString() { throw new SoyDataException("Attempted to coerce undefined value into a string."); }
/** * Prepends an index to the data path where this error occurred. E.g. if the dataPath was * previously 'foo.goo' and the index to prepend is 2, then the new data path will be * '[2].foo.goo'. * * @param index The index to prepend. */ public void prependIndexToDataPath(int index) { prependKeyToDataPath("[" + index + "]"); }
/** Initializes this SoyMapData from an existing map. */ public SoyMapData(Map<String, ?> data) { map = new LinkedHashMap<>(data.size()); for (Map.Entry<String, ?> entry : data.entrySet()) { String key; try { key = entry.getKey(); } catch (ClassCastException cce) { throw new SoyDataException( "Attempting to convert a map with non-string key to Soy data (key type " + ((Map.Entry<?, ?>) entry).getKey().getClass().getName() + ")."); } Object value = entry.getValue(); try { map.put(key, SoyData.createFromExistingData(value)); } catch (SoyDataException sde) { sde.prependKeyToDataPath(key); throw sde; } } }
/** * Private helper shared by constructor SoyListData(Iterable) and add(Object...). * @param data The data to add. */ private void add(Iterable<?> data) { for (Object el : data) { try { add(SoyData.createFromExistingData(el)); } catch (SoyDataException sde) { sde.prependIndexToDataPath(list.size()); throw sde; } } }
/** * Constructor that initializes this SoyMapData from an existing map. * * @param data The initial data in an existing map. */ public SoyMapData(Map<String, ?> data) { map = new LinkedHashMap<>(data.size()); for (Map.Entry<String, ?> entry : data.entrySet()) { String key; try { key = entry.getKey(); } catch (ClassCastException cce) { throw new SoyDataException( "Attempting to convert a map with non-string key to Soy data (key type " + ((Map.Entry<?, ?>) entry).getKey().getClass().getName() + ")."); } Object value = entry.getValue(); try { map.put(key, SoyData.createFromExistingData(value)); } catch (SoyDataException sde) { sde.prependKeyToDataPath(key); throw sde; } } }
/** * Private helper shared by constructor SoyListData(Iterable) and add(Object...). * * @param data The data to add. */ private void add(Iterable<?> data) { for (Object el : data) { try { add(SoyData.createFromExistingData(el)); } catch (SoyDataException sde) { sde.prependIndexToDataPath(list.size()); throw sde; } } }
@Override public String toString() { throw new SoyDataException("Attempted to coerce undefined value into a string."); }
/** * Constructor that initializes this SoyMapData from an existing map. * @param data The initial data in an existing map. */ public SoyMapData(Map<String, ?> data) { map = new LinkedHashMap<String, SoyData>(data.size()); for (Map.Entry<String, ?> entry : data.entrySet()) { String key; try { key = entry.getKey(); } catch (ClassCastException cce) { throw new SoyDataException( "Attempting to convert a map with non-string key to Soy data (key type " + ((Map.Entry<?, ?>) entry).getKey().getClass().getName() + ")."); } Object value = entry.getValue(); try { map.put(key, SoyData.createFromExistingData(value)); } catch (SoyDataException sde) { sde.prependKeyToDataPath(key); throw sde; } } }
/** * Prepends an index to the data path where this error occurred. * E.g. if the dataPath was previously 'foo.goo' and the index to prepend is 2, then the new * data path will be '[2].foo.goo'. * @param index The index to prepend. */ public void prependIndexToDataPath(int index) { prependKeyToDataPath("[" + index + "]"); }
/** * Private helper shared by constructor SoyListData(Iterable) and add(Object...). * * @param data The data to add. */ private void add(Iterable<?> data) { for (Object el : data) { try { add(SoyData.createFromExistingData(el)); } catch (SoyDataException sde) { sde.prependIndexToDataPath(list.size()); throw sde; } } }
@Override public String toString() { throw new SoyDataException("Attempted to coerce undefined value into a string."); }
/** * Prepends an index to the data path where this error occurred. E.g. if the dataPath was * previously 'foo.goo' and the index to prepend is 2, then the new data path will be * '[2].foo.goo'. * * @param index The index to prepend. */ public void prependIndexToDataPath(int index) { prependKeyToDataPath("[" + index + "]"); }
@Override public double floatValue() { throw new SoyDataException( "Expecting float value but instead encountered type " + getClass().getSimpleName()); }
@Override public boolean booleanValue() { throw new SoyDataException( "Expecting boolean value but instead encountered type " + getClass().getSimpleName()); }
@Override public double numberValue() { throw new SoyDataException( "Expecting number value but instead encountered type " + getClass().getSimpleName()); }
@Override public double numberValue() { throw new SoyDataException( "Expecting number value but instead encountered type " + getClass().getSimpleName()); }
/** * Precondition: Only call this method if you know that this SoyData object is a float. * This method gets the float value of this float object. * @return The float value of this float object. * @throws SoyDataException If this object is not actually a float. */ public double floatValue() { throw new SoyDataException("Expecting float value but instead encountered type " + getClass().getSimpleName()); }
/** * Precondition: Only call this method if you know that this SoyData object is a number. * This method gets the float value of this number object (converting integer to float if * necessary). * @return The float value of this number object. * @throws SoyDataException If this object is not actually a number. */ public double numberValue() { throw new SoyDataException("Expecting number value but instead encountered type " + getClass().getSimpleName()); }
/** * Precondition: Only call this method if you know that this SoyData object is a string. * This method gets the string value of this string object. * @return The string value of this string object. * @throws SoyDataException If this object is not actually a string. */ public String stringValue() { throw new SoyDataException("Expecting string value but instead encountered type " + getClass().getSimpleName()); }
@Override public boolean booleanValue() { throw new SoyDataException( "Expecting boolean value but instead encountered type " + getClass().getSimpleName()); }