public final Object exec(List args) throws TemplateModelException { int argCnt = args.size(); checkMethodArgCount(argCnt, 1, 2); TemplateModel searched = (TemplateModel) args.get(0); int foundAtIdx; if (argCnt > 1) { int startIndex = getNumberMethodArg(args, 1).intValue(); // In 2.3, we prefer TemplateSequenceModel for backward compatibility, even if startIndex is 0: foundAtIdx = m_seq != null ? findInSeq(searched, startIndex) : findInCol(searched, startIndex); } else { foundAtIdx = m_seq != null ? findInSeq(searched) : findInCol(searched); } return foundAtIdx == -1 ? Constants.MINUS_ONE : new SimpleNumber(foundAtIdx); }
public final Object exec(List args) throws TemplateModelException { int argCnt = args.size(); checkMethodArgCount(argCnt, 1, 2); TemplateModel searched = (TemplateModel) args.get(0); int foundAtIdx; if (argCnt > 1) { int startIndex = getNumberMethodArg(args, 1).intValue(); // In 2.3, we prefer TemplateSequenceModel for backward compatibility, even if startIndex is 0: foundAtIdx = m_seq != null ? findInSeq(searched, startIndex) : findInCol(searched, startIndex); } else { foundAtIdx = m_seq != null ? findInSeq(searched) : findInCol(searched); } return foundAtIdx == -1 ? Constants.MINUS_ONE : new SimpleNumber(foundAtIdx); }
public final Object exec(List args) throws TemplateModelException { int argCnt = args.size(); checkMethodArgCount(argCnt, 1, 2); TemplateModel searched = (TemplateModel) args.get(0); int foundAtIdx; if (argCnt > 1) { int startIndex = getNumberMethodArg(args, 1).intValue(); // In 2.3, we prefer TemplateSequenceModel for backward compatibility, even if startIndex is 0: foundAtIdx = m_seq != null ? findInSeq(searched, startIndex) : findInCol(searched, startIndex); } else { foundAtIdx = m_seq != null ? findInSeq(searched) : findInCol(searched); } return foundAtIdx == -1 ? Constants.MINUS_ONE : new SimpleNumber(foundAtIdx); }
private int findInSeq(TemplateModel searched, int startIndex) throws TemplateModelException { int seqSize = m_seq.size(); if (findFirst) { if (startIndex >= seqSize) { return -1; } if (startIndex < 0) { startIndex = 0; } } else { if (startIndex >= seqSize) { startIndex = seqSize - 1; } if (startIndex < 0) { return -1; } } return findInSeq(searched, startIndex, seqSize); }
private int findInSeq(TemplateModel searched, int startIndex) throws TemplateModelException { int seqSize = m_seq.size(); if (findFirst) { if (startIndex >= seqSize) { return -1; } if (startIndex < 0) { startIndex = 0; } } else { if (startIndex >= seqSize) { startIndex = seqSize - 1; } if (startIndex < 0) { return -1; } } return findInSeq(searched, startIndex, seqSize); }
int findInSeq(TemplateModel searched) throws TemplateModelException { final int seqSize = m_seq.size(); final int actualStartIndex; if (findFirst) { actualStartIndex = 0; } else { actualStartIndex = seqSize - 1; } return findInSeq(searched, actualStartIndex, seqSize); }
int findInSeq(TemplateModel searched) throws TemplateModelException { final int seqSize = m_seq.size(); final int actualStartIndex; if (findFirst) { actualStartIndex = 0; } else { actualStartIndex = seqSize - 1; } return findInSeq(searched, actualStartIndex, seqSize); }
private int findInSeq(TemplateModel searched, int startIndex) throws TemplateModelException { int seqSize = m_seq.size(); if (findFirst) { if (startIndex >= seqSize) { return -1; } if (startIndex < 0) { startIndex = 0; } } else { if (startIndex >= seqSize) { startIndex = seqSize - 1; } if (startIndex < 0) { return -1; } } return findInSeq(searched, startIndex, seqSize); }
int findInSeq(TemplateModel searched) throws TemplateModelException { final int seqSize = m_seq.size(); final int actualStartIndex; if (findFirst) { actualStartIndex = 0; } else { actualStartIndex = seqSize - 1; } return findInSeq(searched, actualStartIndex, seqSize); }