/** * 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 + "]"); }
/** * 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 + "]"); }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }