gpt4 book ai didi

net.sf.okapi.common.skeleton.ZipSkeleton类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 18:29:31 36 4
gpt4 key购买 nike

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

ZipSkeleton介绍

[英]Extension of the GenericSkeleton skeleton implementation that allow ZipFile and ZipEntry objects to be passed along with skeleton parts.
[中]GenericSkleton骨架实现的扩展,允许ZipFile和ZipEntry对象与骨架部件一起传递。

代码示例

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

@Override
  public ZipSkeleton clone() {
    ZipSkeleton newSkel = new ZipSkeleton(original, entry);
    newSkel.setModifiedContents(modifiedContents);
    super.copyFields(newSkel);
    return newSkel;
  }
}

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

zipOutputStream.putNextEntry(new ZipEntry(skeleton.getEntry().getName()));
String modifiedContents = skeleton.getModifiedContents();
  InputStream input = zipOriginal.getInputStream(skeleton.getEntry());
  int len;
  while ((len = input.read(buffer)) > 0) {

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

if ( res.getSkeleton() instanceof ZipSkeleton ) {
  ZipSkeleton skel = (ZipSkeleton)res.getSkeleton();
  ZipFile original = skel.getOriginal();
  if (original == null)
    original = zipOriginal;
  ZipEntry entry = skel.getEntry();

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

protected Event createStartSubDocumentEvent() {
  StartSubDocument sd = new StartSubDocument(parentId, id);
  sd.setName(zipEntry.getName());
  sd.setMimeType(MIME_TYPE);
  ZipSkeleton zs = new ZipSkeleton(zipFile, zipEntry);
  sd.setSkeleton(zs);
  sd.setFilterParameters(parameters);
  return new Event(EventType.START_SUBDOCUMENT, sd);
}

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

protected void processStartSubDocument (StartSubDocument res) {
  ZipSkeleton skel = (ZipSkeleton)res.getSkeleton();
  ZipEntry entry = skel.getEntry();
  if (entry != null)
    entryName = entry.getName();
  // Set the temporary path and create it
  try {
    tempFile = File.createTempFile("~okapi-9_", null);
  }
  catch ( IOException e ) {
    throw new OkapiException(e);
  }
  
  // Instantiate the filter writer for that entry if not set from outside with setSubDocWriter()
  if (subDocWriter == null) {
    subDocWriter = createSubDocumentFilterWriter(res);
  }            
  subDocWriter.setOutput(tempFile.getAbsolutePath());
      
  StartDocument sd = convertToStartDocument(res);
  subDocWriter.handleEvent(new Event(EventType.START_DOCUMENT, sd));
}

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

ZipFile zipFile = ((ZipSkeleton) res.getSkeleton()).getOriginal();
zipOriginal = new ZipFile(new File(zipFile.getName()), ZipFile.OPEN_READ);

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

public ZipSkeleton (GenericSkeleton skel, ZipFile original, ZipEntry entry) {
  this(original, entry);
  add(skel);		
}

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

private Event nextInZipFile () {
  while( entries.hasMoreElements() ) {
    entry = entries.nextElement();
    subFilter = getSubFilter(entry.getName());
    if (subFilter != null) {	
      subDocWriter = subFilter.createFilterWriter();
      ((ZipFilterWriter) createFilterWriter()).setSubDocWriter(subDocWriter);
      return openSubDocument();
    }
    else {
      DocumentPart dp = new DocumentPart(entry.getName(), false);
      ZipSkeleton skel = new ZipSkeleton(zipFile, entry);
      return new Event(EventType.DOCUMENT_PART, dp, skel);
    }
  }
  // No more sub-documents: end of the ZIP document
  close();
  Ending ending = new Ending(EID);
  return new Event(EventType.END_DOCUMENT, ending);
}

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

private void processStartSubDocument(StartSubDocument res) {
  ndxSubDoc++;
  // Set the temporary path and create it
  try {
    tempFile = File.createTempFile("~okapi-22_idmlTmp" + ndxSubDoc + "_", null);
  } catch (IOException e) {
    throw new OkapiIOException("Error opening temporary zip output file.");
  }
  subDocEntry = ((ZipSkeleton) res.getSkeleton()).getEntry();
  subDocWriter = new SubDocumentWriter(
      parameters, outputFactory, StandardCharsets.UTF_8, tempFile.getAbsolutePath(),
      new ReferenceableEventsWriter(
        new ReferenceableEventsMerger(eventFactory, targetLocale),
        new StyleRangeEventsGenerator(eventFactory)
      )
  );
  StartDocument sd = new StartDocument("sd");
  sd.setLineBreak("\n");
  sd.setSkeleton(res.getSkeleton());
  sd.setLocale(sourceLocale);
  subDocWriter.handleEvent(new Event(EventType.START_DOCUMENT, sd));
  SubDocumentValues subDocumentValues = new SubDocumentValues(subDocEntry, subDocWriter, tempFile);
  tmSubDoc.put(ndxSubDoc, subDocumentValues);
}

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

zipOriginal = skel.getOriginal();

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

private Event getStartDocumentEvent(URI uri, LocaleId sourceLocale, IFilterWriter filterWriter) {
  StartDocument startDoc = new StartDocument(startDocumentId);
  startDoc.setName(uri.getPath());
  startDoc.setLocale(sourceLocale);
  startDoc.setMimeType(MIME_TYPE);
  startDoc.setFilterWriter(filterWriter);
  startDoc.setFilterParameters(parameters);
  startDoc.setLineBreak("\n");
  startDoc.setEncoding(encoding, false);  // IDML files don't have UTF8BOM
  ZipSkeleton skel = new ZipSkeleton(zipFile, null);
  return new Event(EventType.START_DOCUMENT, startDoc, skel);
}

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

@Override
public Event open() throws IOException, XMLStreamException {
  DocumentPart documentPart = new DocumentPart(zipEntry.getName(), false);
  ZipSkeleton skeleton = new ZipSkeleton(zipFile, zipEntry);
  skeleton.setModifiedContents(getModifiedContent());
  return new Event(EventType.DOCUMENT_PART, documentPart, skeleton);
}

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

zipOut.putNextEntry(new ZipEntry(skeleton.getEntry().getName()));
String modifiedContents = skeleton.getModifiedContents();
  InputStream input = zipOriginal.getInputStream(skeleton.getEntry());
  int len;
  while ( (len = input.read(buffer)) > 0 ) {

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

ConditionalParameters conditionalParameters = (ConditionalParameters) res.getFilterParameters();
if (skel instanceof ZipSkeleton) {
  subDocEntry = ((ZipSkeleton) res.getSkeleton()).getEntry();
  String contentType = getContentTypeForPart(subDocEntry);
  if (docType.isStyledTextPart(subDocEntry.getName(), contentType)) {

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

sourceLocale = res.getLocale();
ZipSkeleton skel = (ZipSkeleton)res.getSkeleton();
ZipFile zipTemp = skel.getOriginal(); // if OpenXML filter was closed, this ZipFile has been marked for close
File fZip = new File(zipTemp.getName()); // so get its name
zipOriginal = new OpenXMLZipFile(new ZipFile(fZip,ZipFile.OPEN_READ),

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

protected Event createStartSubDocumentEvent(String documentId, String subDocumentId) {
  StartSubDocument sd = new StartSubDocument(documentId, subDocumentId);
  sd.setName(partName);
  if (zipFile != null) { // XXX This null check is a hack for testing
    ZipSkeleton zs = new ZipSkeleton(zipFile.getZip(), entry);
    sd.setSkeleton(zs);
  }
  ConditionalParameters clonedParams = params.clone();
  sd.setFilterParameters(clonedParams);
  return new Event(EventType.START_SUBDOCUMENT, sd);
}

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

@Override
public Event open(String documentId, String subDocumentId, LocaleId srcLang) throws IOException, XMLStreamException {
  DocumentPart dp = new DocumentPart(entry.getName(), false);
  ZipSkeleton skel = new ZipSkeleton(zipFile.getZip(), entry);
  skel.setModifiedContents(getModifiedContent());
  return new Event(EventType.DOCUMENT_PART, dp, skel);
}

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

private Event openSubDocument () {
  if (subFilter != null) subFilter.close();
  Event event;
  try {
    subFilter.open(new RawDocument(zipFile.getInputStream(entry), "UTF-8", srcLoc, trgLoc));
    event = subFilter.next(); // START_DOCUMENT
  }
  catch (IOException e) {
    throw new OkapiIOException("Error opening internal file.", e);
  }
  
  // Change the START_DOCUMENT event from sub-filter to START_SUBDOCUMENT
  StartDocument sd = null;
  StartSubDocument ssd = null;
  if (event.getEventType() == EventType.START_DOCUMENT) {
    sd = (StartDocument) event.getResource();
    ssd = new StartSubDocument(SID, sd.getId());			
    saveStartDoc = sd; // Remember the SD transformed to SSD not to loose isMultilingual
  }
  else
    ssd = new StartSubDocument(SID, String.valueOf(++subDocId));
  
  ResourceUtil.copyProperties(sd, ssd);
  ssd.setName(docURI.getPath() + "/" + entry.getName()); // Use '/'
  nextAction = NextAction.NEXTINSUBDOC;
  ZipSkeleton skel = new ZipSkeleton(
    (GenericSkeleton)event.getResource().getSkeleton(), zipFile, entry);
  return new Event(EventType.START_SUBDOCUMENT, ssd, skel);
}

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

/**
 * Open the nested {@link OpenXMLContentFilter} instance on the specified InputStream,
 * and convert a START_SUBDOCUMENT event for it.
 * @param is input stream
 * @param documentId document identifier
 * @param subDocumentId sub-document identifier
 * @param srcLang the source language
 * @return the START_SUBDOCUMENT Event
 */
protected Event openContentFilter(InputStream is, String documentId, String subDocumentId, LocaleId srcLang) {
  contentFilter.open(new RawDocument(is, StandardCharsets.UTF_8.name(), srcLang));
  Event startDocEvent = contentFilter.next();
  // Change the START_DOCUMENT event to START_SUBDOCUMENT
  StartSubDocument sd = new StartSubDocument(documentId, subDocumentId);
  sd.setName(entry.getName());
  ConditionalParameters clonedParams = params.clone();
  clonedParams.nFileType = contentFilter.getParseType();
  sd.setFilterParameters(clonedParams);
  ZipSkeleton skel = new ZipSkeleton((GenericSkeleton)startDocEvent.getStartDocument().getSkeleton(),
                    zipFile.getZip(), entry);
  return new Event(EventType.START_SUBDOCUMENT, sd, skel);
}

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

startDoc.setEncoding(encoding, false);  // Office 2007 files don't have UTF8BOM
startDoc.setFilterParameters(cparams);
ZipSkeleton skel = new ZipSkeleton(zipFile.getZip(), null);
return new Event(EventType.START_DOCUMENT, startDoc, skel);

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com