gpt4 book ai didi

org.apache.poi.xwpf.converter.core.openxmlformats.ZipArchive类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:32:17 28 4
gpt4 key购买 nike

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

ZipArchive介绍

[英]ZipArchive is used to load zipped XML document archive (docx, odt...) ZipArchive cache each entry zip to transform content stream with IXDocPreprocessor and ITemplateEngine.
[中]ZipArchive用于加载压缩的XML文档存档(docx、odt…)ZipArchive缓存每个条目压缩,以使用IXDocPreprocessor和ITemplateEngine转换内容流。

代码示例

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

/**
 * Create a copy of the {@link ZipArchive}.
 * 
 * @return
 */
public ZipArchive createCopy()
{
  // Create new instance of XDocArchive
  ZipArchive archiveCopy = new ZipArchive();
  // Loop for cache entries
  for ( Map.Entry<String, byte[]> entry : cacheEntries.entrySet() )
  {
    String name = entry.getKey();
    byte[] entryData = entry.getValue();
    byte[] entryDataCopy = new byte[entryData.length];
    System.arraycopy( entryData, 0, entryDataCopy, 0, entryData.length );
    // modify the cache entries in the new XDocArchive
    archiveCopy.cacheEntries.put( name, entryDataCopy );
  }
  return archiveCopy;
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

public Set<String> getEntryNames( final String wildcard )
{
  if ( cacheEntriesWilcard == null )
  {
    cacheEntriesWilcard = new HashMap<String, Set<String>>();
  }
  Set<String> entryNamesWithWildcard = cacheEntriesWilcard.get( wildcard );
  if ( entryNamesWithWildcard != null )
  {
    return entryNamesWithWildcard;
  }
  String regexp = wildcardToRegex( wildcard );
  entryNamesWithWildcard = new HashSet<String>();
  Set<String> entryNames = getEntryNames();
  for ( String entryName : entryNames )
  {
    if ( entryName.matches( regexp ) )
    {
      entryNamesWithWildcard.add( entryName );
    }
  }
  cacheEntriesWilcard.put( wildcard, entryNamesWithWildcard );
  return entryNamesWithWildcard;
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

/**
 * Write the given entry from the document archive in the given output stream.
 * 
 * @param archive
 * @param outputStream
 * @throws IOException
 */
public static void writeEntry( ZipArchive archive, String entryName, OutputStream outputStream )
  throws IOException
{
  if ( !archive.hasEntry( entryName ) )
  {
    throw new IOException( "Cannot find entry name=" + entryName + " in the document archive." );
  }
  outputStream.write( archive.cacheEntries.get( entryName ) );
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

/**
 * Write XML document archive in the given output stream.
 * 
 * @param archive
 * @param outputStream
 * @throws IOException
 */
public static void writeZip( ZipArchive archive, OutputStream outputStream )
  throws IOException
{
  ZipOutputStream zipOutputStream = new ZipOutputStream( outputStream );
  Set<String> entryNames = archive.getEntryNames();
  // ODT spec requires 'mimetype' to be the first entry
  // writeZipEntry( zipOutputStream, archive, MIMETYPE_ENTRY_NAME, ZipEntry.STORED );
  for ( String entryName : entryNames )
  {
    if ( !MIMETYPE_ENTRY_NAME.equals( entryName ) )
    {
      writeZipEntry( zipOutputStream, archive, entryName, ZipEntry.DEFLATED );
    }
  }
  zipOutputStream.close();
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

archive = new ZipArchive( true );
setEntry( archive, zipEntry.getName(), zipInputStream );
zipInputStream.closeEntry();

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

public long getLastModifiedEntry( String entryName )
{
  if ( isTrackLastModified() )
  {
    Long lastModified = lastModifiedEntries.get( entryName );
    if ( lastModified != null )
    {
      return lastModified;
    }
  }
  return 0;
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

/**
 * Set the given input stream in the given entry of the document archive.
 * 
 * @param archive
 * @param inputStream
 * @throws IOException
 */
public static void setEntry( ZipArchive archive, String entryName, InputStream input )
  throws IOException
{
  // entry name must uses '/' (see https://code.google.com/p/xdocreport/issues/detail?id=234)
  if ( entryName.indexOf( "\\" ) != -1 )
  {
    entryName = StringUtils.replaceAll( entryName, "\\", "/" );
  }
  // 1) Create empty output stream and register it with the entry
  // name
  OutputStream output = archive.getEntryOutputStream( entryName );
  // 2) Copy original stream form the input stream to the empty output stream
  IOUtils.copy( input, output );
  output.close();
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

throws IOException
InputStream entryInputStream = archive.getEntryInputStream( entryName );
if ( entryInputStream == null )

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

/**
 * Write XML document archive in the given output stream.
 * 
 * @param archive
 * @param outputStream
 * @throws IOException
 */
public static void writeZip( ZipArchive archive, OutputStream outputStream )
  throws IOException
{
  ZipOutputStream zipOutputStream = new ZipOutputStream( outputStream );
  Set<String> entryNames = archive.getEntryNames();
  // ODT spec requires 'mimetype' to be the first entry
  // writeZipEntry( zipOutputStream, archive, MIMETYPE_ENTRY_NAME, ZipEntry.STORED );
  for ( String entryName : entryNames )
  {
    if ( !MIMETYPE_ENTRY_NAME.equals( entryName ) )
    {
      writeZipEntry( zipOutputStream, archive, entryName, ZipEntry.DEFLATED );
    }
  }
  zipOutputStream.close();
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

archive = new ZipArchive( true );
setEntry( archive, zipEntry.getName(), zipInputStream );
zipInputStream.closeEntry();

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

public long getLastModifiedEntry( String entryName )
{
  if ( isTrackLastModified() )
  {
    Long lastModified = lastModifiedEntries.get( entryName );
    if ( lastModified != null )
    {
      return lastModified;
    }
  }
  return 0;
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

/**
 * Set the given input stream in the given entry of the document archive.
 * 
 * @param archive
 * @param inputStream
 * @throws IOException
 */
public static void setEntry( ZipArchive archive, String entryName, InputStream input )
  throws IOException
{
  // entry name must uses '/' (see https://code.google.com/p/xdocreport/issues/detail?id=234)
  if ( entryName.indexOf( "\\" ) != -1 )
  {
    entryName = StringUtils.replaceAll( entryName, "\\", "/" );
  }
  // 1) Create empty output stream and register it with the entry
  // name
  OutputStream output = archive.getEntryOutputStream( entryName );
  // 2) Copy original stream form the input stream to the empty output stream
  IOUtils.copy( input, output );
  output.close();
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

throws IOException
InputStream entryInputStream = archive.getEntryInputStream( entryName );
if ( entryInputStream == null )

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

public Set<String> getEntryNames( final String wildcard )
{
  if ( cacheEntriesWilcard == null )
  {
    cacheEntriesWilcard = new HashMap<String, Set<String>>();
  }
  Set<String> entryNamesWithWildcard = cacheEntriesWilcard.get( wildcard );
  if ( entryNamesWithWildcard != null )
  {
    return entryNamesWithWildcard;
  }
  String regexp = wildcardToRegex( wildcard );
  entryNamesWithWildcard = new HashSet<String>();
  Set<String> entryNames = getEntryNames();
  for ( String entryName : entryNames )
  {
    if ( entryName.matches( regexp ) )
    {
      entryNamesWithWildcard.add( entryName );
    }
  }
  cacheEntriesWilcard.put( wildcard, entryNamesWithWildcard );
  return entryNamesWithWildcard;
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core

/**
 * Write the given entry from the document archive in the given output stream.
 * 
 * @param archive
 * @param outputStream
 * @throws IOException
 */
public static void writeEntry( ZipArchive archive, String entryName, OutputStream outputStream )
  throws IOException
{
  if ( !archive.hasEntry( entryName ) )
  {
    throw new IOException( "Cannot find entry name=" + entryName + " in the document archive." );
  }
  outputStream.write( archive.cacheEntries.get( entryName ) );
}

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

/**
 * Create a copy of the {@link ZipArchive}.
 * 
 * @return
 */
public ZipArchive createCopy()
{
  // Create new instance of XDocArchive
  ZipArchive archiveCopy = new ZipArchive();
  // Loop for cache entries
  for ( Map.Entry<String, byte[]> entry : cacheEntries.entrySet() )
  {
    String name = entry.getKey();
    byte[] entryData = entry.getValue();
    byte[] entryDataCopy = new byte[entryData.length];
    System.arraycopy( entryData, 0, entryDataCopy, 0, entryData.length );
    // modify the cache entries in the new XDocArchive
    archiveCopy.cacheEntries.put( name, entryDataCopy );
  }
  return archiveCopy;
}

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