public int write(final Protein protein,final boolean standalone) throws IOException {
  checkEntryHierarchy();
  if (entryHierarchy != null) {
    for (    ProteinXref xref : protein.getCrossReferences()) {
      final SimpleProtein simpleProtein=SimpleProtein.valueOf(protein,xref,entryHierarchy);
      if (simpleProtein != null) {
        final SimpleHash model=buildModelMap(simpleProtein,entryHierarchy,standalone);
        Writer writer=null;
        try {
          final Template temp=freeMarkerConfig.getTemplate(freeMarkerTemplate);
          checkTempDirectory(tempDirectory);
          if (!tempDirectory.endsWith(File.separator)) {
            tempDirectory=tempDirectory + File.separator;
          }
          UrlFriendlyIdGenerator gen=UrlFriendlyIdGenerator.getInstance();
          String urlFriendlyId=gen.generate(xref.getIdentifier());
          final Path newResultFile=Paths.get(tempDirectory + urlFriendlyId + ".html");
          resultFiles.add(newResultFile);
          writer=Files.newBufferedWriter(newResultFile,characterSet);
          temp.process(model,writer);
          writer.flush();
        }
 catch (        TemplateException e) {
          e.printStackTrace();
        }
catch (        IOException e) {
          e.printStackTrace();
        }
 finally {
          if (writer != null) {
            writer.close();
          }
        }
      }
    }
  }
  return 0;
}

public int write ( final Protein protein , final boolean standalone ) throws IOException { checkEntryHierarchy ( ) ; if ( entryHierarchy != null ) { for ( ProteinXref xref : protein . getCrossReferences ( ) ) { final SimpleProtein simpleProtein = SimpleProtein . valueOf ( protein , xref , entryHierarchy ) ; if ( simpleProtein != null ) { final SimpleHash model = buildModelMap ( simpleProtein , entryHierarchy , standalone ) ; Writer writer = null ; try { final Template temp = freeMarkerConfig . getTemplate ( freeMarkerTemplate ) ; checkTempDirectory ( tempDirectory ) ; if ( ! tempDirectory . endsWith ( File . separator ) ) { tempDirectory = tempDirectory + File . separator ; } UrlFriendlyIdGenerator gen = UrlFriendlyIdGenerator . getInstance ( ) ; String urlFriendlyId = gen . generate ( xref . getIdentifier ( ) ) ; final Path newResultFile = Paths . get ( tempDirectory + urlFriendlyId + ".html" ) ; resultFiles . add ( newResultFile ) ; writer = Files . newBufferedWriter ( newResultFile , characterSet ) ; temp . process ( model , writer ) ; writer . flush ( ) ; } catch ( TemplateException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { if ( writer != null ) { writer . close ( ) ; } } } } } return 0 ; }
writes out protein view to an zipped and compressed html file .
