下面列出了java.util.ListIterator#hasNext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public synchronized AuthCacheValue get (String pkey, String skey) {
AuthenticationInfo result = null;
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
if (list == null || list.size() == 0) {
return null;
}
if (skey == null) {
// list should contain only one element
return (AuthenticationInfo)list.get (0);
}
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (skey.startsWith (inf.path)) {
return inf;
}
}
return null;
}
public synchronized void put (String pkey, AuthCacheValue value) {
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
String skey = value.getPath();
if (list == null) {
list = new LinkedList<AuthCacheValue>();
hashtable.put(pkey, list);
}
// Check if the path already exists or a super-set of it exists
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (inf.path == null || inf.path.startsWith (skey)) {
iter.remove ();
}
}
iter.add(value);
}
private void updateModelTemplates() throws Exception {
ModelTemplateContainer modelTemplateContainer = pmanager.findModelTemplateContainer(this.currentddbid);
List<ModelTemplate> modelTemplates = modelTemplateContainer.getModelTemplates();
ArrayList<ModelTemplate> modelTemplatesUpdated = new ArrayList<ModelTemplate>();
ListIterator<ModelTemplate> modelTemplateListIter = modelTemplates.listIterator();
while (modelTemplateListIter.hasNext()) {
ModelTemplate mt = modelTemplateListIter.next();
if (mt.getId().compareTo(this.currentId) != 0) {
modelTemplatesUpdated.add(mt);
} else {
modelTemplatesUpdated.add(this.modelTemplate);
}
}
modelTemplateContainer.setModelTemplates(modelTemplatesUpdated);
modelTemplateContainer = pmanager.save(modelTemplateContainer);
}
@Override
boolean find(InjectionInfo info, Target target, Collection<AbstractInsnNode> nodes) {
SearchState state = new SearchState();
ListIterator<AbstractInsnNode> iter = target.method.instructions.iterator();
while (iter.hasNext()) {
AbstractInsnNode insn = iter.next();
if (state.isPendingCheck()) {
state.check(target, nodes, insn);
} else if (insn instanceof VarInsnNode && insn.getOpcode() == this.opcode && (this.ordinal == -1 || !state.success())) {
state.register((VarInsnNode)insn);
if (this.opcodeAfter) {
state.setPendingCheck();
} else {
state.check(target, nodes, insn);
}
}
}
return state.success();
}
/**
* Changes the role of a user in this group. Group admin rights are needed.
*
* @param user The user whose role is to be changed
* @param role The new role of the user.
* @return true if the Skype account has admin rights, and the user was in the group and didn't have this role already.
* @see #isSelfAdmin()
*/
public boolean changeUserRole(User user, Role role) {
if (!isSelfAdmin()) {
return false;
}
// we need to make sure the user is in the group to avoid getting an error
ListIterator<Pair<User, Role>> it = users.listIterator();
while (it.hasNext()) {
Pair<User, Role> pair = it.next();
if (user.equals(pair.getFirst())) {
// need to return if it already has the same role to avoid getting an error
if (role == pair.getSecond()) {
return false;
}
it.remove();
it.add(new Pair<>(user, role));
skype.changeUserRole(user, role, this);
return true;
}
}
return false;
}
/**
* Returns the driver-defined name defined in design hints for
* the specified data set parameter's model name.
* @param paramName
* @return driver-defined parameter name; may be null
*/
private String getNativeNameFromParamHints( String paramName )
{
if( m_parameterHints == null )
return null;
ListIterator iter = m_parameterHints.listIterator();
while( iter.hasNext() )
{
ParameterHint paramHint = (ParameterHint) iter.next();
if( paramHint.getName().equals( paramName ) )
return paramHint.getNativeName();
}
return null; // no matching parameter hint to give us the native name
}
private void verify() throws Throwable {
ListIterator<ILoggingEvent> actualIterator = appender.getEvents().listIterator();
for (final ExpectedLogEvent expectedEvent : expectedEvents) {
boolean found = false;
while (actualIterator.hasNext()) {
ILoggingEvent actual = actualIterator.next();
if (expectedEvent.matches(actual)) {
found = true;
break;
}
}
if (!found) {
fail(expectedEvent.toString());
}
}
}
public synchronized void put (String pkey, AuthCacheValue value) {
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
String skey = value.getPath();
if (list == null) {
list = new LinkedList<AuthCacheValue>();
hashtable.put(pkey, list);
}
// Check if the path already exists or a super-set of it exists
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (inf.path == null || inf.path.startsWith (skey)) {
iter.remove ();
}
}
iter.add(value);
}
/**
* 执行识别
*
* @param segResult 粗分结果
* @param wordNetOptimum 粗分结果对应的词图
* @param wordNetAll 全词图
*/
public static void recognition(List<Vertex> segResult, WordNet wordNetOptimum, WordNet wordNetAll) {
StringBuilder sbName = new StringBuilder();
int appendTimes = 0;
ListIterator<Vertex> listIterator = segResult.listIterator();
listIterator.next();
int line = 1;
int activeLine = 1;
while (listIterator.hasNext()) {
Vertex vertex = listIterator.next();
if (appendTimes > 0) {
if (vertex.guessNature() == Nature.nrf || TranslatedPersonDictionary.containsKey(vertex.realWord)) {
sbName.append(vertex.realWord);
++appendTimes;
} else {
// 识别结束
if (appendTimes > 1) {
if (Xmnlp.Config.DEBUG) {
System.out.println("音译人名识别出:" + sbName.toString());
}
wordNetOptimum.insert(activeLine, new Vertex(Predefine.TAG_PEOPLE, sbName.toString(), new CoreDictionary.Attribute(Nature.nrf), NRConstant.WORD_ID), wordNetAll);
}
sbName.setLength(0);
appendTimes = 0;
}
} else {
// nrf和nsf触发识别
if (vertex.guessNature() == Nature.nrf || vertex.getNature() == Nature.nsf
// || TranslatedPersonDictionary.containsKey(vertex.realWord)
) {
sbName.append(vertex.realWord);
++appendTimes;
activeLine = line;
}
}
line += vertex.realWord.length();
}
}
public static Set<ASTSliceGroup> getExtractMethodRefactoringOpportunities(IJavaProject project) {
CompilationUnitCache.getInstance().clearCache();
try {
if(ASTReader.getSystemObject() != null && project.equals(ASTReader.getExaminedProject())) {
new ASTReader(project, ASTReader.getSystemObject(), null);
}
else {
new ASTReader(project, null);
}
}
catch(CompilationErrorDetectedException e) {
e.printStackTrace();
}
SystemObject systemObject = ASTReader.getSystemObject();
Set<ASTSliceGroup> extractedSliceGroups = new TreeSet<ASTSliceGroup>();
if(systemObject != null) {
Set<ClassObject> classObjectsToBeExamined = new LinkedHashSet<ClassObject>();
classObjectsToBeExamined.addAll(systemObject.getClassObjects());
for(ClassObject classObject : classObjectsToBeExamined) {
if(!classObject.isEnum() && !classObject.isInterface() && !classObject.isGeneratedByParserGenenator()) {
ListIterator<MethodObject> methodIterator = classObject.getMethodIterator();
while(methodIterator.hasNext()) {
MethodObject methodObject = methodIterator.next();
processMethod(extractedSliceGroups,classObject, methodObject);
}
}
}
}
return extractedSliceGroups;
}
public void insert(Event newEvent, boolean uniqueTimes) {
ListIterator<Event> li = l.listIterator();
while (li.hasNext()) {
int sgn = newEvent.compareTo(li.next());
if (sgn < 0) {
li.previous();
break;
} else if (uniqueTimes && (sgn == 0)) {
li.remove();
break;
}
}
li.add(newEvent);
}
/**
* Releases for normal dispatching to the current focus owner all
* KeyEvents which were enqueued because of a call to
* <code>enqueueKeyEvents</code> with the same timestamp and Component.
* If the given timestamp is less than zero, the outstanding enqueue
* request for the given Component with the <b>oldest</b> timestamp (if
* any) should be cancelled.
*
* @param after the timestamp specified in the call to
* <code>enqueueKeyEvents</code>, or any value < 0
* @param untilFocused the Component specified in the call to
* <code>enqueueKeyEvents</code>
* @see #enqueueKeyEvents
* @see #discardKeyEvents
*/
protected synchronized void dequeueKeyEvents(long after,
Component untilFocused) {
if (untilFocused == null) {
return;
}
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
focusLog.finer("Dequeue at {0} for {1}",
after, untilFocused);
}
TypeAheadMarker marker;
ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator
((after >= 0) ? typeAheadMarkers.size() : 0);
if (after < 0) {
while (iter.hasNext()) {
marker = iter.next();
if (marker.untilFocused == untilFocused)
{
iter.remove();
return;
}
}
} else {
while (iter.hasPrevious()) {
marker = iter.previous();
if (marker.untilFocused == untilFocused &&
marker.after == after)
{
iter.remove();
return;
}
}
}
}
public void consumeAnnotations(SpanList root) {
if (root instanceof AlternateSpanList) {
parseAlternateLists((AlternateSpanList)root);
if (debug) System.out.println("\nGetting annotations for the SpanList itself : [" + root.getFrom() + ", " + root.getTo() + "] ");
getAnnotationsForNode(root);
return;
}
if (debug) System.out.println("\n\nSpanList: [" + root.getFrom() + ", " + root.getTo() + "] num Children: " + root.numChildren());
if (debug) System.out.println("-------------------");
Iterator<SpanNode> childIterator = root.childIterator();
while (childIterator.hasNext()) {
SpanNode node = childIterator.next();
//System.out.println("Span Node: " + node); // + " Span Text: " + node.getText(fieldValStr));
if (debug) System.out.println("\n\nSpan Node: [" + node.getFrom() + ", " + node.getTo() + "] ");
if (node instanceof AlternateSpanList) {
parseAlternateLists((AlternateSpanList)node);
if (debug) System.out.println("---- Alternate SpanList complete ---");
} else if (node instanceof SpanList) {
if (debug) System.out.println("Encountered another span list");
SpanList spl = (SpanList) node;
ListIterator<SpanNode> lli = spl.childIterator();
while (lli.hasNext()) System.out.print(" " + lli.next() + " ");
consumeAnnotations((SpanList) node);
} else {
if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
getAnnotationsForNode(node);
}
}
if (debug) System.out.println("\nGetting annotations for the SpanList itself : [" + root.getFrom() + ", " + root.getTo() + "] ");
getAnnotationsForNode(root);
}
public void modifyProcessor ( final String triggerId, final String processorId, final String configuration )
{
Objects.requireNonNull ( triggerId );
Objects.requireNonNull ( processorId );
final List<TriggerProcessorConfiguration> trigger = this.processors.get ( triggerId );
if ( trigger == null )
{
throw new UnknownProcessorException ( triggerId, processorId );
}
final ListIterator<TriggerProcessorConfiguration> i = trigger.listIterator ();
while ( i.hasNext () )
{
final TriggerProcessorConfiguration cfg = i.next ();
if ( !cfg.getId ().equals ( processorId ) )
{
continue;
}
// replace
i.set ( new TriggerProcessorConfiguration ( processorId, cfg.getFactoryId (), configuration ) );
// return
return;
}
// did not return, so not found
throw new UnknownProcessorException ( triggerId, processorId );
}
@Override
public <T> T forSelected(Interpreter interpreter, Selectee<T> callback) {
T selected = null;
interpreter.willSelect(this);
if (interpreter.scopeDepth() != 0) {
// Pop the current selection off of the stack to take it out of scope.
final Value scope = interpreter.popScope().toValue();
// Only records can have children.
if (scope instanceof Record) {
final ListIterator<Item> children = ((Record) scope).listIterator();
// For each child, while none have been selected:
while (selected == null && children.hasNext()) {
final Item child = children.next();
// Push the child onto the scope stack.
interpreter.pushScope(child);
// Subselect the child.
selected = this.then.forSelected(interpreter, callback);
// Pop the child off of the scope stack.
interpreter.popScope();
}
}
// Push the current selection back onto the stack.
interpreter.pushScope(scope);
}
interpreter.didSelect(this, selected);
return selected;
}
private Process createCommandProcess(Command command, ListIterator<CliToken> tokens, int jobId, Term term, ResultDistributor resultDistributor) throws IOException {
List<CliToken> remaining = new ArrayList<CliToken>();
List<CliToken> pipelineTokens = new ArrayList<CliToken>();
boolean isPipeline = false;
RedirectHandler redirectHandler = null;
List<Function<String, String>> stdoutHandlerChain = new ArrayList<Function<String, String>>();
String cacheLocation = null;
while (tokens.hasNext()) {
CliToken remainingToken = tokens.next();
if (remainingToken.isText()) {
String tokenValue = remainingToken.value();
if ("|".equals(tokenValue)) {
isPipeline = true;
// 将管道符|之后的部分注入为输出链上的handler
injectHandler(stdoutHandlerChain, pipelineTokens);
continue;
} else if (">>".equals(tokenValue) || ">".equals(tokenValue)) {
String name = getRedirectFileName(tokens);
if (name == null) {
// 如果没有指定重定向文件名,那么重定向到以jobid命名的缓存中
name = LogUtil.cacheDir() + File.separator + Constants.PID + File.separator + jobId;
cacheLocation = name;
if (getRedirectJobCount() == 8) {
throw new IllegalStateException("The amount of async command that saving result to file can't > 8");
}
}
redirectHandler = new RedirectHandler(name, ">>".equals(tokenValue));
break;
}
}
if (isPipeline) {
pipelineTokens.add(remainingToken);
} else {
remaining.add(remainingToken);
}
}
injectHandler(stdoutHandlerChain, pipelineTokens);
if (redirectHandler != null) {
stdoutHandlerChain.add(redirectHandler);
} else {
stdoutHandlerChain.add(new TermHandler(term));
if (GlobalOptions.isSaveResult) {
stdoutHandlerChain.add(new RedirectHandler());
}
}
ProcessOutput ProcessOutput = new ProcessOutput(stdoutHandlerChain, cacheLocation, term);
ProcessImpl process = new ProcessImpl(command, remaining, command.processHandler(), ProcessOutput, resultDistributor);
process.setTty(term);
return process;
}
/**
* Collect collection.
*
* @param reader
* the reader
* @param docSet
* the doc set
* @param collectionInfo
* the collection info
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void collectCollection(IndexReader reader, List<Integer> docSet,
ComponentCollection collectionInfo) throws IOException {
if (collectionInfo.action().equals(ComponentCollection.ACTION_CHECK)) {
// can't do anything in lucene for check
} else if (collectionInfo.action()
.equals(ComponentCollection.ACTION_LIST)) {
// can't do anything in lucene for list
} else if (collectionInfo.action()
.equals(ComponentCollection.ACTION_CREATE)) {
BytesRef term = null;
PostingsEnum postingsEnum = null;
Integer docId;
Integer termDocId = -1;
Terms terms;
LeafReaderContext lrc;
LeafReader r;
ListIterator<LeafReaderContext> iterator = reader.leaves().listIterator();
while (iterator.hasNext()) {
lrc = iterator.next();
r = lrc.reader();
for (String field : collectionInfo.fields()) {
if ((terms = r.terms(field)) != null) {
TermsEnum termsEnum = terms.iterator();
while ((term = termsEnum.next()) != null) {
Iterator<Integer> docIterator = docSet.iterator();
postingsEnum = termsEnum.postings(postingsEnum,
PostingsEnum.NONE);
termDocId = -1;
while (docIterator.hasNext()) {
docId = docIterator.next() - lrc.docBase;
if ((docId >= termDocId) && ((docId.equals(termDocId))
|| ((termDocId = postingsEnum.advance(docId))
.equals(docId)))) {
collectionInfo.addValue(term.utf8ToString());
break;
}
if (termDocId.equals(PostingsEnum.NO_MORE_DOCS)) {
break;
}
}
}
}
}
}
}
}
/**
* This test case checks the changes made in.
* LinkStateAttributes (For Link State Attribute Type 1173 i.e. Extended Administrative Group)
* as bug fix for bug 8036
*/
@Test
public void bgpUpdateMessage2Test4() throws BgpParseException {
byte[] updateMsg = new byte[]{
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0x01, (byte) 0x19, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x90,
(byte) 0x0e, (byte) 0x00, (byte) 0x6e, (byte) 0x40, (byte) 0x04, (byte) 0x47, (byte) 0x10, (byte) 0x20,
(byte) 0x01, (byte) 0x05, (byte) 0xb0, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x50,
(byte) 0x54, (byte) 0x00, (byte) 0xff, (byte) 0xfe, (byte) 0xb8, (byte) 0x35, (byte) 0x2b, (byte) 0x00,
(byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x55, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0xe9, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x1a, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x64, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x2b, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x1a, (byte) 0x02,
(byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x64, (byte) 0x02,
(byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,
(byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x1b, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x70, (byte) 0x70, (byte) 0x70,
(byte) 0xd5, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0x70, (byte) 0x70, (byte) 0x70,
(byte) 0xd4, (byte) 0x40, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x40, (byte) 0x02, (byte) 0x00,
(byte) 0x40, (byte) 0x05, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x64, (byte) 0x80,
(byte) 0x1d, (byte) 0x7f, (byte) 0x04, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0xc0, (byte) 0xa8,
(byte) 0x07, (byte) 0xca, (byte) 0x04, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0xc0, (byte) 0xa8,
(byte) 0x07, (byte) 0xc9, (byte) 0x04, (byte) 0x40, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x41, (byte) 0x00, (byte) 0x04, (byte) 0x49, (byte) 0xb7,
(byte) 0x1b, (byte) 0x00, (byte) 0x04, (byte) 0x42, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x43, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x44,
(byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x04, (byte) 0x47,
(byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x0a,
//------------ BGP-LS ATTR_EXTNDED_ADMNSTRATIVE_GRP Attribute------------------------------------------
(byte) 0x04, (byte) 0x95, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
//-----------------------------------------------------------------------------------------------------
};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(updateMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message = null;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpUpdateMsg.class));
BgpUpdateMsg receivedMsg = (BgpUpdateMsg) message;
List<BgpValueType> pathAttr = receivedMsg.bgpPathAttributes().pathAttributes();
ListIterator<BgpValueType> iterator = pathAttr.listIterator();
while (iterator.hasNext()) {
BgpValueType attr = iterator.next();
if (attr instanceof LinkStateAttributes) {
assertThat(((LinkStateAttributes) attr).linkStateAttributes().size(), is(9));
}
}
}
protected FieldAction seekFieldAction(boolean shouldReadCurrent, Schema.Field field,
ListIterator<Symbol> symbolIterator) {
Schema.Type type = field.schema().getType();
if (!shouldReadCurrent) {
return FieldAction.fromValues(type, false, EMPTY_SYMBOL);
}
boolean shouldRead = true;
Symbol fieldSymbol = END_SYMBOL;
if (Schema.Type.RECORD.equals(type)) {
if (symbolIterator.hasNext()) {
fieldSymbol = symbolIterator.next();
if (fieldSymbol instanceof Symbol.SkipAction) {
return FieldAction.fromValues(type, false, fieldSymbol);
} else {
symbolIterator.previous();
}
}
return FieldAction.fromValues(type, true, symbolIterator);
}
while (symbolIterator.hasNext()) {
Symbol symbol = symbolIterator.next();
if (symbol instanceof Symbol.ErrorAction) {
throw new FastDeserializerGeneratorException(((Symbol.ErrorAction) symbol).msg);
}
if (symbol instanceof Symbol.SkipAction) {
shouldRead = false;
fieldSymbol = symbol;
break;
}
if (symbol instanceof Symbol.WriterUnionAction) {
if (symbolIterator.hasNext()) {
symbol = symbolIterator.next();
if (symbol instanceof Symbol.Alternative) {
shouldRead = true;
fieldSymbol = symbol;
break;
}
}
}
if (symbol.kind == Symbol.Kind.TERMINAL) {
shouldRead = true;
if (symbolIterator.hasNext()) {
symbol = symbolIterator.next();
if (symbol instanceof Symbol.Repeater) {
fieldSymbol = symbol;
} else {
fieldSymbol = symbolIterator.previous();
}
} else if (!symbolIterator.hasNext() && getSymbolPrintName(symbol) != null) {
fieldSymbol = symbol;
}
break;
}
}
return FieldAction.fromValues(type, shouldRead, fieldSymbol);
}
@RequestMapping("/moveHeading")
public String moveHeading(@ModelAttribute("authoringForm") AuthoringForm authoringForm,
HttpServletRequest request) {
SessionMap<String, Object> map = getSessionMap(request, authoringForm);
int headingIndex = WebUtil.readIntParam(request, "headingIndex");
String direction = WebUtil.readStrParam(request, "direction");
ListIterator<ScribeHeading> iter = getHeadingList(map).listIterator(headingIndex);
ScribeHeading heading = iter.next();
iter.remove();
// move to correct location
if (direction.equals("up")) {
if (iter.hasPrevious()) {
iter.previous();
}
} else if (direction.equals("down")) {
if (iter.hasNext()) {
iter.next();
}
} else {
// invalid direction, don't move anywhere.
logger.error("moveHeading: received invalid direction : " + direction);
}
// adding heading back into list
iter.add(heading);
// update the displayOrder
int i = 0;
for (ScribeHeading elem : getHeadingList(map)) {
elem.setDisplayOrder(i);
i++;
}
request.setAttribute("sessionMapID", map.getSessionID());
return "pages/authoring/headingResponse";
}