List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException(int index)
From source file:au.org.ala.delta.editor.slotfile.model.SlotFileDataSet.java
@Override protected Character doGetCharacter(int number) { synchronized (_vop) { if (number > getNumberOfCharacters()) { throw new IndexOutOfBoundsException("No such Character (" + number + ">" + getNumberOfCharacters()); }/* w w w . ja v a2 s .c o m*/ int charId = _vop.getDeltaMaster().uniIdFromCharNo(number); VOCharBaseDesc characterDesc = (VOCharBaseDesc) _vop.getDescFromId(charId); return getFactory().wrapCharacter(characterDesc, number); } }
From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.DenseMatrix.java
/** * @param indices The index of the entry within the matrix to be returned. * If a single index is given, it assumes ind2sub behaviour (index = i*rows+j) and returns that index * If a pair of indices are given, it assumes standard lookup behaviour and returns the index at the given matrix "coordinate". * @return the entry at index specified//from w ww . j a v a 2 s. c o m * */ @Override public Double getEntry(int... indices) { if (indices.length > 2) { throw new IndexOutOfBoundsException( "Trying to access a 2D array representation with tuple>2 is forbidden!"); } else if (indices.length == 2) { return _data[_rowPtr[indices[0]] + indices[1]]; } else { return _data[indices[0]]; } }
From source file:com.netxforge.oss2.xml.event.Events.java
/** * Method getEvent.//from w w w.j a va 2 s. c o m * * @param index * @throws java.lang.IndexOutOfBoundsException if the index * given is outside the bounds of the collection * @return the value of the com.netxforge.oss2.core.xml.event.Event * at the given index */ public com.netxforge.oss2.xml.event.Event getEvent(final int index) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._eventList.size()) { throw new IndexOutOfBoundsException( "getEvent: Index value '" + index + "' not in range [0.." + (this._eventList.size() - 1) + "]"); } return (com.netxforge.oss2.xml.event.Event) _eventList.get(index); }
From source file:com.nofuturecorp.www.connector.DataSet.java
/** * Return Column name with index columnIndex * @param columnIndex//from w w w . j ava2 s. c o m * @return Column Name or null * @throws IndexOutOfBoundsException */ public String getColumnName(int columnIndex) { try { if (columnIndex < 0) { throw new IndexOutOfBoundsException("columnIndex cannot be negative"); } if (dataSet.get(columnIndex).keySet().size() - 1 > columnIndex) { throw new IndexOutOfBoundsException("columnIndex exceed last column index"); } return new ArrayList<String>(dataSet.get(columnIndex).keySet()).get(columnIndex); } catch (Exception e) { return null; } }
From source file:com.l2jfree.gameserver.model.skills.conditions.ConditionParser.java
private Condition parseCondition(Node n, Object template, boolean force, boolean onlyFirst) { Condition cond = null;// w ww .j a v a 2s. c o m for (; n != null; n = n.getNextSibling()) { if (n.getNodeType() == Node.ELEMENT_NODE) { if (cond != null) throw new IllegalStateException("Full condition"); else if ("and".equalsIgnoreCase(n.getNodeName())) cond = parseLogicAnd(n, template); else if ("or".equalsIgnoreCase(n.getNodeName())) cond = parseLogicOr(n, template); else if ("not".equalsIgnoreCase(n.getNodeName())) cond = parseLogicNot(n, template); else if ("player".equalsIgnoreCase(n.getNodeName())) cond = parsePlayerCondition(n, template); else if ("target".equalsIgnoreCase(n.getNodeName())) cond = parseTargetCondition(n, template); else if ("using".equalsIgnoreCase(n.getNodeName())) cond = parseUsingCondition(n, template); else if ("game".equalsIgnoreCase(n.getNodeName())) cond = parseGameCondition(n, template); else throw new IllegalStateException("Unrecognized condition <" + n.getNodeName() + ">"); if (onlyFirst) return cond; } } if (force && cond == null) throw new IndexOutOfBoundsException("Empty condition"); return cond; }
From source file:org.camunda.spin.impl.json.jackson.JacksonJsonLogger.java
public IndexOutOfBoundsException indexOutOfBounds(Integer index, Integer size) { return new IndexOutOfBoundsException( exceptionMessage("012", "Index is out of bound! Index: '{}', Size: '{}'", index, size)); }
From source file:com.qualogy.qafe.core.application.ApplicationCluster.java
private void put(ApplicationContext context) { if (context == null) throw new IllegalArgumentException("cannot put with null object"); contexts.put(context.getId(), context); if (!readOrderList.contains(context.getId())) { readOrderList.add(context.getId()); }/* w ww .ja va 2s .c o m*/ if (readOrderList.size() != contexts.size()) throw new IndexOutOfBoundsException("readorderlist size is not equal to contexts size"); }
From source file:com.sirma.itt.seip.time.ISO8601DateFormat.java
/** * Parse date from ISO formatted string. * * @param isoDate/* w w w . ja v a2 s . co m*/ * ISO string to parse * @return the date */ public static Date parse(String isoDate) { if (StringUtils.isBlank(isoDate)) { return null; } Date parsed = null; try { int offset = 0; // extract year int year = Integer.parseInt(isoDate.substring(offset, offset += 4)); if (isoDate.charAt(offset) != '-') { throw new IndexOutOfBoundsException(EXPECTED_CHARACTER_BUT_FOUND + isoDate.charAt(offset)); } // extract month int month = Integer.parseInt(isoDate.substring(offset += 1, offset += 2)); if (isoDate.charAt(offset) != '-') { throw new IndexOutOfBoundsException(EXPECTED_CHARACTER_BUT_FOUND + isoDate.charAt(offset)); } // extract day int day = Integer.parseInt(isoDate.substring(offset += 1, offset += 2)); if (isoDate.charAt(offset) != 'T') { throw new IndexOutOfBoundsException("Expected T character but found " + isoDate.charAt(offset)); } // extract hours, minutes, seconds and milliseconds int hour = Integer.parseInt(isoDate.substring(offset += 1, offset += 2)); if (isoDate.charAt(offset) != ':') { throw new IndexOutOfBoundsException(EXPECTED_CHARACTER_BUT_FOUND2 + isoDate.charAt(offset)); } int minutes = Integer.parseInt(isoDate.substring(offset += 1, offset += 2)); if (isoDate.charAt(offset) != ':') { throw new IndexOutOfBoundsException(EXPECTED_CHARACTER_BUT_FOUND2 + isoDate.charAt(offset)); } int seconds = Integer.parseInt(isoDate.substring(offset += 1, offset += 2)); int milliseconds = 0; if (isoDate.charAt(offset) == '.') { // ALF-3803 bug fix, milliseconds are optional milliseconds = Integer.parseInt(isoDate.substring(offset += 1, offset += 3)); } // extract timezone String timezoneId; char timezoneIndicator = isoDate.charAt(offset); if (timezoneIndicator == '+' || timezoneIndicator == '-') { timezoneId = "GMT" + isoDate.substring(offset); } else if (timezoneIndicator == 'Z') { timezoneId = "GMT"; } else { throw new IndexOutOfBoundsException("Invalid time zone indicator " + timezoneIndicator); } // Get the timezone Map<String, TimeZone> timezoneMap = TIMEZONES.get(); if (timezoneMap == null) { timezoneMap = new HashMap<>(3); TIMEZONES.set(timezoneMap); } TimeZone timezone = timezoneMap.get(timezoneId); if (timezone == null) { timezone = TimeZone.getTimeZone(timezoneId); timezoneMap.put(timezoneId, timezone); } if (!timezone.getID().equals(timezoneId)) { throw new IndexOutOfBoundsException(); } // initialize Calendar object# // Note: always de-serialise from Gregorian Calendar Calendar calendar = new GregorianCalendar(timezone); calendar.setLenient(false); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minutes); calendar.set(Calendar.SECOND, seconds); calendar.set(Calendar.MILLISECOND, milliseconds); // extract the date parsed = calendar.getTime(); } catch (IndexOutOfBoundsException e) { throw new EmfRuntimeException(FAILED_TO_PARSE_DATE + isoDate, e); } catch (NumberFormatException e) { throw new EmfRuntimeException(FAILED_TO_PARSE_DATE + isoDate, e); } catch (IllegalArgumentException e) { throw new EmfRuntimeException(FAILED_TO_PARSE_DATE + isoDate, e); } return parsed; }
From source file:Main.java
/** * <p>Removes the element at the specified position from the specified array. * All subsequent elements are shifted to the left (substracts one from * their indices).</p>/*from ww w. j av a 2 s .co m*/ * * <p>This method returns a new array with the same elements of the input * array except the element on the specified position. The component * type of the returned array is always the same as that of the input * array.</p> * * <p>If the input array is <code>null</code>, an IndexOutOfBoundsException * will be thrown, because in that case no valid index can be specified.</p> * * @param array the array to remove the element from, may not be <code>null</code> * @param index the position of the element to be removed * @return A new array containing the existing elements except the element * at the specified position. * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= array.length), or if the array is <code>null</code>. * @since 2.1 */ private static Object remove(Object array, int index) { int length = getLength(array); if (index < 0 || index >= length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length); } Object result = Array.newInstance(array.getClass().getComponentType(), length - 1); System.arraycopy(array, 0, result, 0, index); if (index < length - 1) { System.arraycopy(array, index + 1, result, index, length - index - 1); } return result; }
From source file:com.netxforge.oss2.xml.event.Mask.java
/** * Method getMaskelement./*from ww w. j av a2 s . co m*/ * * @param index * @throws java.lang.IndexOutOfBoundsException if the index * given is outside the bounds of the collection * @return the value of the * com.netxforge.oss2.core.xml.event.Maskelement at the given index */ public com.netxforge.oss2.xml.event.Maskelement getMaskelement(final int index) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._maskelementList.size()) { throw new IndexOutOfBoundsException("getMaskelement: Index value '" + index + "' not in range [0.." + (this._maskelementList.size() - 1) + "]"); } return (com.netxforge.oss2.xml.event.Maskelement) _maskelementList.get(index); }