/** * Gets the layout information as byte array, assuming that the layout information is stored * as byte array. * @return the layout information or <code>null</code> if not stored in byte array format */ public byte[] getLayoutBytes(){ return layout.getDataByte(); }
/** * Gets the layout information as byte array, assuming that the layout information is stored * as byte array. * @return the layout information or <code>null</code> if not stored in byte array format */ public byte[] getLayoutBytes(){ return layout.getDataByte(); }
if( info.getKind() == DockLayoutInfo.Data.BYTE ){ try{ DataInputStream in = new DataInputStream( new ByteArrayInputStream( info.getDataByte() )); String result = in.readUTF(); in.close();
@SuppressWarnings("unchecked") public void write( PredefinedLayout layout, DataOutputStream out ) throws IOException { Version.write( out, Version.VERSION_1_0_7 ); DockLayoutInfo info = layout.getDelegate(); out.writeUTF( layout.getPredefined() ); if( info.getKind() == DockLayoutInfo.Data.BYTE ){ out.writeBoolean( true ); out.write( info.getDataByte() ); } else if( info.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT ){ out.writeBoolean( true ); DockLayout delegate = info.getDataLayout(); String factoryId = delegate.getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new IOException( "Missing factory: " + factoryId ); out.writeUTF( factoryId ); factory.write( delegate.getData(), out ); } else if( info.getKind() == DockLayoutInfo.Data.NULL ){ out.writeBoolean( false ); } else{ throw new IllegalArgumentException( "Cannot store information as byte[], it is not present as raw byte[] or in an understandable format" ); } }
@SuppressWarnings("unchecked") public void write( PredefinedLayout layout, DataOutputStream out ) throws IOException { Version.write( out, Version.VERSION_1_0_7 ); DockLayoutInfo info = layout.getDelegate(); out.writeUTF( layout.getPredefined() ); if( info.getKind() == DockLayoutInfo.Data.BYTE ){ out.writeBoolean( true ); out.write( info.getDataByte() ); } else if( info.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT ){ out.writeBoolean( true ); DockLayout delegate = info.getDataLayout(); String factoryId = delegate.getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new IOException( "Missing factory: " + factoryId ); out.writeUTF( factoryId ); factory.write( delegate.getData(), out ); } else if( info.getKind() == DockLayoutInfo.Data.NULL ){ out.writeBoolean( false ); } else{ throw new IllegalArgumentException( "Cannot store information as byte[], it is not present as raw byte[] or in an understandable format" ); } }
/** * Updates the contents of the internal {@link DockLayoutInfo} using <code>factory</code> to read * a byte array or an {@link XElement}. * @param factory the factory used to read the layout * @param placeholders the placeholders that may be used */ public void updateLayout( DockFactory<?, ?, Object> factory, PlaceholderStrategy placeholders ){ try{ Object data = null; switch( layout.getKind() ){ case BYTE: data = factory.read( new DataInputStream( new ByteArrayInputStream( layout.getDataByte() ) ), placeholders ); break; case XML: data = factory.read( layout.getDataXML(), placeholders ); break; } if( data != null ){ layout.setData( new DockLayout<Object>( factory.getID(), data ) ); } } catch( IOException e ){ // since a ByteArrayInputStream never throws an IOException this should never happen throw new IllegalStateException( e ); } }
/** * Updates the contents of the internal {@link DockLayoutInfo} using <code>factory</code> to read * a byte array or an {@link XElement}. * @param factory the factory used to read the layout * @param placeholders the placeholders that may be used */ public void updateLayout( DockFactory<?, ?, Object> factory, PlaceholderStrategy placeholders ){ try{ Object data = null; switch( layout.getKind() ){ case BYTE: data = factory.read( new DataInputStream( new ByteArrayInputStream( layout.getDataByte() ) ), placeholders ); break; case XML: data = factory.read( layout.getDataXML(), placeholders ); break; } if( data != null ){ layout.setData( new DockLayout<Object>( factory.getID(), data ) ); } } catch( IOException e ){ // since a ByteArrayInputStream never throws an IOException this should never happen throw new IllegalStateException( e ); } }
out.write( info.getDataByte() );
byte[] bytes = layout.getDelegate().getDataByte();
byte[] bytes = layout.getDelegate().getDataByte();
info = readEntry( info.getDataByte(), info.getPlaceholder() ); if( info != null && info.getKind() == DockLayoutInfo.Data.BYTE ){ info = original;