net.sf.okapi.common.Event.getEventType()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中net.sf.okapi.common.Event.getEventType()方法的一些代码示例,展示了Event.getEventType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getEventType()方法的具体详情如下:
包路径:net.sf.okapi.common.Event
类名称:Event
方法名:getEventType

Event.getEventType介绍

[英]Gets the type of this event.
[中]获取此事件的类型。

代码示例

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-regex

private Event nextEvent () {
  if ( queue.size() == 0 ) return null;
  if ( queue.peek().getEventType() == EventType.END_DOCUMENT ) {
    parseState = 0; // No more event after
  }
  return queue.poll();
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Does the current {@link TextUnit} have a parent?
 * 
 * @return true, if successful
 */
public boolean hasParentTextUnit() {
  if (tempFilterEventStack.isEmpty()) {
    return false;
  }
  boolean first = true;
  // skip current TextUnit - the one we are currently processing
  for (Event fe : tempFilterEventStack) {
    if (fe.getEventType() == EventType.TEXT_UNIT && !first) {
      return true;
    }
    first = false;
  }
  return false;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Is the current buffered {@link Event} a {@link StartGroup}?
 * 
 * @return true, if current {@link Event} is a {@link StartGroup}
 */
public boolean isCurrentGroup() {
  Event e = peekTempEvent();
  if (e != null && e.getEventType() == EventType.START_GROUP) {
    return true;
  }
  return false;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Is the current buffered {@link Event} a {@link StartSubfilter}?
 * 
 * @return true, if current {@link Event} is a {@link StartSubfilter}
 */
public boolean isCurrentSubfilter() {
  Event e = peekTempEvent();
  if (e != null && e.getEventType() == EventType.START_SUBFILTER) {
    return true;
  }
  return false;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Is the current buffered {@link Event} a {@link TextUnit}?
 * 
 * @return true if TextUnit, false otherwise.
 */
public boolean isCurrentTextUnit() {
  Event e = peekTempEvent();
  if (e != null && e.getEventType() == EventType.TEXT_UNIT) {
    return true;
  }
  return false;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Peek at the most recently created {@link StartSubDocument}
 * 
 * @return the filter event
 */
public StartSubDocument peekMostRecentSubDocument() {
  if (tempFilterEventStack.isEmpty()) {
    return null;
  }
  // the normal stack iterator gives the elements in the wrong order
  int lastIndex = tempFilterEventStack.size() - 1;
  for (int i = lastIndex; i >= 0; i--) {
    Event fe = tempFilterEventStack.get(i);
    if (fe.getEventType() == EventType.START_SUBDOCUMENT) {
      StartSubDocument sd = (StartSubDocument) fe.getResource();
      return sd;
    }
  }
  return null;
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-rtf

public Event next () {
  // Check for cancellation first
  if ( canceled ) {
    queue.clear();
    queue.add(new Event(EventType.CANCELED));
    hasNext = false;
  }
  
  // Parse next if nothing in the queue
  if ( queue.size() == 0 ) {
    parseNext();
  }
  
  // Return the head of the queue
  if ( queue.peek().getEventType() == EventType.END_DOCUMENT ) {
    hasNext = false;
  }
  return queue.poll();
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit

@Override
public Event handleEvent(Event event) {
  switch (event.getEventType()) {
  case START_DOCUMENT:
    return handleStartDocument(event);
  default:
    if (merger != null) {
      return merger.handleEvent(event);
    }
  }
  return event;
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-idml

private boolean isStyledReferenceableEvent(ReferenceableEvent referenceableEvent) {
  switch (referenceableEvent.getEvent().getEventType()) {
    case TEXT_UNIT:
      return true;
    case DOCUMENT_PART:
      return referenceableEvent.getEvent().getDocumentPart().getSkeleton() instanceof StyledTextSkeleton;
    default:
      throw new IllegalStateException(UNEXPECTED_STRUCTURE);
  }
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-idml

private void writeReferenceableEvent(ReferenceableEvent referenceableEvent) {
  switch (referenceableEvent.getEvent().getEventType()) {
    case TEXT_UNIT:
      writeTextUnitReferenceableEvent(referenceableEvent);
      break;
    case DOCUMENT_PART:
      writeDocumentPartReferenceableEvent(referenceableEvent);
    default:
  }
}

代码示例来源:origin: net.sf.okapi.tm/okapi-tm-pensieve

private void indexEvent(LocaleId targetLang, ITmWriter tmWriter, Event event) throws IOException {
  TranslationUnit tu;
  if (event.getEventType() == EventType.TEXT_UNIT) {
    tu = PensieveUtil.convertToTranslationUnit(sourceLang, targetLang, event.getTextUnit());
    tmWriter.indexTranslationUnit(tu);
  }
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Is the current buffered {@link Event} a complex {@link TextUnit}? A complex TextUnit is one which carries along
 * with it it's surrounding formatting or skeleton such <p> text </p> or <title> text </title>
 * 
 * @return true, if current {@link Event} is a complex text unit, false otherwise.
 */
public boolean isCurrentComplexTextUnit() {
  Event e = peekTempEvent();
  if (e != null && e.getEventType() == EventType.TEXT_UNIT && e.getResource().getSkeleton() != null) {
    return true;
  }
  return false;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-translationcomparison

private Event synchronize (IFilter filter,
  EventType untilType)
{
  boolean found = false;
  Event event = null;
  while ( !found && filter.hasNext() ) {
    event = filter.next();
    found = (event.getEventType() == untilType);
  }
    if ( !found ) {
    throw new OkapiException("The document to compare is de-synchronized.");
  }
    return event;
}

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-merge

/**
 * Gets the next text unit in the XLIFF document.
 * 
 * @return the next text unit or null.
 */
private ITextUnit getTextUnitFromXLIFF() {
  Event event;
  while (xlfReader.hasNext()) {
    event = xlfReader.next();
    if (event.getEventType() == EventType.TEXT_UNIT) {
      return event.getTextUnit();
    }
  }
  return null;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Is the current TextUnit of the specified type?
 * 
 * @param type
 *            a {@link TextUnit} type.
 * @return true if the current {@link TextUnit} type is the same as the parameter type.
 */
public boolean isTextUnitWithSameType(String type) {
  Event e = peekTempEvent();
  if (e != null && e.getEventType() == EventType.TEXT_UNIT) {
    ITextUnit tu = e.getTextUnit();
    if (tu != null && tu.getType() != null && tu.getType().equals(type)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Find in our buffered queue the most recent TextUnit
 * that has an assigned name
 * @return - the TextUnit name, null if not found
 */
public String findMostRecentTextUnitName() {	
  if (tempFilterEventStack.isEmpty()) {
    return null;
  }
  // skip current TextUnit - the one we are currently processing
  for (Event fe : tempFilterEventStack) {
    if (fe.getEventType() == EventType.TEXT_UNIT && fe.getTextUnit().getName() != null) {
      return fe.getTextUnit().getName();
    }
  }
  return null;	
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-pensieve

@Override
public Event handleEvent (Event event) {
  switch ( event.getEventType() ) {
  case START_DOCUMENT:
    handleStartDocument(event);
    break;
  case TEXT_UNIT:
    handleTextUnit(event);
    break;
  case END_DOCUMENT:
    close();
    break;
  default:
    break;
  }
  return event;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-wordcount

private IResource createResource(Event event) {
  if (event == null) return null;
  
  IResource res = event.getResource();
  if (res != null) return res;
  
  switch (event.getEventType()) {
  case END_BATCH:
  case END_BATCH_ITEM:
  case END_DOCUMENT:
  case END_SUBDOCUMENT:
  case END_GROUP:
    res = new Ending(gen.createId());
    event.setResource(res);
    break;
  default:
    break;			
  }
  
  return res;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit

@Override
public Event handleEvent (Event event) {
  switch ( event.getEventType() ) {
  case START_BATCH:
    return handleStartBatch(event);
  case END_BATCH:
    return handleEndBatch(event);
  case START_DOCUMENT:
    return handleStartDocument(event);
  case RAW_DOCUMENT:
    return handleRawDocument(event);
  default:
    return writer.handleEvent(event);
  }
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-mosestext

@Override
public Event handleEvent (Event event) {
  switch ( event.getEventType() ) {
  case START_DOCUMENT:
    processStartDocument(event.getStartDocument());
    break;
  case END_DOCUMENT:
    close();
    break;
  case TEXT_UNIT:
    processTextUnit(event.getTextUnit());
    break;
  default:
    break;
  }
  return event;
}

相关文章