text
stringlengths
30
1.67M
<s> package org . sqlproc . sample . catalog . db ; import java . io . IOException ; import java . io . InputStream ; import java . sql . Connection ; import java . sql . Statement ; import java . util . Properties ; import org . springframework . beans . BeansException ; import org . springframework . beans . factory . InitializingBean ; import org . springframework . context . ApplicationContext ; import org . springframework . context . ApplicationContextAware ; import org . springframework . core . io . DefaultResourceLoader ; import org . springframework . core . io . Resource ; import org . springframework . core . io . ResourceLoader ; import org . springframework . jdbc . core . JdbcTemplate ; import org . sqlproc . sample . catalog . model . Item ; import org . sqlproc . sample . catalog . service . ItemService ; public final class TestDataInitializer implements InitializingBean , ApplicationContextAware { private JdbcTemplate jdbcTemplate ; private ItemService itemService ; private boolean initData ; private Properties catalog ; private ApplicationContext context ; public TestDataInitializer ( ) { } public void afterPropertiesSet ( ) throws Exception { if ( initData ) { Connection connection = null ; Statement stmt = null ; try { connection = jdbcTemplate . getDataSource ( ) . getConnection ( ) ; stmt = connection . createStatement ( ) ; for ( int i = <NUM_LIT:1> ; i <= <NUM_LIT> ; i ++ ) { String ddl = catalog . getProperty ( "<STR_LIT:s>" + i ) ; if ( ddl == null ) continue ; System . out . println ( ddl ) ; stmt . addBatch ( ddl ) ; } stmt . executeBatch ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } finally { if ( connection != null ) connection . close ( ) ; } try { DefaultResourceLoader loader = new DefaultResourceLoader ( ) ; Item item ; item = new Item ( <NUM_LIT:1> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:2> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:3> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:4> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:5> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:6> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:7> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:8> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:9> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:10> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:11> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:12> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:15> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:16> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:20> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT:24> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; item = new Item ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ; loadImages ( item , loader ) ; itemService . create ( item ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } private void loadImages ( Item item , ResourceLoader loader ) { try { if ( item . getImageurl ( ) != null ) { Resource res = loader . getResource ( "<STR_LIT>" + item . getImageurl ( ) ) ; if ( res . exists ( ) && res . isReadable ( ) ) { item . setImage ( copy ( res . getInputStream ( ) , <NUM_LIT> ) ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } try { if ( item . getImagethumburl ( ) != null ) { Resource res = loader . getResource ( "<STR_LIT>" + item . getImagethumburl ( ) ) ; if ( res . exists ( ) && res . isReadable ( ) ) { item . setImagethumb ( copy ( res . getInputStream ( ) , <NUM_LIT> ) ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } } private byte [ ] copy ( InputStream ins , int bufSize ) throws IOException { byte [ ] result = new byte [ <NUM_LIT:0> ] ; final byte [ ] buffer = new byte [ bufSize ] ; int bytesCopied = <NUM_LIT:0> ; while ( true ) { int byteCount = ins . read ( buffer , <NUM_LIT:0> , buffer . length ) ; if ( byteCount <= <NUM_LIT:0> ) { break ; } byte [ ] result2 = new byte [ result . length + byteCount ] ; System . arraycopy ( result , <NUM_LIT:0> , result2 , <NUM_LIT:0> , result . length ) ; System . arraycopy ( buffer , <NUM_LIT:0> , result2 , result . length , byteCount ) ; result = result2 ; } return result ; } public void setJdbcTemplate ( JdbcTemplate jdbcTemplate ) { this . jdbcTemplate = jdbcTemplate ; } public void setItemService ( ItemService itemService ) { this . itemService = itemService ; } public void setInitData ( boolean initData ) { this . initData = initData ; } public void setCatalog ( Properties catalog ) { this . catalog = catalog ; } public void setApplicationContext ( ApplicationContext applicationContext ) throws BeansException { this . context = applicationContext ; } } </s>
<s> package org . sqlproc . sample . catalog . service ; import java . util . List ; import org . springframework . beans . factory . annotation . Autowired ; import org . springframework . transaction . annotation . Transactional ; import org . sqlproc . sample . catalog . dao . ItemDao ; import org . sqlproc . sample . catalog . form . ItemForm ; import org . sqlproc . sample . catalog . model . Item ; import org . sqlproc . sample . catalog . to . ItemTO ; public class ItemService { @ Autowired private ItemDao itemDao ; @ Transactional ( readOnly = true ) public Item findById ( Long itemId ) { return ( Item ) itemDao . findById ( itemId ) ; } @ Transactional public Long create ( Item item ) { return itemDao . create ( item ) . getItemid ( ) ; } @ Transactional public Long update ( Item item ) { return itemDao . update ( item ) . getItemid ( ) ; } @ Transactional public void delete ( Long itemId ) { itemDao . delete ( itemId ) ; } @ Transactional ( readOnly = true ) public List < ItemTO > find ( ItemForm criteria ) { return itemDao . find ( criteria ) ; } @ Transactional ( readOnly = true ) public int findCount ( ItemForm criteria ) { return itemDao . findCount ( criteria ) ; } } </s>
<s> package org . sqlproc . sample . catalog . to ; import java . io . Serializable ; import java . math . BigDecimal ; public class ItemTO implements Serializable { private Long itemid ; private String productid ; private String name ; private String description ; private String imageurl ; private String imagethumburl ; private byte [ ] image ; private byte [ ] imagethumb ; private BigDecimal price ; public ItemTO ( ) { } public Long getItemid ( ) { return itemid ; } public void setItemid ( Long itemid ) { this . itemid = itemid ; } public String getProductid ( ) { return productid ; } public void setProductid ( String productid ) { this . productid = productid ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } public String getDescription ( ) { return description ; } public void setDescription ( String description ) { this . description = description ; } public String getImageurl ( ) { return imageurl ; } public void setImageurl ( String imageurl ) { this . imageurl = imageurl ; } public String getImagethumburl ( ) { return imagethumburl ; } public void setImagethumburl ( String imagethumburl ) { this . imagethumburl = imagethumburl ; } public byte [ ] getImage ( ) { return image ; } public void setImage ( byte [ ] image ) { this . image = image ; } public byte [ ] getImagethumb ( ) { return imagethumb ; } public void setImagethumb ( byte [ ] imagethumb ) { this . imagethumb = imagethumb ; } public BigDecimal getPrice ( ) { return price ; } public void setPrice ( BigDecimal price ) { this . price = price ; } @ Override public String toString ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( name ) ; return sb . toString ( ) ; } } </s>
<s> package org . sqlproc . sample . catalog . dao ; import java . util . List ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import org . springframework . cache . annotation . CacheEvict ; import org . springframework . cache . annotation . Cacheable ; import org . springframework . jdbc . core . JdbcTemplate ; import org . sqlproc . engine . SqlCrudEngine ; import org . sqlproc . engine . SqlEngineFactory ; import org . sqlproc . engine . SqlOrder ; import org . sqlproc . engine . SqlQueryEngine ; import org . sqlproc . engine . SqlSession ; import org . sqlproc . engine . spring . SpringSimpleSession ; import org . sqlproc . sample . catalog . form . ItemForm ; import org . sqlproc . sample . catalog . model . Item ; import org . sqlproc . sample . catalog . to . ItemTO ; public class ItemDao { protected final Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; protected JdbcTemplate jdbcTemplate ; protected SqlEngineFactory sqlFactory ; private SqlSession getSqlSession ( ) { SqlSession session = new SpringSimpleSession ( jdbcTemplate ) ; return session ; } @ Cacheable ( value = "<STR_LIT>" , key = "<STR_LIT>" ) public Item findById ( Long id ) { SqlSession session = getSqlSession ( ) ; Item item = getCrudEngine ( "<STR_LIT>" ) . get ( session , Item . class , new Item ( id ) ) ; logger . info ( "<STR_LIT>" + item . toDebugString ( ) ) ; return item ; } @ CacheEvict ( value = "<STR_LIT>" , key = "<STR_LIT>" ) public Item create ( Item item ) { SqlSession session = getSqlSession ( ) ; logger . info ( "<STR_LIT>" + item . toDebugString ( ) ) ; getCrudEngine ( "<STR_LIT>" ) . insert ( session , item ) ; logger . info ( "<STR_LIT>" + item . toDebugString ( ) ) ; return item ; } @ CacheEvict ( value = "<STR_LIT>" , key = "<STR_LIT>" ) public Item update ( Item item ) { SqlSession session = getSqlSession ( ) ; logger . info ( "<STR_LIT>" + item . toDebugString ( ) ) ; getCrudEngine ( "<STR_LIT>" ) . update ( session , item ) ; logger . info ( "<STR_LIT>" + item . toDebugString ( ) ) ; return item ; } @ CacheEvict ( value = "<STR_LIT>" , key = "<STR_LIT>" ) public void delete ( Long id ) { SqlSession session = getSqlSession ( ) ; logger . info ( "<STR_LIT>" + id ) ; getCrudEngine ( "<STR_LIT>" ) . delete ( session , new Item ( id ) ) ; } public List < ItemTO > find ( ItemForm criteria ) { SqlSession session = getSqlSession ( ) ; logger . info ( "<STR_LIT>" + criteria ) ; return getQueryEngine ( "<STR_LIT>" ) . query ( session , ItemTO . class , criteria , null , SqlOrder . getOrder ( criteria . getOrder ( ) ) , <NUM_LIT:0> , criteria . getCount ( ) , criteria . getFirst ( ) ) ; } public int findCount ( ItemForm criteria ) { SqlSession session = getSqlSession ( ) ; logger . info ( "<STR_LIT>" + criteria ) ; return getQueryEngine ( "<STR_LIT>" ) . queryCount ( session , criteria ) ; } public SqlCrudEngine getCrudEngine ( String name ) { SqlCrudEngine queryEngine = sqlFactory . getCrudEngine ( name ) ; if ( queryEngine == null ) throw new RuntimeException ( "<STR_LIT>" + name ) ; return queryEngine ; } public SqlQueryEngine getQueryEngine ( String name ) { SqlQueryEngine queryEngine = sqlFactory . getQueryEngine ( name ) ; if ( queryEngine == null ) throw new RuntimeException ( "<STR_LIT>" + name ) ; return queryEngine ; } public void setJdbcTemplate ( JdbcTemplate jdbcTemplate ) { this . jdbcTemplate = jdbcTemplate ; } public void setSqlFactory ( SqlEngineFactory sqlFactory ) { this . sqlFactory = sqlFactory ; } } </s>
<s> package org . sqlproc . sample . catalog . model ; import java . io . Serializable ; import java . math . BigDecimal ; import java . math . BigInteger ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Item implements Serializable { private Long itemid ; private String productid ; private String name ; private String description ; private String imageurl ; private String imagethumburl ; private byte [ ] image ; private byte [ ] imagethumb ; private BigDecimal price ; public Item ( ) { } public Item ( Long itemid ) { this . itemid = itemid ; } public Item ( Long itemid , String productid , String name , String description , String imageurl , String imagethumburl , BigDecimal price ) { this . itemid = itemid ; this . productid = productid ; this . name = name ; this . description = description ; this . imageurl = imageurl ; this . imagethumburl = imagethumburl ; this . price = price ; } public Item ( int itemid , String productid , String name , String description , String imageurl , String imagethumburl , double price ) { this . itemid = new Long ( itemid ) ; this . productid = productid ; this . name = name ; this . description = description ; this . imageurl = imageurl ; this . imagethumburl = imagethumburl ; this . price = new BigDecimal ( price ) ; } public Long getItemid ( ) { return itemid ; } public void setItemid ( Long itemid ) { this . itemid = itemid ; } public void setItemid ( BigInteger itemid ) { if ( itemid != null ) this . itemid = itemid . longValue ( ) ; else this . itemid = null ; } public String getProductid ( ) { return productid ; } public void setProductid ( String productid ) { this . productid = productid ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } public String getDescription ( ) { return description ; } public void setDescription ( String description ) { this . description = description ; } public String getImageurl ( ) { return imageurl ; } public void setImageurl ( String imageurl ) { this . imageurl = imageurl ; } public String getImagethumburl ( ) { return imagethumburl ; } public void setImagethumburl ( String imagethumburl ) { this . imagethumburl = imagethumburl ; } public byte [ ] getImage ( ) { return image ; } public void setImage ( byte [ ] image ) { this . image = image ; } public byte [ ] getImagethumb ( ) { return imagethumb ; } public void setImagethumb ( byte [ ] imagethumb ) { this . imagethumb = imagethumb ; } public BigDecimal getPrice ( ) { return price ; } public void setPrice ( BigDecimal price ) { this . price = price ; } @ Override public int hashCode ( ) { int hash = <NUM_LIT:0> ; hash += ( itemid != null ? itemid . hashCode ( ) : <NUM_LIT:0> ) ; return hash ; } @ Override public boolean equals ( Object object ) { if ( ! ( object instanceof Item ) ) { return false ; } Item other = ( Item ) object ; if ( ( this . itemid == null && other . itemid != null ) || ( this . itemid != null && ! this . itemid . equals ( other . itemid ) ) ) { return false ; } return true ; } public String toDebugString ( ) { return "<STR_LIT>" + itemid + "<STR_LIT>" + productid + "<STR_LIT>" + name + "<STR_LIT>" + description + "<STR_LIT>" + imageurl + "<STR_LIT>" + imagethumburl + "<STR_LIT>" + image + "<STR_LIT>" + imagethumb + "<STR_LIT>" + price + "<STR_LIT:]>" ; } @ Override public String toString ( ) { return name ; } } </s>
<s> package org . sqlproc . sample . catalog . form ; import java . io . Serializable ; import java . math . BigDecimal ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class ItemForm implements Serializable { private Long itemid ; private String name ; private String description ; private BigDecimal priceFrom ; private BigDecimal priceTo ; public ItemForm ( ) { } public Long getItemid ( ) { return itemid ; } public void setItemid ( Long itemid ) { this . itemid = itemid ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } public String getDescription ( ) { return description ; } public void setDescription ( String description ) { this . description = description ; } public BigDecimal getPriceFrom ( ) { return priceFrom ; } public void setPriceFrom ( BigDecimal priceFrom ) { this . priceFrom = priceFrom ; } public BigDecimal getPriceTo ( ) { return priceTo ; } public void setPriceTo ( BigDecimal priceTo ) { this . priceTo = priceTo ; } int first ; int count ; int order ; public int getFirst ( ) { return first ; } public void setFirst ( int first ) { this . first = first ; } public int getCount ( ) { return count ; } public void setCount ( int count ) { this . count = count ; } public int getOrder ( ) { return order ; } public void setOrder ( int order ) { this . order = order ; } @ Override public String toString ( ) { return "<STR_LIT>" + name + "<STR_LIT>" + description + "<STR_LIT>" + priceFrom + "<STR_LIT>" + priceTo + "<STR_LIT>" + first + "<STR_LIT>" + count + "<STR_LIT>" + order + "<STR_LIT:]>" ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import java . awt . image . BufferedImage ; import org . apache . wicket . markup . html . image . resource . DynamicImageResource ; public class ImageResource extends DynamicImageResource { private byte [ ] image ; public ImageResource ( byte [ ] image , String format ) { this . image = image ; setFormat ( format ) ; } public ImageResource ( BufferedImage image ) { this . image = toImageData ( image ) ; } @ Override protected byte [ ] getImageData ( ) { if ( image != null ) { return image ; } else { return new byte [ <NUM_LIT:0> ] ; } } @ Override protected int getCacheDuration ( ) { return <NUM_LIT> * <NUM_LIT:24> ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import org . apache . wicket . PageParameters ; import org . apache . wicket . ResourceReference ; import org . apache . wicket . behavior . SimpleAttributeModifier ; import org . apache . wicket . markup . html . basic . Label ; import org . apache . wicket . markup . html . form . Button ; import org . apache . wicket . markup . html . form . Form ; import org . apache . wicket . markup . html . image . Image ; import org . apache . wicket . markup . html . image . NonCachingImage ; import org . apache . wicket . model . AbstractReadOnlyModel ; import org . apache . wicket . model . CompoundPropertyModel ; import org . apache . wicket . spring . injection . annot . SpringBean ; import org . sqlproc . sample . catalog . model . Item ; import org . sqlproc . sample . catalog . service . ItemService ; public class ItemDetails extends BasePage { @ SpringBean ( name = "<STR_LIT>" ) ItemService itemService ; public ItemDetails ( ) { createPage ( new Item ( ) ) ; } public ItemDetails ( PageParameters params ) { Item item = itemService . findById ( params . getLong ( "<STR_LIT>" ) ) ; createPage ( item ) ; } private void createPage ( final Item item ) { add ( new Label ( "<STR_LIT:name>" , item . getName ( ) ) ) ; add ( new Label ( "<STR_LIT:description>" , item . getDescription ( ) ) ) ; if ( item . getImage ( ) != null && item . getImage ( ) . length > <NUM_LIT:0> ) { add ( new NonCachingImage ( "<STR_LIT>" , new AbstractReadOnlyModel ( ) { @ Override public Object getObject ( ) { return new ImageResource ( item . getImage ( ) , "<STR_LIT>" ) ; } } ) ) ; } else { add ( new Image ( "<STR_LIT>" , new ResourceReference ( this . getClass ( ) , "<STR_LIT>" ) ) ) ; } final Form < Item > form = new Form < Item > ( "<STR_LIT>" , new CompoundPropertyModel < Item > ( item ) ) ; add ( form ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { Item item = form . getModelObject ( ) ; setResponsePage ( new ItemEdit ( item . getItemid ( ) , null ) ) ; } } ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { Item item = form . getModelObject ( ) ; itemService . delete ( item . getItemid ( ) ) ; setResponsePage ( ItemList . class ) ; } } . add ( new SimpleAttributeModifier ( "<STR_LIT>" , "<STR_LIT>" ) ) ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { setResponsePage ( ItemList . class ) ; } } ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { setResponsePage ( ItemSearch . class ) ; } } ) ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import org . apache . wicket . markup . html . WebPage ; import org . apache . wicket . markup . html . resources . StyleSheetReference ; import org . apache . wicket . model . IModel ; import org . apache . wicket . util . string . Strings ; public class BasePage extends WebPage { public BasePage ( ) { this ( null ) ; } public BasePage ( IModel < ? > model ) { super ( model ) ; final String packageName = getClass ( ) . getPackage ( ) . getName ( ) ; add ( new HeaderPanel ( "<STR_LIT>" , Strings . afterLast ( packageName , '<CHAR_LIT:.>' ) ) ) ; add ( new StyleSheetReference ( "<STR_LIT>" , BasePage . class , "<STR_LIT>" ) ) ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import java . util . Iterator ; import org . apache . wicket . PageParameters ; import org . apache . wicket . ResourceReference ; import org . apache . wicket . markup . html . basic . Label ; import org . apache . wicket . markup . html . form . Button ; import org . apache . wicket . markup . html . form . Form ; import org . apache . wicket . markup . html . image . Image ; import org . apache . wicket . markup . html . image . NonCachingImage ; import org . apache . wicket . markup . html . link . BookmarkablePageLink ; import org . apache . wicket . markup . html . navigation . paging . PagingNavigator ; import org . apache . wicket . markup . repeater . Item ; import org . apache . wicket . markup . repeater . data . DataView ; import org . apache . wicket . markup . repeater . data . IDataProvider ; import org . apache . wicket . model . AbstractReadOnlyModel ; import org . apache . wicket . model . CompoundPropertyModel ; import org . apache . wicket . model . IModel ; import org . apache . wicket . model . LoadableDetachableModel ; import org . apache . wicket . model . Model ; import org . apache . wicket . spring . injection . annot . SpringBean ; import org . sqlproc . sample . catalog . form . ItemForm ; import org . sqlproc . sample . catalog . service . ItemService ; import org . sqlproc . sample . catalog . to . ItemTO ; public class ItemList extends BasePage { private static final int ROWS_PER_PAGE = <NUM_LIT:5> ; @ SpringBean ( name = "<STR_LIT>" ) ItemService itemService ; public ItemList ( final ItemForm searchForm ) { createPage ( searchForm ) ; } public ItemList ( final PageParameters parameters ) { createPage ( new ItemForm ( ) ) ; } private void createPage ( final ItemForm searchForm ) { IDataProvider < ItemTO > itemDataProvider = new IDataProvider < ItemTO > ( ) { @ Override public Iterator < ItemTO > iterator ( int first , int count ) { searchForm . setFirst ( first ) ; searchForm . setCount ( count ) ; searchForm . setOrder ( <NUM_LIT:1> ) ; return itemService . find ( searchForm ) . iterator ( ) ; } @ Override public int size ( ) { return itemService . findCount ( searchForm ) ; } @ Override public IModel < ItemTO > model ( final ItemTO object ) { return new LoadableDetachableModel < ItemTO > ( ) { @ Override protected ItemTO load ( ) { return object ; } } ; } @ Override public void detach ( ) { } } ; DataView < ItemTO > dataView = new DataView < ItemTO > ( "<STR_LIT>" , itemDataProvider , ROWS_PER_PAGE ) { @ Override protected void populateItem ( Item < ItemTO > repItem ) { final ItemTO item = repItem . getModelObject ( ) ; repItem . setModel ( new CompoundPropertyModel < ItemTO > ( item ) ) ; repItem . add ( link ( "<STR_LIT>" , item ) ) ; if ( item . getImagethumb ( ) != null && item . getImagethumb ( ) . length > <NUM_LIT:0> ) { repItem . add ( new NonCachingImage ( "<STR_LIT>" , new AbstractReadOnlyModel ( ) { @ Override public Object getObject ( ) { return new ImageResource ( item . getImagethumb ( ) , "<STR_LIT>" ) ; } } ) ) ; } else { repItem . add ( new Image ( "<STR_LIT>" , new ResourceReference ( this . getClass ( ) , "<STR_LIT>" ) ) ) ; } repItem . add ( new Label ( "<STR_LIT>" ) ) ; } } ; add ( dataView ) ; PagingNavigator pager = new PagingNavigator ( "<STR_LIT>" , dataView ) ; add ( pager ) ; final Form < Item > form = new Form < Item > ( "<STR_LIT>" ) ; add ( form ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { setResponsePage ( new ItemEdit ( null , ItemList . this ) ) ; } } ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { setResponsePage ( ItemSearch . class ) ; } } ) ; } public static BookmarkablePageLink < Void > link ( final String name , final ItemTO item ) { final BookmarkablePageLink < Void > link = new BookmarkablePageLink < Void > ( name , ItemDetails . class ) ; if ( item != null ) { link . setParameter ( "<STR_LIT>" , item . getItemid ( ) ) ; link . add ( new Label ( "<STR_LIT:name>" , new Model < ItemTO > ( item ) ) ) ; } return link ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import org . apache . wicket . PageParameters ; import org . apache . wicket . markup . html . form . Button ; import org . apache . wicket . markup . html . form . Form ; import org . apache . wicket . markup . html . form . StatelessForm ; import org . apache . wicket . markup . html . form . TextField ; import org . apache . wicket . markup . html . link . Link ; import org . apache . wicket . model . CompoundPropertyModel ; import org . sqlproc . sample . catalog . form . ItemForm ; public class ItemSearch extends BasePage { public ItemSearch ( PageParameters params ) { final ItemForm searchForm = new ItemForm ( ) ; final Form form = new StatelessForm ( "<STR_LIT>" , new CompoundPropertyModel ( searchForm ) ) ; add ( form ) ; form . add ( new TextField ( "<STR_LIT:name>" ) ) ; form . add ( new TextField ( "<STR_LIT:description>" ) ) ; form . add ( new TextField ( "<STR_LIT>" ) ) ; form . add ( new TextField ( "<STR_LIT>" ) ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { setResponsePage ( new ItemList ( searchForm ) ) ; } } ) ; form . add ( new Link ( "<STR_LIT>" ) { @ Override public void onClick ( ) { setResponsePage ( new ItemEdit ( null , ItemSearch . this ) ) ; } } ) ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import org . apache . wicket . markup . html . panel . Panel ; public class HeaderPanel extends Panel { public HeaderPanel ( String componentName , String exampleTitle ) { super ( componentName ) ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import org . apache . wicket . protocol . http . WebApplication ; import org . apache . wicket . spring . injection . annot . SpringComponentInjector ; import org . apache . wicket . util . time . Duration ; public class Application extends WebApplication { public Application ( ) { } public Class getHomePage ( ) { return ItemSearch . class ; } @ Override protected void init ( ) { super . init ( ) ; addComponentInstantiationListener ( new SpringComponentInjector ( this ) ) ; if ( Application . DEPLOYMENT . equals ( getConfigurationType ( ) ) ) { getMarkupSettings ( ) . setStripWicketTags ( true ) ; getMarkupSettings ( ) . setCompressWhitespace ( true ) ; } else { getResourceSettings ( ) . setResourcePollFrequency ( Duration . ONE_SECOND ) ; } getMarkupSettings ( ) . setDefaultAfterDisabledLink ( "<STR_LIT>" ) ; } } </s>
<s> package org . sqlproc . sample . catalog . wicket ; import org . apache . wicket . PageParameters ; import org . apache . wicket . markup . html . WebPage ; import org . apache . wicket . markup . html . basic . Label ; import org . apache . wicket . markup . html . form . Button ; import org . apache . wicket . markup . html . form . Form ; import org . apache . wicket . markup . html . form . StatelessForm ; import org . apache . wicket . markup . html . form . TextArea ; import org . apache . wicket . markup . html . form . TextField ; import org . apache . wicket . markup . html . form . upload . FileUpload ; import org . apache . wicket . markup . html . form . upload . FileUploadField ; import org . apache . wicket . markup . html . link . Link ; import org . apache . wicket . markup . html . panel . FeedbackPanel ; import org . apache . wicket . model . CompoundPropertyModel ; import org . apache . wicket . model . IModel ; import org . apache . wicket . spring . injection . annot . SpringBean ; import org . sqlproc . sample . catalog . model . Item ; import org . sqlproc . sample . catalog . service . ItemService ; public class ItemEdit extends BasePage { @ SpringBean ( name = "<STR_LIT>" ) ItemService itemService ; final WebPage previousPage ; FileUploadField imageUploadField ; FileUploadField imagethumbUploadField ; public ItemEdit ( Long itemid , WebPage previousPage ) { this . previousPage = previousPage ; final Item item = ( itemid != null ) ? itemService . findById ( itemid ) : new Item ( ) ; final Form < Item > form = new StatelessForm < Item > ( "<STR_LIT>" , new CompoundPropertyModel < Item > ( item ) ) ; form . setMultiPart ( true ) ; add ( form ) ; form . add ( new FeedbackPanel ( "<STR_LIT>" ) ) ; form . add ( new TextField ( "<STR_LIT>" ) . setRequired ( true ) ) ; form . add ( new TextField ( "<STR_LIT:name>" ) . setRequired ( true ) ) ; form . add ( new TextArea ( "<STR_LIT:description>" ) . setRequired ( true ) ) ; form . add ( new FileUploadField ( "<STR_LIT>" , new IModel < FileUpload > ( ) { @ Override public void detach ( ) { } @ Override public FileUpload getObject ( ) { return null ; } @ Override public void setObject ( FileUpload imageUpload ) { if ( imageUpload != null ) { item . setImageurl ( imageUpload . getClientFileName ( ) ) ; item . setImage ( imageUpload . getBytes ( ) ) ; } } } ) ) ; form . add ( new Label ( "<STR_LIT>" , item . getImageurl ( ) ) ) ; form . add ( new FileUploadField ( "<STR_LIT>" , new IModel < FileUpload > ( ) { @ Override public void detach ( ) { } @ Override public FileUpload getObject ( ) { return null ; } @ Override public void setObject ( FileUpload imagethumbUpload ) { if ( imagethumbUpload != null ) { item . setImagethumburl ( imagethumbUpload . getClientFileName ( ) ) ; item . setImagethumb ( imagethumbUpload . getBytes ( ) ) ; } } } ) ) ; form . add ( new Label ( "<STR_LIT>" , item . getImagethumburl ( ) ) ) ; form . add ( new TextField ( "<STR_LIT>" ) . setRequired ( true ) ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { Item item = form . getModelObject ( ) ; Long itemid = ( item . getItemid ( ) != null ) ? itemService . update ( item ) : itemService . create ( item ) ; PageParameters pp = new PageParameters ( ) ; pp . put ( "<STR_LIT>" , itemid ) ; setResponsePage ( ItemDetails . class , pp ) ; } } ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { Item item = form . getModelObject ( ) ; item . setImage ( null ) ; item . setImageurl ( null ) ; itemService . update ( item ) ; PageParameters pp = new PageParameters ( ) ; pp . put ( "<STR_LIT>" , item . getItemid ( ) ) ; setResponsePage ( ItemDetails . class , pp ) ; } } . setVisibilityAllowed ( item . getItemid ( ) != null ) ) ; form . add ( new Button ( "<STR_LIT>" ) { @ Override public void onSubmit ( ) { Item item = form . getModelObject ( ) ; item . setImagethumb ( null ) ; item . setImagethumburl ( null ) ; itemService . update ( item ) ; PageParameters pp = new PageParameters ( ) ; pp . put ( "<STR_LIT>" , item . getItemid ( ) ) ; setResponsePage ( ItemDetails . class , pp ) ; } } . setVisibilityAllowed ( item . getItemid ( ) != null ) ) ; form . add ( new Link ( "<STR_LIT>" ) { @ Override public void onClick ( ) { Item item = form . getModelObject ( ) ; if ( item . getItemid ( ) == null ) { if ( ItemEdit . this . previousPage != null ) setResponsePage ( ItemEdit . this . previousPage ) ; else setResponsePage ( ItemList . class ) ; } else { PageParameters pp = new PageParameters ( ) ; pp . put ( "<STR_LIT>" , item . getItemid ( ) ) ; setResponsePage ( ItemDetails . class , pp ) ; } } } ) ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class CreditCard extends BillingDetails { private Long number ; public CreditCard ( ) { } public CreditCard ( Long number , Subscriber subscriber ) { super ( "<STR_LIT>" , subscriber ) ; this . number = number ; } public Long getNumber ( ) { return number ; } public void setNumber ( Long number ) { this . number = number ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public abstract class BillingDetails { private Long id ; private String type ; private Subscriber subscriber ; public BillingDetails ( ) { } public BillingDetails ( String type , Subscriber subscriber ) { this . type = type ; this . subscriber = subscriber ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public String getType ( ) { return type ; } public void setType ( String type ) { this . type = type ; } public Subscriber getSubscriber ( ) { return subscriber ; } public void setSubscriber ( Subscriber subscriber ) { this . subscriber = subscriber ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import java . util . List ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Person { private Long id ; private String name ; private List < Contact > contacts ; private List < Media > library ; public Person ( ) { } public Person ( String name ) { this . name = name ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } public List < Contact > getContacts ( ) { return contacts ; } public void setContacts ( List < Contact > contacts ) { this . contacts = contacts ; } public List < Media > getLibrary ( ) { return library ; } public void setLibrary ( List < Media > library ) { this . library = library ; } @ Override public String toString ( ) { return "<STR_LIT>" + id + "<STR_LIT>" + name + "<STR_LIT>" + contacts + "<STR_LIT>" + library + "<STR_LIT:]>" ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class BankAccount extends BillingDetails { private String account ; public BankAccount ( ) { } public BankAccount ( String account , Subscriber subscriber ) { super ( "<STR_LIT>" , subscriber ) ; this . account = account ; } public String getAccount ( ) { return account ; } public void setAccount ( String account ) { this . account = account ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Library { private Long id ; private String name ; public Library ( ) { } public Library ( String name ) { this . name = name ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class PersonLibrary { private Long id ; private Long personId ; private Long mediaId ; public PersonLibrary ( Long personId , Long mediaId ) { this . personId = personId ; this . mediaId = mediaId ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public Long getPersonId ( ) { return personId ; } public void setPersonId ( Long personId ) { this . personId = personId ; } public Long getMediaId ( ) { return mediaId ; } public void setMediaId ( Long mediaId ) { this . mediaId = mediaId ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Contact { private Long id ; private Long personId ; private String address ; private PhoneNumber homePhone ; public Contact ( ) { } public Contact ( String address ) { this . address = address ; } public Contact ( String address , PhoneNumber homePhone ) { this . address = address ; this . homePhone = homePhone ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public Long getPersonId ( ) { return personId ; } public void setPersonId ( Long personId ) { this . personId = personId ; } public String getAddress ( ) { return address ; } public void setAddress ( String address ) { this . address = address ; } public PhoneNumber getHomePhone ( ) { return homePhone ; } public void setHomePhone ( PhoneNumber homePhone ) { this . homePhone = homePhone ; } @ Override public String toString ( ) { return "<STR_LIT>" + id + "<STR_LIT>" + personId + "<STR_LIT>" + address + "<STR_LIT>" + homePhone + "<STR_LIT:]>" ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Book extends Media { private String isbn ; public Book ( ) { } public Book ( String title , String isbn ) { super ( title ) ; this . isbn = isbn ; } public String getIsbn ( ) { return isbn ; } public void setIsbn ( String isbn ) { this . isbn = isbn ; } @ Override public String toString ( ) { return "<STR_LIT>" + isbn + "<STR_LIT>" + getId ( ) + "<STR_LIT>" + getTitle ( ) + "<STR_LIT:]>" ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public abstract class Media { private Long id ; private String title ; public Media ( ) { } public Media ( String title ) { this . title = title ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public String getTitle ( ) { return title ; } public void setTitle ( String title ) { this . title = title ; } @ Override public String toString ( ) { return "<STR_LIT>" + id + "<STR_LIT>" + title + "<STR_LIT:]>" ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public final class PhoneNumber { private final int area ; private final int exch ; private final int ext ; public PhoneNumber ( int area , int exch , int ext ) { this . area = area ; this . exch = exch ; this . ext = ext ; } public int getArea ( ) { return area ; } public int getExch ( ) { return exch ; } public int getExt ( ) { return ext ; } public boolean equals ( Object y ) { if ( y == this ) { return true ; } if ( y == null ) { return false ; } if ( y . getClass ( ) != this . getClass ( ) ) { return false ; } PhoneNumber a = this ; PhoneNumber b = ( PhoneNumber ) y ; return ( a . area == b . area ) && ( a . exch == b . exch ) && ( a . ext == b . ext ) ; } public String toString ( ) { return String . format ( "<STR_LIT>" , area , exch , ext ) ; } public int hashCode ( ) { return <NUM_LIT> * ( area + <NUM_LIT> * exch ) + ext ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Movie extends Media { private String urlIMDB ; private Integer playLength ; public Movie ( ) { } public Movie ( String title , String urlIMDB , Integer playLength ) { super ( title ) ; this . urlIMDB = urlIMDB ; this . playLength = playLength ; } public String getUrlIMDB ( ) { return urlIMDB ; } public void setUrlIMDB ( String urlIMDB ) { this . urlIMDB = urlIMDB ; } public Integer getPlayLength ( ) { return playLength ; } public void setPlayLength ( Integer playLength ) { this . playLength = playLength ; } @ Override public String toString ( ) { return "<STR_LIT>" + urlIMDB + "<STR_LIT>" + playLength + "<STR_LIT>" + getId ( ) + "<STR_LIT>" + getTitle ( ) + "<STR_LIT:]>" ; } } </s>
<s> package org . sqlproc . sample . simple . model ; import java . util . List ; import org . sqlproc . engine . annotation . Pojo ; @ Pojo public class Subscriber { private Long id ; private String name ; private Contact contact ; private Library library ; private List < BillingDetails > billingDetails ; public Subscriber ( ) { } public Subscriber ( String name , Library library ) { this . name = name ; this . library = library ; } public Long getId ( ) { return id ; } public void setId ( Long id ) { this . id = id ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } public Contact getContact ( ) { return contact ; } public void setContact ( Contact contact ) { this . contact = contact ; } public Library getLibrary ( ) { return library ; } public void setLibrary ( Library library ) { this . library = library ; } public List < BillingDetails > getBillingDetails ( ) { return billingDetails ; } public void setBillingDetails ( List < BillingDetails > billingDetails ) { this . billingDetails = billingDetails ; } } </s>
<s> package org . sqlproc . sample . simple . type ; import java . lang . reflect . Method ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Iterator ; import java . util . List ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; import org . hibernate . type . StringType ; import org . sqlproc . engine . SqlQuery ; import org . sqlproc . engine . SqlRuntimeException ; import org . sqlproc . engine . impl . BeanUtils ; import org . sqlproc . engine . type . SqlInternalType ; import org . sqlproc . sample . simple . model . PhoneNumber ; public class PhoneNumberType extends SqlInternalType { static Pattern pattern = Pattern . compile ( "<STR_LIT>" ) ; @ Override public Class < ? > [ ] getClassTypes ( ) { return new Class [ ] { PhoneNumber . class } ; } @ Override public String [ ] getMetaTypes ( ) { return new String [ ] { "<STR_LIT>" } ; } public void addScalar ( SqlQuery query , String dbName , Class < ? > attributeType ) { query . addScalar ( dbName , StringType . INSTANCE ) ; } @ Override public void setResult ( Object resultInstance , String attributeName , Object resultValue , boolean ingoreError ) throws SqlRuntimeException { Method m = BeanUtils . getSetter ( resultInstance , attributeName , PhoneNumber . class ) ; if ( m == null ) { if ( ingoreError ) { logger . error ( "<STR_LIT>" + attributeName + "<STR_LIT>" + resultInstance + "<STR_LIT>" ) ; return ; } else { throw new SqlRuntimeException ( "<STR_LIT>" + attributeName + "<STR_LIT>" + resultInstance + "<STR_LIT>" ) ; } } if ( resultValue == null ) { BeanUtils . simpleInvokeMethod ( m , resultInstance , null ) ; return ; } if ( ! ( resultValue instanceof String ) ) { if ( ingoreError ) { logger . error ( "<STR_LIT>" + resultValue + "<STR_LIT>" ) ; return ; } else { throw new SqlRuntimeException ( "<STR_LIT>" + resultValue + "<STR_LIT>" ) ; } } String sPhoneNumber = ( String ) resultValue ; Matcher matcher = pattern . matcher ( sPhoneNumber ) ; if ( ! matcher . matches ( ) ) { if ( ingoreError ) { logger . error ( "<STR_LIT>" + sPhoneNumber + "<STR_LIT:'>" ) ; return ; } else { throw new SqlRuntimeException ( "<STR_LIT>" + sPhoneNumber + "<STR_LIT:'>" ) ; } } int area = Integer . parseInt ( matcher . group ( <NUM_LIT:1> ) ) ; int exch = Integer . parseInt ( matcher . group ( <NUM_LIT:2> ) ) ; int ext = Integer . parseInt ( matcher . group ( <NUM_LIT:3> ) ) ; BeanUtils . simpleInvokeMethod ( m , resultInstance , new PhoneNumber ( area , exch , ext ) ) ; } @ Override public void setParameter ( SqlQuery query , String paramName , Object inputValue , Class < ? > inputType , boolean ingoreError ) throws SqlRuntimeException { if ( inputValue == null ) { query . setParameter ( paramName , inputValue , StringType . INSTANCE ) ; } else { if ( inputValue instanceof Collection ) { List < String > phoneNumbers = new ArrayList < String > ( ) ; for ( Iterator iter = ( ( Collection ) inputValue ) . iterator ( ) ; iter . hasNext ( ) ; ) { Object o = iter . next ( ) ; if ( o != null ) { if ( ! ( o instanceof PhoneNumber ) ) { if ( ingoreError ) { logger . error ( "<STR_LIT>" + o + "<STR_LIT>" ) ; continue ; } else { throw new SqlRuntimeException ( "<STR_LIT>" + o + "<STR_LIT>" ) ; } } String sPhoneNumber = ( ( PhoneNumber ) o ) . toString ( ) ; } } query . setParameterList ( paramName , phoneNumbers . toArray ( ) , StringType . INSTANCE ) ; } else { if ( ! ( inputValue instanceof PhoneNumber ) ) { if ( ingoreError ) { logger . error ( "<STR_LIT>" + inputValue + "<STR_LIT>" ) ; return ; } else { throw new SqlRuntimeException ( "<STR_LIT>" + inputValue + "<STR_LIT>" ) ; } } PhoneNumber phoneNumber = ( PhoneNumber ) inputValue ; String sPhoneNumber = String . format ( "<STR_LIT>" , phoneNumber . getArea ( ) , phoneNumber . getExch ( ) , phoneNumber . getExt ( ) ) ; query . setParameter ( paramName , sPhoneNumber , StringType . INSTANCE ) ; } } } } </s>
<s> package org . sqlproc . sample . simple ; import java . sql . Connection ; import java . sql . SQLException ; import java . sql . Statement ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Properties ; import org . hibernate . Session ; import org . hibernate . SessionFactory ; import org . hibernate . cfg . Configuration ; import org . hibernate . jdbc . Work ; import org . junit . Assert ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import org . sqlproc . engine . SqlCrudEngine ; import org . sqlproc . engine . SqlEngineFactory ; import org . sqlproc . engine . SqlOrder ; import org . sqlproc . engine . SqlPropertiesLoader ; import org . sqlproc . engine . SqlQueryEngine ; import org . sqlproc . engine . SqlSession ; import org . sqlproc . engine . hibernate . HibernateEngineFactory ; import org . sqlproc . engine . hibernate . HibernateSession ; import org . sqlproc . sample . simple . model . BankAccount ; import org . sqlproc . sample . simple . model . Book ; import org . sqlproc . sample . simple . model . Contact ; import org . sqlproc . sample . simple . model . CreditCard ; import org . sqlproc . sample . simple . model . Library ; import org . sqlproc . sample . simple . model . Media ; import org . sqlproc . sample . simple . model . Movie ; import org . sqlproc . sample . simple . model . Person ; import org . sqlproc . sample . simple . model . PersonLibrary ; import org . sqlproc . sample . simple . model . PhoneNumber ; import org . sqlproc . sample . simple . model . Subscriber ; import org . sqlproc . sample . simple . type . PhoneNumberType ; public class Main { private final Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; private SessionFactory sessionFactory ; private SqlEngineFactory sqlFactory ; private Properties catalog ; public Main ( ) { HibernateEngineFactory factory = new HibernateEngineFactory ( ) ; factory . setMetaFilesNames ( "<STR_LIT>" ) ; factory . addCustomType ( new PhoneNumberType ( ) ) ; sqlFactory = factory ; SqlPropertiesLoader catalogLoader = new SqlPropertiesLoader ( "<STR_LIT>" , this . getClass ( ) ) ; catalog = catalogLoader . getProperties ( ) ; Configuration configuration = new Configuration ( ) . configure ( "<STR_LIT>" ) ; sessionFactory = configuration . buildSessionFactory ( ) ; } public void setupDb ( ) throws Exception { Session session = null ; try { session = sessionFactory . openSession ( ) ; session . doWork ( new Work ( ) { @ Override public void execute ( Connection connection ) throws SQLException { Statement stmt = null ; try { stmt = connection . createStatement ( ) ; for ( int i = <NUM_LIT:1> ; i <= <NUM_LIT> ; i ++ ) { String ddl = catalog . getProperty ( "<STR_LIT:s>" + i ) ; if ( ddl == null ) continue ; System . out . println ( ddl ) ; stmt . addBatch ( ddl ) ; } stmt . executeBatch ( ) ; } catch ( SQLException ex ) { if ( stmt != null ) stmt . close ( ) ; throw ex ; } } } ) ; } finally { if ( session != null ) session . close ( ) ; } } public List < Person > listAll ( ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; List < Person > list = sqlEngine . query ( session , Person . class ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public List < Person > listSome ( Person person ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; List < Person > list = sqlEngine . query ( session , Person . class , person , SqlOrder . getDescOrder ( <NUM_LIT:2> ) ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public List < Person > listLike ( Person person ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; List < Person > list = sqlEngine . query ( session , Person . class , person , SqlOrder . getDescOrder ( <NUM_LIT:2> ) ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Person insert ( Person person , Contact ... contacts ) { SqlCrudEngine sqlInsertPerson = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlCrudEngine sqlInsertContact = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertPerson . insert ( session , person ) ; logger . info ( "<STR_LIT>" + count ) ; logger . info ( "<STR_LIT>" + person ) ; if ( contacts != null && count > <NUM_LIT:0> ) { for ( Contact contact : contacts ) { contact . setPersonId ( person . getId ( ) ) ; sqlInsertContact . insert ( session , contact ) ; } } return ( count > <NUM_LIT:0> ) ? person : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Person get ( Person person ) { SqlCrudEngine sqlEngine = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; Person p = sqlEngine . get ( session , Person . class , person ) ; logger . info ( "<STR_LIT>" + p ) ; return p ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Person update ( Person person ) { SqlCrudEngine sqlEngine = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlEngine . update ( session , person ) ; logger . info ( "<STR_LIT>" + count ) ; return ( count > <NUM_LIT:0> ) ? person : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public boolean delete ( Person person ) { SqlCrudEngine sqlEngine = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlEngine . delete ( session , person ) ; logger . info ( "<STR_LIT>" + count ) ; return ( count > <NUM_LIT:0> ) ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public List < Person > listPeopleAndContacts ( Person person ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; List < Person > list = sqlEngine . query ( session , Person . class , person , SqlQueryEngine . ASC_ORDER ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Movie insertMovie ( Movie movie ) { SqlCrudEngine sqlInsertMedia = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlCrudEngine sqlInsertMovie = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertMedia . insert ( session , movie ) ; if ( count > <NUM_LIT:0> ) { sqlInsertMovie . insert ( session , movie ) ; } return ( count > <NUM_LIT:0> ) ? movie : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Book insertBook ( Book book ) { SqlCrudEngine sqlInsertMedia = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlCrudEngine sqlInsertBook = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertMedia . insert ( session , book ) ; if ( count > <NUM_LIT:0> ) { sqlInsertBook . insert ( session , book ) ; } return ( count > <NUM_LIT:0> ) ? book : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public void createPersonLibrary ( Person person , Media ... media ) { SqlCrudEngine sqlCreateLibrary = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; if ( media == null || media . length == <NUM_LIT:0> ) return ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; for ( Media media1 : media ) { PersonLibrary library = new PersonLibrary ( person . getId ( ) , media1 . getId ( ) ) ; sqlCreateLibrary . insert ( session , library ) ; } } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public List < Person > listPeopleLibrary ( Person person ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; Map < String , Class < ? > > moreResultClasses = new HashMap < String , Class < ? > > ( ) ; moreResultClasses . put ( "<STR_LIT>" , Movie . class ) ; moreResultClasses . put ( "<STR_LIT>" , Book . class ) ; List < Person > list = sqlEngine . query ( session , Person . class , null , null , SqlQueryEngine . ASC_ORDER , moreResultClasses ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Person insertCustom ( Person person , Contact ... contacts ) { SqlCrudEngine sqlInsertPerson = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlCrudEngine sqlInsertContact = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertPerson . insert ( session , person ) ; logger . info ( "<STR_LIT>" + count ) ; logger . info ( "<STR_LIT>" + person ) ; if ( contacts != null && count > <NUM_LIT:0> ) { for ( Contact contact : contacts ) { contact . setPersonId ( person . getId ( ) ) ; sqlInsertContact . insert ( session , contact ) ; } } return ( count > <NUM_LIT:0> ) ? person : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public List < Person > listCustom ( Contact contact ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; List < Person > list = sqlEngine . query ( session , Person . class , contact , SqlQueryEngine . ASC_ORDER ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Library insertLibrary ( Library library ) { SqlCrudEngine sqlInsertLibrary = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertLibrary . insert ( session , library ) ; return ( count > <NUM_LIT:0> ) ? library : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public Subscriber insertSubscriber ( Subscriber subscriber ) { SqlCrudEngine sqlInsertSubscriber = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertSubscriber . insert ( session , subscriber ) ; return ( count > <NUM_LIT:0> ) ? subscriber : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public BankAccount insertBankAccount ( BankAccount bankAccount ) { SqlCrudEngine sqlInsertBankAccount = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertBankAccount . insert ( session , bankAccount ) ; return ( count > <NUM_LIT:0> ) ? bankAccount : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public CreditCard insertCreditCard ( CreditCard creditCard ) { SqlCrudEngine sqlInsertCreditCard = sqlFactory . getCrudEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; int count = sqlInsertCreditCard . insert ( session , creditCard ) ; return ( count > <NUM_LIT:0> ) ? creditCard : null ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public List < Subscriber > listAllSubsribersWithBillingDetails ( ) { SqlQueryEngine sqlEngine = sqlFactory . getQueryEngine ( "<STR_LIT>" ) ; SqlSession session = null ; try { session = HibernateSession . generateProxy ( sessionFactory . openSession ( ) ) ; Map < String , Class < ? > > moreResultClasses = new HashMap < String , Class < ? > > ( ) ; moreResultClasses . put ( "<STR_LIT>" , BankAccount . class ) ; moreResultClasses . put ( "<STR_LIT>" , CreditCard . class ) ; List < Subscriber > list = sqlEngine . query ( session , Subscriber . class , null , null , SqlQueryEngine . ASC_ORDER , moreResultClasses ) ; logger . info ( "<STR_LIT>" + list . size ( ) ) ; return list ; } finally { if ( session != null ) ( ( Session ) session ) . close ( ) ; } } public static void main ( String [ ] args ) throws Exception { Person person , p ; List < Person > list ; boolean deleted ; Main main = new Main ( ) ; main . setupDb ( ) ; Person jan = main . insert ( new Person ( "<STR_LIT>" ) , new Contact ( "<STR_LIT>" ) ) ; Person janik = main . insert ( new Person ( "<STR_LIT>" ) , new Contact ( "<STR_LIT>" ) ) ; Person honza = main . insert ( new Person ( "<STR_LIT>" ) , new Contact ( "<STR_LIT>" ) , new Contact ( "<STR_LIT>" ) ) ; Person honzik = main . insert ( new Person ( "<STR_LIT>" ) ) ; Person andrej = main . insert ( new Person ( "<STR_LIT>" ) , new Contact ( "<STR_LIT>" ) ) ; Book book1 = main . insertBook ( new Book ( "<STR_LIT>" , "<STR_LIT>" ) ) ; Book book2 = main . insertBook ( new Book ( "<STR_LIT>" , "<STR_LIT>" ) ) ; Movie movie1 = main . insertMovie ( new Movie ( "<STR_LIT>" , "<STR_LIT:abc>" , <NUM_LIT> ) ) ; Movie movie2 = main . insertMovie ( new Movie ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT> ) ) ; main . createPersonLibrary ( jan , book1 , movie1 ) ; main . createPersonLibrary ( honza , book2 , movie2 ) ; main . createPersonLibrary ( andrej , book1 , book2 , movie2 ) ; Library lib = main . insertLibrary ( new Library ( "<STR_LIT>" ) ) ; Subscriber arnost = main . insertSubscriber ( new Subscriber ( "<STR_LIT>" , lib ) ) ; Subscriber maria = main . insertSubscriber ( new Subscriber ( "<STR_LIT>" , lib ) ) ; main . insertBankAccount ( new BankAccount ( "<STR_LIT>" , arnost ) ) ; main . insertBankAccount ( new BankAccount ( "<STR_LIT>" , maria ) ) ; main . insertCreditCard ( new CreditCard ( <NUM_LIT> , arnost ) ) ; main . insertCreditCard ( new CreditCard ( <NUM_LIT> , maria ) ) ; list = main . listAll ( ) ; Assert . assertEquals ( <NUM_LIT:5> , list . size ( ) ) ; person = new Person ( ) ; person . setName ( "<STR_LIT>" ) ; list = main . listSome ( person ) ; Assert . assertEquals ( <NUM_LIT:1> , list . size ( ) ) ; person = new Person ( ) ; person . setName ( "<STR_LIT>" ) ; list = main . listLike ( person ) ; Assert . assertEquals ( <NUM_LIT:3> , list . size ( ) ) ; person = new Person ( ) ; person . setName ( "<STR_LIT>" ) ; list = main . listPeopleAndContacts ( person ) ; Assert . assertEquals ( <NUM_LIT:1> , list . size ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getName ( ) ) ; Assert . assertEquals ( <NUM_LIT:2> , list . get ( <NUM_LIT:0> ) . getContacts ( ) . size ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getContacts ( ) . get ( <NUM_LIT:0> ) . getAddress ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getContacts ( ) . get ( <NUM_LIT:1> ) . getAddress ( ) ) ; list = main . listPeopleLibrary ( null ) ; Assert . assertEquals ( <NUM_LIT:5> , list . size ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getName ( ) ) ; Assert . assertEquals ( <NUM_LIT:3> , list . get ( <NUM_LIT:0> ) . getLibrary ( ) . size ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:0> ) . getTitle ( ) ) ; Assert . assertTrue ( list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:0> ) instanceof Movie ) ; Assert . assertEquals ( "<STR_LIT>" , ( ( Movie ) list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:0> ) ) . getUrlIMDB ( ) ) ; Assert . assertEquals ( new Integer ( <NUM_LIT> ) , ( ( Movie ) list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:0> ) ) . getPlayLength ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:1> ) . getTitle ( ) ) ; Assert . assertTrue ( list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:1> ) instanceof Book ) ; Assert . assertEquals ( "<STR_LIT>" , ( ( Book ) list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:1> ) ) . getIsbn ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:2> ) . getTitle ( ) ) ; Assert . assertTrue ( list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:2> ) instanceof Book ) ; Assert . assertEquals ( "<STR_LIT>" , ( ( Book ) list . get ( <NUM_LIT:0> ) . getLibrary ( ) . get ( <NUM_LIT:2> ) ) . getIsbn ( ) ) ; person = new Person ( ) ; person . setId ( andrej . getId ( ) ) ; p = main . get ( person ) ; Assert . assertNotNull ( p ) ; Assert . assertEquals ( "<STR_LIT>" , p . getName ( ) ) ; person = new Person ( ) ; person . setId ( janik . getId ( ) ) ; person . setName ( "<STR_LIT>" ) ; p = main . update ( person ) ; Assert . assertNotNull ( p ) ; Assert . assertEquals ( "<STR_LIT>" , p . getName ( ) ) ; person = new Person ( ) ; person . setId ( jan . getId ( ) ) ; deleted = main . delete ( person ) ; Assert . assertTrue ( deleted ) ; list = main . listAll ( ) ; Assert . assertEquals ( <NUM_LIT:4> , list . size ( ) ) ; try { deleted = main . delete ( null ) ; Assert . fail ( ) ; } catch ( IllegalArgumentException e ) { } list = main . listAll ( ) ; Assert . assertEquals ( <NUM_LIT:4> , list . size ( ) ) ; Person pepa = main . insertCustom ( new Person ( "<STR_LIT>" ) , new Contact ( "<STR_LIT>" , new PhoneNumber ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) ) ; Contact contact = new Contact ( ) ; contact . setHomePhone ( new PhoneNumber ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) ; list = main . listCustom ( contact ) ; Assert . assertEquals ( <NUM_LIT:1> , list . size ( ) ) ; Assert . assertEquals ( "<STR_LIT>" , list . get ( <NUM_LIT:0> ) . getContacts ( ) . get ( <NUM_LIT:0> ) . getHomePhone ( ) . toString ( ) ) ; List < Subscriber > subscribers = main . listAllSubsribersWithBillingDetails ( ) ; Assert . assertEquals ( <NUM_LIT:2> , subscribers . size ( ) ) ; } } </s>
<s> package com . Backside . BacksideUpdater ; import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import org . apache . http . HttpResponse ; import org . apache . http . client . HttpClient ; import org . apache . http . client . methods . HttpGet ; import org . apache . http . impl . client . DefaultHttpClient ; import android . app . Activity ; import android . app . AlertDialog ; import android . app . ProgressDialog ; import android . content . Context ; import android . content . DialogInterface ; import android . content . DialogInterface . OnDismissListener ; import android . content . Intent ; import android . content . pm . ActivityInfo ; import android . content . res . Configuration ; import android . net . ConnectivityManager ; import android . net . NetworkInfo ; import android . net . Uri ; import android . os . Build ; import android . os . Bundle ; import android . os . Handler ; import android . os . Message ; import android . os . PowerManager ; import android . provider . Settings ; import android . text . method . LinkMovementMethod ; import android . view . GestureDetector ; import android . view . Gravity ; import android . view . Menu ; import android . view . MenuItem ; import android . view . MotionEvent ; import android . view . View ; import android . widget . ImageView ; import android . widget . LinearLayout ; import android . widget . TextView ; import android . widget . Toast ; public class BacksideUpdaterActivity extends Activity { private static Context theView ; private static TextView textView ; private static TextView buttonTextView ; private static String manifestURL = "<STR_LIT>" ; private static final String BUILD_VERSION = Build . VERSION . INCREMENTAL ; private static final String [ ] SEPARATED_DATE = BUILD_VERSION . split ( "<STR_LIT:\\.>" ) ; private static final int BUILD_DATE = Integer . parseInt ( SEPARATED_DATE [ <NUM_LIT:2> ] ) ; private static int ALREADY_CHECKED = <NUM_LIT:0> ; private String theDate ; private int choosenDate = <NUM_LIT:0> ; private static String theUrl ; private String theChangeLog = "<STR_LIT>" ; private String romName ; private static String line ; private static String localFileName ; private static String theFileSize ; private static Long fileSize ; private static String theMD5 ; private static String downloadMD5 ; private static String md5FileName ; private static Boolean goodMD5 ; private Boolean upToDate ; private Boolean alreadyDownloaded ; private static String recoveryName ; private static String recoveryMessage ; private static String lastRecoveryMessage ; private static int recoveryStepCount = <NUM_LIT:0> ; private static final int REQUEST_CODE_PICK_FILE = <NUM_LIT> ; private static final int REQUEST_CODE_PICK_RECOVERY = <NUM_LIT:1000> ; private static final int REQUEST_CODE_PICK_OTHER = <NUM_LIT> ; GestureDetector gd ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setRequestedOrientation ( ActivityInfo . SCREEN_ORIENTATION_PORTRAIT ) ; setContentView ( R . layout . main ) ; theView = this ; manifestURL = theView . getString ( R . string . manifest_url ) ; textView = ( TextView ) findViewById ( R . id . pagetext ) ; textView . setMovementMethod ( LinkMovementMethod . getInstance ( ) ) ; textView . setText ( "<STR_LIT>" ) ; buttonTextView = ( TextView ) findViewById ( R . id . BacksideUpdaterButton ) ; buttonTextView . setVisibility ( <NUM_LIT:4> ) ; try { Runtime . getRuntime ( ) . exec ( "<STR_LIT>" ) ; } catch ( Exception e ) { showCustomToast ( e . toString ( ) ) ; } alreadyDownloaded = false ; checkManifest ( ) ; gd = new GestureDetector ( getBaseContext ( ) , sogl ) ; } @ Override public void onConfigurationChanged ( Configuration newConfig ) { super . onConfigurationChanged ( newConfig ) ; setRequestedOrientation ( ActivityInfo . SCREEN_ORIENTATION_PORTRAIT ) ; } @ Override public boolean onTouchEvent ( MotionEvent event ) { return gd . onTouchEvent ( event ) ; } GestureDetector . SimpleOnGestureListener sogl = new GestureDetector . SimpleOnGestureListener ( ) { public boolean onDown ( MotionEvent event ) { return true ; } public void onLongPress ( MotionEvent event ) { String bband = null ; BufferedReader reader = null ; try { reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( "<STR_LIT>" ) ) ) ; bband = reader . readLine ( ) ; } catch ( IOException io ) { io . printStackTrace ( ) ; bband = "<STR_LIT:error>" ; } finally { try { reader . close ( ) ; } catch ( Exception e ) { } reader = null ; } String basebandMessage = "<STR_LIT>" + bband ; showCustomToast ( basebandMessage ) ; } } ; @ Override public boolean onCreateOptionsMenu ( Menu menu ) { menu . add ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , "<STR_LIT>" ) ; menu . add ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , "<STR_LIT>" ) ; menu . add ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:3> , "<STR_LIT>" ) ; menu . add ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:4> , "<STR_LIT>" ) ; menu . add ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:5> , "<STR_LIT>" ) ; menu . add ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:6> , "<STR_LIT>" ) ; menu . add ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:7> , "<STR_LIT>" ) ; return true ; } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { switch ( item . getItemId ( ) ) { case <NUM_LIT:1> : textView . setText ( "<STR_LIT>" ) ; alreadyDownloadedHandler ( ) ; return true ; case <NUM_LIT:2> : textView . setGravity ( <NUM_LIT:3> ) ; textView . setText ( "<STR_LIT>" + romName + "<STR_LIT>" + theChangeLog ) ; return true ; case <NUM_LIT:3> : textView . setText ( "<STR_LIT>" ) ; backupRestoreDialog ( ) ; return true ; case <NUM_LIT:4> : textView . setText ( "<STR_LIT>" ) ; showExtendedManifest ( ) ; return true ; case <NUM_LIT:5> : buttonTextView . setVisibility ( <NUM_LIT:4> ) ; textView . setText ( "<STR_LIT>" ) ; textView . setGravity ( Gravity . CENTER ) ; TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { recoveryName = "<STR_LIT>" ; Intent intent = new Intent ( Intent . ACTION_GET_CONTENT ) ; intent . setDataAndType ( Uri . fromFile ( new File ( "<STR_LIT>" ) ) , "<STR_LIT>" ) ; startActivityForResult ( intent , REQUEST_CODE_PICK_RECOVERY ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { } } ) . show ( ) ; return true ; case <NUM_LIT:6> : Intent intent = new Intent ( Intent . ACTION_GET_CONTENT ) ; intent . setDataAndType ( Uri . fromFile ( new File ( "<STR_LIT>" ) ) , "<STR_LIT>" ) ; startActivityForResult ( intent , REQUEST_CODE_PICK_OTHER ) ; return true ; case <NUM_LIT:7> : System . exit ( <NUM_LIT:0> ) ; return true ; } return super . onOptionsItemSelected ( item ) ; } public void myClickHandler ( View view ) { textView . setGravity ( <NUM_LIT> ) ; switch ( view . getId ( ) ) { case R . id . BacksideUpdaterButton : try { if ( ALREADY_CHECKED == <NUM_LIT:0> ) { ALREADY_CHECKED = <NUM_LIT:1> ; textView . setText ( "<STR_LIT>" ) ; checkStatus ( ) ; } else { if ( ALREADY_CHECKED == <NUM_LIT:1> ) { if ( upToDate && ! alreadyDownloaded ) { System . exit ( <NUM_LIT:0> ) ; } else { ALREADY_CHECKED = <NUM_LIT:2> ; downloadUpdateNow ( ) ; } } else { if ( ! checkFileSize ( romName ) ) { textView . setText ( "<STR_LIT>" ) ; checkMD5 ( localFileName , false ) ; } else { ALREADY_CHECKED = <NUM_LIT:2> ; String tempFile = "<STR_LIT>" + localFileName ; final String badFileName = localFileName . substring ( <NUM_LIT:0> , localFileName . length ( ) - <NUM_LIT:3> ) + "<STR_LIT>" ; final String badFile = ( badFileName . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) ? badFileName : "<STR_LIT>" + badFileName ; final File fBad = new File ( badFile ) ; if ( fBad . exists ( ) ) { tempFile = badFile ; } final String file = tempFile ; final File f = new File ( file ) ; if ( f . exists ( ) ) { final ProgressDialog downloadDialog = new ProgressDialog ( theView ) ; downloadDialog . setCancelable ( false ) ; downloadDialog . setProgressStyle ( ProgressDialog . STYLE_HORIZONTAL ) ; downloadDialog . setProgress ( <NUM_LIT:0> ) ; downloadDialog . setMax ( <NUM_LIT:100> ) ; downloadDialog . setMessage ( "<STR_LIT>" + romName + "<STR_LIT>" ) ; downloadDialog . setOnDismissListener ( new OnDismissListener ( ) { public void onDismiss ( DialogInterface dialog ) { final File fProgress = new File ( file ) ; final int progressFileSize = ( int ) ( fProgress . length ( ) ) / <NUM_LIT> / <NUM_LIT> ; int percentageDownloaded = ( progressFileSize * <NUM_LIT:100> / Integer . parseInt ( theFileSize ) ) ; if ( percentageDownloaded >= <NUM_LIT:100> ) { try { textView . setText ( "<STR_LIT>" ) ; checkMD5 ( file , false ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } } ) ; final Handler downloadProgressHandler = new Handler ( ) { public void handleMessage ( Message msg ) { final File fProgress = new File ( file ) ; final int progressFileSize = ( int ) ( fProgress . length ( ) ) / <NUM_LIT> / <NUM_LIT> ; int percentageDownloaded = ( progressFileSize * <NUM_LIT:100> / Integer . parseInt ( theFileSize ) ) ; downloadDialog . setProgress ( percentageDownloaded ) ; } } ; downloadDialog . show ( ) ; Thread downloadProgress = new Thread ( new Runnable ( ) { public void run ( ) { try { while ( downloadDialog . getProgress ( ) < downloadDialog . getMax ( ) ) { Thread . sleep ( <NUM_LIT> ) ; downloadProgressHandler . sendMessage ( downloadProgressHandler . obtainMessage ( ) ) ; } Thread . sleep ( <NUM_LIT> ) ; } catch ( java . lang . InterruptedException e ) { showCustomToast ( e . toString ( ) ) ; } downloadDialog . dismiss ( ) ; } } ) ; downloadProgress . start ( ) ; textView . setText ( "<STR_LIT>" ) ; } else { ALREADY_CHECKED = <NUM_LIT:1> ; showCustomToast ( "<STR_LIT>" ) ; textView . setText ( "<STR_LIT>" ) ; buttonTextView . setText ( "<STR_LIT>" ) ; } } } } } catch ( Exception e ) { textView . setText ( e . getMessage ( ) ) ; } break ; } } private boolean isNetworkAvailable ( ) { ConnectivityManager connectivityManager = ( ConnectivityManager ) getSystemService ( Context . CONNECTIVITY_SERVICE ) ; NetworkInfo activeNetworkInfo = connectivityManager . getActiveNetworkInfo ( ) ; return activeNetworkInfo != null ; } public void checkManifest ( ) { if ( isNetworkAvailable ( ) ) { final ProgressDialog manifestDialog = ProgressDialog . show ( this , "<STR_LIT>" , "<STR_LIT>" , true ) ; if ( ! alreadyDownloaded ) { manifestDialog . setOnDismissListener ( new OnDismissListener ( ) { public void onDismiss ( DialogInterface dialog ) { if ( line != null ) { checkStatus ( ) ; } else { checkManifest ( ) ; } } } ) ; } new Thread ( new Runnable ( ) { public void run ( ) { BufferedReader rd = null ; try { String lines = "<STR_LIT>" ; line = "<STR_LIT>" ; HttpClient client = new DefaultHttpClient ( ) ; HttpGet request = new HttpGet ( manifestURL ) ; HttpResponse response = client . execute ( request ) ; rd = new BufferedReader ( new InputStreamReader ( response . getEntity ( ) . getContent ( ) ) ) ; while ( ( lines = rd . readLine ( ) ) != null ) { line = line + lines ; } } catch ( IOException e ) { textView . setText ( e . getMessage ( ) ) ; } finally { try { rd . close ( ) ; } catch ( Exception e ) { } rd = null ; } manifestDialog . dismiss ( ) ; return ; } } ) . start ( ) ; buttonTextView . setText ( "<STR_LIT>" ) ; } else { TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setIcon ( R . drawable . md5_error ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { startActivity ( new Intent ( Settings . ACTION_WIRELESS_SETTINGS ) ) ; System . exit ( <NUM_LIT:0> ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { System . exit ( <NUM_LIT:0> ) ; } } ) . show ( ) ; } } private void showExtendedManifest ( ) { final String [ ] oldManifest = line . split ( "<STR_LIT>" ) ; final int versionLength = oldManifest . length ; final String [ ] oldVersion = new String [ versionLength ] ; int cntr = <NUM_LIT:0> ; for ( String i : oldManifest ) { String [ ] nextVersion = i . split ( "<STR_LIT:U+002C>" ) ; String thisRomDate = nextVersion [ <NUM_LIT:0> ] . substring ( <NUM_LIT:4> , <NUM_LIT:8> ) + nextVersion [ <NUM_LIT:0> ] . substring ( <NUM_LIT:0> , <NUM_LIT:4> ) ; if ( cntr == <NUM_LIT:0> ) { oldVersion [ cntr ] = thisRomDate + "<STR_LIT>" ; } else if ( ( cntr == versionLength - <NUM_LIT:1> ) && ( nextVersion [ <NUM_LIT:4> ] . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) ) { oldVersion [ cntr ] = thisRomDate + "<STR_LIT>" ; } else { oldVersion [ cntr ] = thisRomDate ; } cntr ++ ; } new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setItems ( oldVersion , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int item ) { choosenDate = item ; checkStatus ( ) ; } } ) . show ( ) ; } private void checkStatus ( ) { ALREADY_CHECKED = <NUM_LIT:1> ; textView . setText ( "<STR_LIT>" ) ; String [ ] romVersions = line . split ( "<STR_LIT>" ) ; String [ ] separated = romVersions [ choosenDate ] . split ( "<STR_LIT:U+002C>" ) ; theDate = separated [ <NUM_LIT:0> ] ; theUrl = separated [ <NUM_LIT:1> ] ; theChangeLog = separated [ <NUM_LIT:2> ] . replace ( "<STR_LIT:-->" , "<STR_LIT>" ) ; theMD5 = separated [ <NUM_LIT:3> ] ; romName = separated [ <NUM_LIT:4> ] ; localFileName = "<STR_LIT>" + romName ; theFileSize = separated [ <NUM_LIT:5> ] ; upToDate = ( BUILD_DATE >= Integer . parseInt ( theDate ) && choosenDate == <NUM_LIT:0> ) ; if ( upToDate ) { buttonTextView . setVisibility ( <NUM_LIT:4> ) ; } else { buttonTextView . setVisibility ( <NUM_LIT:0> ) ; } String file = ( localFileName . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) ? localFileName : "<STR_LIT>" + localFileName ; String badFile = file . substring ( <NUM_LIT:0> , file . length ( ) - <NUM_LIT:3> ) + "<STR_LIT>" ; File fBad = new File ( badFile ) ; if ( fBad . exists ( ) ) { try { Runtime . getRuntime ( ) . exec ( "<STR_LIT>" + badFile + "<STR_LIT:U+0020>" + file ) ; Thread . sleep ( <NUM_LIT:10> ) ; } catch ( IOException e ) { showCustomToast ( "<STR_LIT>" + e . toString ( ) ) ; } catch ( InterruptedException ee ) { showCustomToast ( "<STR_LIT>" + ee . toString ( ) ) ; } } final File f = new File ( file ) ; if ( ! upToDate ) { if ( f . exists ( ) ) { if ( ! checkFileSize ( romName ) ) { showCustomToast ( "<STR_LIT>" ) ; textView . setText ( "<STR_LIT>" ) ; buttonTextView . setText ( "<STR_LIT>" ) ; ALREADY_CHECKED = <NUM_LIT:2> ; } else { showCustomToast ( "<STR_LIT>" ) ; textView . setText ( "<STR_LIT>" ) ; buttonTextView . setText ( "<STR_LIT>" ) ; ALREADY_CHECKED = <NUM_LIT:2> ; } } else { textView . setGravity ( <NUM_LIT:3> ) ; textView . setText ( "<STR_LIT>" + romName + "<STR_LIT>" + theChangeLog ) ; if ( choosenDate == <NUM_LIT:0> ) { showCustomToast ( "<STR_LIT>" + romName ) ; } else if ( ( choosenDate == ( romVersions . length - <NUM_LIT:1> ) ) && ( romName . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) ) { showCustomToast ( "<STR_LIT>" + theDate ) ; } else { showCustomToast ( "<STR_LIT>" + romName ) ; } buttonTextView . setText ( "<STR_LIT>" ) ; } } else { textView . setText ( "<STR_LIT>" + BUILD_DATE + "<STR_LIT>" + theDate + "<STR_LIT>" ) ; buttonTextView . setText ( "<STR_LIT>" ) ; } } public void alreadyDownloadedHandler ( ) { textView . setGravity ( <NUM_LIT> ) ; try { alreadyDownloaded = true ; ALREADY_CHECKED = <NUM_LIT:2> ; String [ ] romVersions = line . split ( "<STR_LIT>" ) ; String [ ] separated = romVersions [ choosenDate ] . split ( "<STR_LIT:U+002C>" ) ; theDate = separated [ <NUM_LIT:0> ] ; theUrl = separated [ <NUM_LIT:1> ] ; theChangeLog = separated [ <NUM_LIT:2> ] . replace ( "<STR_LIT:-->" , "<STR_LIT>" ) ; theMD5 = separated [ <NUM_LIT:3> ] ; romName = separated [ <NUM_LIT:4> ] ; theFileSize = separated [ <NUM_LIT:5> ] ; upToDate = ( BUILD_DATE >= Integer . parseInt ( theDate ) ) ; Intent intent = new Intent ( Intent . ACTION_GET_CONTENT ) ; intent . setDataAndType ( Uri . fromFile ( new File ( "<STR_LIT>" ) ) , "<STR_LIT>" ) ; startActivityForResult ( intent , REQUEST_CODE_PICK_FILE ) ; } catch ( Exception e ) { textView . setText ( e . getMessage ( ) ) ; } } public static void downloadUpdateNow ( ) { Intent downloadUpdate = new Intent ( Intent . ACTION_VIEW ) ; downloadUpdate . setData ( Uri . parse ( theUrl ) ) ; theView . startActivity ( downloadUpdate ) ; textView . setText ( "<STR_LIT>" ) ; buttonTextView . setText ( "<STR_LIT>" ) ; } private static void md5Dialog ( final String fileName , final Boolean downloaded ) { if ( goodMD5 ) { TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setIcon ( R . drawable . download_complete_icon ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; RebootList ( fileName ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; } } ) . show ( ) ; } else { buttonTextView . setVisibility ( <NUM_LIT:0> ) ; TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" + downloadMD5 + "<STR_LIT>" + theMD5 + "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setIcon ( R . drawable . md5_error ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { ALREADY_CHECKED = <NUM_LIT:2> ; textView . setText ( "<STR_LIT>" ) ; buttonTextView . setText ( "<STR_LIT>" ) ; File f = new File ( fileName ) ; f . delete ( ) ; downloadUpdateNow ( ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; System . exit ( <NUM_LIT:0> ) ; } } ) . show ( ) ; } } public static String checkMD5 ( final String fileName , Boolean downloaded ) throws IOException { String tempFileName = "<STR_LIT>" ; if ( fileName . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) { tempFileName = fileName . substring ( <NUM_LIT:0> , fileName . length ( ) - <NUM_LIT:3> ) + "<STR_LIT>" ; Runtime . getRuntime ( ) . exec ( "<STR_LIT>" + fileName + "<STR_LIT:U+0020>" + tempFileName ) ; } else { tempFileName = fileName ; } final String thisFileName = tempFileName ; if ( thisFileName . substring ( thisFileName . length ( ) - <NUM_LIT:3> ) . equalsIgnoreCase ( "<STR_LIT>" ) || thisFileName . substring ( thisFileName . length ( ) - <NUM_LIT:3> ) . equalsIgnoreCase ( "<STR_LIT>" ) ) { md5FileName = ( thisFileName . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) ? thisFileName : "<STR_LIT>" + thisFileName ; buttonTextView . setVisibility ( <NUM_LIT:4> ) ; textView . setText ( "<STR_LIT>" ) ; final ProgressDialog md5Dialog = ProgressDialog . show ( theView , "<STR_LIT>" , "<STR_LIT>" , true ) ; md5Dialog . setOnDismissListener ( new OnDismissListener ( ) { public void onDismiss ( DialogInterface dialog ) { if ( thisFileName . substring ( thisFileName . length ( ) - <NUM_LIT:3> ) . equalsIgnoreCase ( "<STR_LIT>" ) ) { md5Dialog ( thisFileName , true ) ; } else if ( thisFileName . substring ( thisFileName . length ( ) - <NUM_LIT:3> ) . equalsIgnoreCase ( "<STR_LIT>" ) ) { installRecovery ( thisFileName ) ; } } } ) ; new Thread ( new Runnable ( ) { public void run ( ) { try { String calculatedDigest = calculateMD5 ( md5FileName ) ; if ( calculatedDigest == null ) { goodMD5 = false ; textView . setText ( "<STR_LIT>" ) ; } goodMD5 = calculatedDigest . equalsIgnoreCase ( theMD5 ) ; } catch ( IOException e ) { showCustomToast ( e . getMessage ( ) ) ; textView . setText ( e . getMessage ( ) ) ; } catch ( NullPointerException e2 ) { showCustomToast ( e2 . getMessage ( ) ) ; } md5Dialog . dismiss ( ) ; return ; } } ) . start ( ) ; } else { badFilePath ( <NUM_LIT:0> ) ; } return "<STR_LIT>" ; } public static String calculateMD5 ( String fileName ) throws IOException { downloadMD5 = "<STR_LIT>" ; if ( fileName != null && ! fileName . toString ( ) . equals ( "<STR_LIT>" ) ) { java . lang . Process process = Runtime . getRuntime ( ) . exec ( "<STR_LIT>" + fileName ) ; BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( process . getInputStream ( ) ) ) ; String [ ] results = bufferedReader . readLine ( ) . split ( "<STR_LIT:U+0020>" ) ; try { bufferedReader . close ( ) ; } catch ( Exception e ) { } bufferedReader = null ; downloadMD5 = results [ <NUM_LIT:0> ] ; } return downloadMD5 ; } public static void RebootRecovery ( ) { TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; PowerManager pm = ( PowerManager ) theView . getSystemService ( Context . POWER_SERVICE ) ; pm . reboot ( "<STR_LIT>" ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; } } ) . show ( ) ; } public static void RebootList ( String theFileName ) { showCustomToast ( "<STR_LIT>" ) ; final String rebootFileName = theFileName ; final String [ ] rebootOptions = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; } } ) . setItems ( rebootOptions , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int item ) { RebootCmd ( rebootFileName , item ) ; } } ) . show ( ) ; } public static void RebootCmd ( String theFileName , int rebootMethod ) { String updateFileName = "<STR_LIT>" ; if ( theFileName . indexOf ( "<STR_LIT>" ) < <NUM_LIT:0> ) { updateFileName = "<STR_LIT>" + theFileName ; } else { updateFileName = theFileName ; } if ( theFileName . indexOf ( "<STR_LIT>" ) >= <NUM_LIT:0> ) { String [ ] fixFileName = theFileName . split ( "<STR_LIT>" ) ; updateFileName = fixFileName [ fixFileName . length - <NUM_LIT:1> ] ; } else { updateFileName = theFileName ; } String theUpdateFileName = updateFileName ; String recoveryUpdateString = "<STR_LIT>" ; if ( rebootMethod == <NUM_LIT:1> ) { recoveryUpdateString = "<STR_LIT>" + theUpdateFileName + "<STR_LIT>" ; textView . setText ( "<STR_LIT>" ) ; } if ( rebootMethod == <NUM_LIT:2> ) { recoveryUpdateString = "<STR_LIT>" + theUpdateFileName + "<STR_LIT>" ; textView . setText ( "<STR_LIT>" ) ; } if ( rebootMethod == <NUM_LIT:3> ) { recoveryUpdateString = "<STR_LIT>" ; textView . setText ( "<STR_LIT>" ) ; } if ( rebootMethod == <NUM_LIT:4> ) { recoveryUpdateString = "<STR_LIT>" + theUpdateFileName + "<STR_LIT>" ; textView . setText ( "<STR_LIT>" + theUpdateFileName + "<STR_LIT:...>" ) ; } BufferedReader bufferedReader = null ; String results = "<STR_LIT>" ; if ( rebootMethod == <NUM_LIT:0> ) { textView . setText ( "<STR_LIT>" ) ; PowerManager pm = ( PowerManager ) theView . getSystemService ( Context . POWER_SERVICE ) ; pm . reboot ( "<STR_LIT>" ) ; } else { try { String [ ] str1 = { "<STR_LIT>" , "<STR_LIT>" , recoveryUpdateString } ; java . lang . Process process = Runtime . getRuntime ( ) . exec ( str1 ) ; bufferedReader = new BufferedReader ( new InputStreamReader ( process . getInputStream ( ) ) ) ; results = bufferedReader . readLine ( ) ; } catch ( Exception e ) { showCustomToast ( e . toString ( ) + "<STR_LIT:U+0020>" + results ) ; } finally { if ( results == null ) { Handler handler = new Handler ( ) ; handler . postDelayed ( new Runnable ( ) { public void run ( ) { File testFile = new File ( "<STR_LIT>" ) ; if ( testFile . exists ( ) ) { PowerManager pm = ( PowerManager ) theView . getSystemService ( Context . POWER_SERVICE ) ; pm . reboot ( "<STR_LIT>" ) ; } else { textView . setText ( "<STR_LIT>" ) ; showCustomToast ( "<STR_LIT>" ) ; } } } , <NUM_LIT> ) ; } else { showCustomToast ( results ) ; } try { bufferedReader . close ( ) ; } catch ( Exception e ) { } bufferedReader = null ; } } } public static boolean checkFileSize ( String fileName ) { String testFileName = fileName ; if ( fileName . indexOf ( "<STR_LIT>" ) == - <NUM_LIT:1> ) { testFileName = "<STR_LIT>" + localFileName ; } try { File file = new File ( testFileName ) ; fileSize = file . length ( ) / <NUM_LIT> / <NUM_LIT> ; return ( fileSize < Long . valueOf ( theFileSize ) ) ; } catch ( Exception e ) { showCustomToast ( e . toString ( ) ) ; return false ; } } private static String badFilePath ( int whichFileType ) { if ( whichFileType == <NUM_LIT:0> ) { textView . setText ( "<STR_LIT>" ) ; } else { textView . setText ( "<STR_LIT>" ) ; } return "<STR_LIT>" ; } public static void showCustomToast ( String str ) { Toast toast = Toast . makeText ( theView , str , Toast . LENGTH_LONG ) ; toast . setGravity ( Gravity . CENTER , <NUM_LIT:0> , <NUM_LIT:0> ) ; LinearLayout toastView = ( LinearLayout ) toast . getView ( ) ; ImageView customIcon = new ImageView ( theView ) ; customIcon . setImageResource ( R . drawable . custom_update_dialog_icon ) ; toastView . addView ( customIcon , <NUM_LIT:0> ) ; toast . show ( ) ; } public static void recoveryFinishedDialog ( ) { String [ ] rmsg = lastRecoveryMessage . split ( "<STR_LIT:U+0020>" ) ; if ( rmsg [ <NUM_LIT:0> ] . equals ( "<STR_LIT>" ) && recoveryStepCount > <NUM_LIT:20> ) { TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" + recoveryName + "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setIcon ( R . drawable . icon_installing ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; RebootRecovery ( ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; } } ) . show ( ) ; } else { TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" + recoveryName + "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setIcon ( R . drawable . md5_error ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { System . exit ( <NUM_LIT:0> ) ; } } ) . show ( ) ; } } public static String installRecovery ( final String recoveryFile ) { String theFileName = "<STR_LIT>" ; if ( recoveryFile . indexOf ( "<STR_LIT>" ) < <NUM_LIT:0> ) { theFileName = "<STR_LIT>" + recoveryFile ; } else { theFileName = recoveryFile ; } final String thisFileName = theFileName ; if ( thisFileName . substring ( thisFileName . length ( ) - <NUM_LIT:3> ) . equalsIgnoreCase ( "<STR_LIT>" ) ) { TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" + recoveryFile + "<STR_LIT:n>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { doInstallRecovery ( thisFileName ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setGravity ( Gravity . CENTER ) ; textView . setText ( "<STR_LIT>" ) ; } } ) . show ( ) ; } else { badFilePath ( <NUM_LIT:1> ) ; } return "<STR_LIT>" ; } public static String doInstallRecovery ( final String recoveryFile ) { recoveryName = recoveryFile ; final ProgressDialog recoveryDialog = ProgressDialog . show ( theView , "<STR_LIT>" , "<STR_LIT>" + recoveryName + "<STR_LIT:...>" , true ) ; recoveryDialog . setOnDismissListener ( new OnDismissListener ( ) { public void onDismiss ( DialogInterface dialog ) { recoveryFinishedDialog ( ) ; } } ) ; final Handler progressHandler = new Handler ( ) { public void handleMessage ( Message msg ) { textView . setGravity ( <NUM_LIT> ) ; textView . setText ( recoveryMessage ) ; } } ; new Thread ( new Runnable ( ) { public void run ( ) { String [ ] str = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + recoveryName } ; StringBuffer outputStr = new StringBuffer ( ) ; String readInput ; String readOutput ; try { java . lang . Process process = Runtime . getRuntime ( ) . exec ( str ) ; BufferedReader outputReader = new BufferedReader ( new InputStreamReader ( process . getErrorStream ( ) ) ) ; while ( ( readOutput = outputReader . readLine ( ) ) != null ) { outputStr . append ( readOutput . toString ( ) + "<STR_LIT:n>" ) ; progressHandler . sendMessage ( progressHandler . obtainMessage ( ) ) ; recoveryStepCount ++ ; recoveryMessage = outputStr . toString ( ) ; lastRecoveryMessage = readOutput . toString ( ) ; } BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( process . getInputStream ( ) ) ) ; while ( ( readInput = bufferedReader . readLine ( ) ) != null ) { outputStr . append ( readInput . toString ( ) + "<STR_LIT:n>" ) ; progressHandler . sendMessage ( progressHandler . obtainMessage ( ) ) ; recoveryMessage = outputStr . toString ( ) ; lastRecoveryMessage = readInput . toString ( ) ; } bufferedReader . close ( ) ; } catch ( IOException e ) { System . err . print ( e ) ; recoveryMessage = outputStr . toString ( ) + "<STR_LIT:U+0020>" + e . getMessage ( ) ; } recoveryDialog . dismiss ( ) ; return ; } } ) . start ( ) ; return "<STR_LIT>" ; } public void backupRestoreDialog ( ) { showCustomToast ( "<STR_LIT>" ) ; TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { RebootCmd ( "<STR_LIT>" , <NUM_LIT:3> ) ; } } ) . setNeutralButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { showRestoreList ( ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setGravity ( Gravity . CENTER ) ; textView . setText ( "<STR_LIT>" ) ; } } ) . show ( ) ; } public static String showRestoreList ( ) { File f = new File ( "<STR_LIT>" ) ; final String [ ] files = f . list ( ) ; if ( files == null ) { showCustomToast ( "<STR_LIT>" ) ; } else { new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setText ( "<STR_LIT>" ) ; } } ) . setItems ( files , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int item ) { restoreBackup ( ( "<STR_LIT>" + files [ item ] ) , <NUM_LIT:4> ) ; } } ) . show ( ) ; } return "<STR_LIT>" ; } public static String restoreBackup ( String theFileName , int recoverytype ) { final String restoreFile = theFileName ; final int recoveryFlag = recoverytype ; TextView myMsg = new TextView ( theView ) ; myMsg . setText ( "<STR_LIT>" + theFileName + "<STR_LIT>" ) ; myMsg . setGravity ( Gravity . CENTER_HORIZONTAL ) ; new AlertDialog . Builder ( theView ) . setTitle ( "<STR_LIT>" ) . setView ( myMsg ) . setPositiveButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { RebootCmd ( restoreFile , recoveryFlag ) ; } } ) . setNegativeButton ( "<STR_LIT>" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { textView . setGravity ( Gravity . CENTER ) ; textView . setText ( "<STR_LIT>" ) ; } } ) . show ( ) ; return "<STR_LIT>" ; } public static String installOtherROM ( String theFileName ) { RebootList ( theFileName ) ; return "<STR_LIT>" ; } @ Override protected void onActivityResult ( int requestCode , int resultCode , Intent data ) { super . onActivityResult ( requestCode , resultCode , data ) ; if ( resultCode == RESULT_OK ) { if ( requestCode == <NUM_LIT> || requestCode == <NUM_LIT:1000> || requestCode == <NUM_LIT> ) { if ( data != null ) { try { Uri fileUri = data . getData ( ) ; if ( fileUri != null && ! fileUri . toString ( ) . equals ( "<STR_LIT>" ) ) { String filePath = fileUri . getPath ( ) ; if ( filePath != null ) { Intent checkDownloadedMD5 = new Intent ( ) ; try { if ( requestCode == <NUM_LIT> ) { checkDownloadedMD5 . setAction ( com . Backside . BacksideUpdater . BacksideUpdaterActivity . checkMD5 ( filePath , true ) ) ; } else if ( requestCode == <NUM_LIT:1000> ) { buttonTextView . setVisibility ( <NUM_LIT:4> ) ; checkDownloadedMD5 . setAction ( com . Backside . BacksideUpdater . BacksideUpdaterActivity . installRecovery ( filePath ) ) ; } else if ( requestCode == <NUM_LIT> ) { buttonTextView . setVisibility ( <NUM_LIT:4> ) ; checkDownloadedMD5 . setAction ( com . Backside . BacksideUpdater . BacksideUpdaterActivity . installOtherROM ( filePath ) ) ; } } catch ( IOException e ) { checkDownloadedMD5 . setAction ( com . Backside . BacksideUpdater . BacksideUpdaterActivity . badFilePath ( <NUM_LIT:0> ) ) ; } sendBroadcast ( checkDownloadedMD5 ) ; } } } catch ( Exception e ) { textView . setText ( "<STR_LIT>" + e . getMessage ( ) ) ; } } else { badFilePath ( <NUM_LIT:0> ) ; } } } } } </s>
<s> package com ; import java . text . ParseException ; import java . util . Calendar ; import java . util . Date ; public class CompareDate { public static String compareYMD ( Date src , Date dst ) { Calendar srcCal = Calendar . getInstance ( ) ; srcCal . setTime ( src ) ; Calendar dstCal = Calendar . getInstance ( ) ; dstCal . setTime ( dst ) ; int year = dstCal . get ( Calendar . YEAR ) - srcCal . get ( Calendar . YEAR ) ; int month = dstCal . get ( Calendar . MONTH ) - srcCal . get ( Calendar . MONTH ) ; int day = dstCal . get ( Calendar . DAY_OF_MONTH ) - srcCal . get ( Calendar . DAY_OF_MONTH ) ; year = year - ( ( month > <NUM_LIT:0> ) ? <NUM_LIT:0> : ( ( month < <NUM_LIT:0> ) ? <NUM_LIT:1> : ( ( day >= <NUM_LIT:0> ? <NUM_LIT:0> : <NUM_LIT:1> ) ) ) ) ; month = ( month <= <NUM_LIT:0> ) ? ( day > <NUM_LIT:0> ? <NUM_LIT:12> + month : <NUM_LIT:12> + month - <NUM_LIT:1> ) : ( day >= <NUM_LIT:0> ? month : month - <NUM_LIT:1> ) ; dstCal . add ( Calendar . MONTH , - <NUM_LIT:1> ) ; day = ( day <= <NUM_LIT:0> ) ? ( perMonthDays ( dstCal ) ) + day : day ; String ages = year + "<STR_LIT>" + month + "<STR_LIT>" + day + "<STR_LIT>" ; return ages ; } public static int perMonthDays ( Calendar cal ) { int maxDays = <NUM_LIT:0> ; int month = cal . get ( Calendar . MONTH ) ; switch ( month ) { case Calendar . JANUARY : case Calendar . MARCH : case Calendar . MAY : case Calendar . JULY : case Calendar . AUGUST : case Calendar . OCTOBER : case Calendar . DECEMBER : maxDays = <NUM_LIT:31> ; break ; case Calendar . APRIL : case Calendar . JUNE : case Calendar . SEPTEMBER : case Calendar . NOVEMBER : maxDays = <NUM_LIT:30> ; break ; case Calendar . FEBRUARY : if ( isLeap ( cal . get ( Calendar . YEAR ) ) ) { maxDays = <NUM_LIT> ; } else { maxDays = <NUM_LIT> ; } break ; } return maxDays ; } public static boolean isLeap ( int year ) { boolean leap = false ; if ( ( year % <NUM_LIT:4> == <NUM_LIT:0> && year % <NUM_LIT:100> != <NUM_LIT:0> ) || ( year % <NUM_LIT> == <NUM_LIT:0> ) ) { leap = true ; } return leap ; } public static void main ( String [ ] args ) throws ParseException { Date now = new Date ( ) ; Date birthdy = new Date ( <NUM_LIT> - <NUM_LIT> , <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT> ) ; String ages = compareYMD ( birthdy , now ) ; System . out . println ( ages ) ; } } </s>
<s> package com . sk89q . minerhat ; import bsh . EvalError ; import bsh . Interpreter ; import bsh . util . NameCompletionTable ; import java . awt . Color ; import java . awt . Font ; import java . io . File ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . Reader ; import javax . swing . JOptionPane ; import javax . swing . tree . DefaultMutableTreeNode ; import javax . swing . tree . DefaultTreeModel ; public class MinecraftProxyFrame extends javax . swing . JFrame { private static final long serialVersionUID = <NUM_LIT> ; private MinecraftProxyServerClient client ; private DefaultTreeModel statsTreeModel ; private DefaultMutableTreeNode statsRoot ; private Font consoleFont = new Font ( "<STR_LIT>" , Font . PLAIN , <NUM_LIT:11> ) ; private Interpreter interpreter ; public MinecraftProxyFrame ( MinecraftProxyServerClient client ) { this . client = client ; initStatsTree ( ) ; initComponents ( ) ; console . setFont ( consoleFont ) ; logDisplay . setFont ( consoleFont ) ; setDefaultCloseOperation ( DISPOSE_ON_CLOSE ) ; statsTree . expandRow ( <NUM_LIT:0> ) ; initConsole ( ) ; } private void initStatsTree ( ) { statsRoot = new DefaultMutableTreeNode ( "<STR_LIT>" ) ; statsTreeModel = new DefaultTreeModel ( statsRoot ) ; DefaultMutableTreeNode node = new DefaultMutableTreeNode ( "<STR_LIT>" + client . getLoggerId ( ) ) ; statsRoot . add ( node ) ; } private void initConsole ( ) { interpreter = new Interpreter ( console ) ; NameCompletionTable nct = new NameCompletionTable ( ) ; nct . add ( interpreter . getNameSpace ( ) ) ; console . setNameCompletion ( nct ) ; new Thread ( interpreter ) . start ( ) ; try { interpreter . set ( "<STR_LIT>" , client ) ; } catch ( EvalError e ) { log ( e . getMessage ( ) ) ; } try { interpreter . eval ( "<STR_LIT>" ) ; interpreter . eval ( "<STR_LIT>" ) ; interpreter . eval ( "<STR_LIT>" ) ; } catch ( EvalError ex ) { } } public void log ( String text ) { logDisplay . append ( text + "<STR_LIT>" ) ; logDisplay . setCaretPosition ( logDisplay . getText ( ) . length ( ) - <NUM_LIT:1> ) ; } public void handleEndedConnection ( ) { miClose . setEnabled ( false ) ; } public void addStatistic ( String label , String text ) { DefaultMutableTreeNode seedNode = new DefaultMutableTreeNode ( label + "<STR_LIT::U+0020>" + text ) ; statsTreeModel . insertNodeInto ( seedNode , statsRoot , statsRoot . getChildCount ( ) ) ; } private void initComponents ( ) { jSplitPane1 = new javax . swing . JSplitPane ( ) ; jScrollPane1 = new javax . swing . JScrollPane ( ) ; logDisplay = new javax . swing . JTextArea ( ) ; jTabbedPane1 = new javax . swing . JTabbedPane ( ) ; console = new bsh . util . JConsole ( ) ; jScrollPane2 = new javax . swing . JScrollPane ( ) ; statsTree = new javax . swing . JTree ( ) ; jMenuBar1 = new javax . swing . JMenuBar ( ) ; jMenu1 = new javax . swing . JMenu ( ) ; miClose = new javax . swing . JMenuItem ( ) ; jMenu2 = new javax . swing . JMenu ( ) ; miEvalBSH = new javax . swing . JMenuItem ( ) ; setDefaultCloseOperation ( javax . swing . WindowConstants . EXIT_ON_CLOSE ) ; jSplitPane1 . setDividerLocation ( <NUM_LIT> ) ; jSplitPane1 . setDividerSize ( <NUM_LIT:2> ) ; jSplitPane1 . setOrientation ( javax . swing . JSplitPane . VERTICAL_SPLIT ) ; logDisplay . setColumns ( <NUM_LIT:20> ) ; logDisplay . setEditable ( false ) ; logDisplay . setFont ( new java . awt . Font ( "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:11> ) ) ; logDisplay . setRows ( <NUM_LIT:5> ) ; logDisplay . setTabSize ( <NUM_LIT:4> ) ; jScrollPane1 . setViewportView ( logDisplay ) ; jSplitPane1 . setBottomComponent ( jScrollPane1 ) ; console . setWaitFeedback ( true ) ; jTabbedPane1 . addTab ( "<STR_LIT>" , console ) ; statsTree . setModel ( statsTreeModel ) ; statsTree . setShowsRootHandles ( true ) ; jScrollPane2 . setViewportView ( statsTree ) ; jTabbedPane1 . addTab ( "<STR_LIT>" , jScrollPane2 ) ; jSplitPane1 . setLeftComponent ( jTabbedPane1 ) ; jMenu1 . setText ( "<STR_LIT>" ) ; miClose . setAccelerator ( javax . swing . KeyStroke . getKeyStroke ( java . awt . event . KeyEvent . VK_C , java . awt . event . InputEvent . CTRL_MASK ) ) ; miClose . setText ( "<STR_LIT>" ) ; miClose . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { miCloseActionPerformed ( evt ) ; } } ) ; jMenu1 . add ( miClose ) ; jMenuBar1 . add ( jMenu1 ) ; jMenu2 . setText ( "<STR_LIT>" ) ; miEvalBSH . setAccelerator ( javax . swing . KeyStroke . getKeyStroke ( java . awt . event . KeyEvent . VK_B , java . awt . event . InputEvent . CTRL_MASK ) ) ; miEvalBSH . setText ( "<STR_LIT>" ) ; miEvalBSH . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { miEvalBSHActionPerformed ( evt ) ; } } ) ; jMenu2 . add ( miEvalBSH ) ; jMenuBar1 . add ( jMenu2 ) ; setJMenuBar ( jMenuBar1 ) ; javax . swing . GroupLayout layout = new javax . swing . GroupLayout ( getContentPane ( ) ) ; getContentPane ( ) . setLayout ( layout ) ; layout . setHorizontalGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addComponent ( jSplitPane1 , javax . swing . GroupLayout . Alignment . TRAILING , javax . swing . GroupLayout . DEFAULT_SIZE , <NUM_LIT> , Short . MAX_VALUE ) ) ; layout . setVerticalGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addComponent ( jSplitPane1 , javax . swing . GroupLayout . DEFAULT_SIZE , <NUM_LIT> , Short . MAX_VALUE ) ) ; pack ( ) ; } private void miCloseActionPerformed ( java . awt . event . ActionEvent evt ) { client . stop ( ) ; } private void miEvalBSHActionPerformed ( java . awt . event . ActionEvent evt ) { String script = ( String ) JOptionPane . showInputDialog ( this , "<STR_LIT>" , "<STR_LIT>" , JOptionPane . PLAIN_MESSAGE ) ; if ( script != null && script . length ( ) != <NUM_LIT:0> ) { try { File f = new File ( "<STR_LIT>" , script ) ; Reader reader ; try { reader = new FileReader ( f ) ; } catch ( FileNotFoundException e ) { f = new File ( "<STR_LIT>" , script + "<STR_LIT>" ) ; reader = new FileReader ( f ) ; } console . println ( ) ; console . print ( "<STR_LIT>" + f . getAbsoluteFile ( ) + "<STR_LIT:...>" , Color . BLUE ) ; interpreter . eval ( reader ) ; } catch ( EvalError e ) { console . println ( ) ; console . print ( "<STR_LIT>" + e . getMessage ( ) , Color . RED ) ; } catch ( FileNotFoundException e ) { console . println ( ) ; console . print ( "<STR_LIT>" + e . getMessage ( ) , Color . RED ) ; } } } private bsh . util . JConsole console ; private javax . swing . JMenu jMenu1 ; private javax . swing . JMenu jMenu2 ; private javax . swing . JMenuBar jMenuBar1 ; private javax . swing . JScrollPane jScrollPane1 ; private javax . swing . JScrollPane jScrollPane2 ; private javax . swing . JSplitPane jSplitPane1 ; private javax . swing . JTabbedPane jTabbedPane1 ; private javax . swing . JTextArea logDisplay ; private javax . swing . JMenuItem miClose ; private javax . swing . JMenuItem miEvalBSH ; private javax . swing . JTree statsTree ; } </s>
<s> package com . sk89q . minerhat ; import java . text . SimpleDateFormat ; import java . util . Date ; import java . util . logging . * ; public class SimpleLoggerFormatter extends Formatter { private SimpleDateFormat dateFormatter = new SimpleDateFormat ( "<STR_LIT>" ) ; @ Override public String format ( LogRecord rec ) { StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( dateFormatter . format ( new Date ( ) ) ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( rec . getLevel ( ) . getName ( ) ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( rec . getMessage ( ) ) ; buffer . append ( "<STR_LIT>" ) ; Throwable throwable = rec . getThrown ( ) ; if ( throwable != null ) { buffer . append ( throwable . toString ( ) ) ; buffer . append ( "<STR_LIT>" ) ; for ( StackTraceElement element : throwable . getStackTrace ( ) ) { buffer . append ( "<STR_LIT:t>" ) ; buffer . append ( element ) ; buffer . append ( "<STR_LIT>" ) ; } } return buffer . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . EOFException ; import java . io . IOException ; import java . net . InetAddress ; import java . net . Socket ; import java . util . logging . Level ; import java . util . logging . Logger ; import com . sk89q . minerhat . packets . Packet ; import com . sk89q . minerhat . packets . PacketManager ; import com . sk89q . minerhat . packets . PacketManager . UnknownPacketException ; class MinecraftClientConnection implements Runnable { private MinecraftProxyServerClient parent ; private InetAddress host ; private int port ; private boolean running = true ; private Socket sock ; private DataOutputStream out ; private DataInputStream in ; private MinecraftProxyServerClient that ; private static final Logger logger = Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) ; public MinecraftClientConnection ( MinecraftProxyServerClient parent , InetAddress host , int port , MinecraftProxyServerClient minecraftProxyServerClient ) { this . parent = parent ; this . host = host ; this . port = port ; this . that = minecraftProxyServerClient ; } public String getLoggerId ( ) { return sock . getInetAddress ( ) . getHostAddress ( ) + "<STR_LIT::>" + sock . getPort ( ) ; } protected void log ( Level level , final String msg ) { logger . log ( level , "<STR_LIT:(>" + getLoggerId ( ) + "<STR_LIT>" + msg ) ; } protected void log ( Level level , final String msg , Throwable t ) { logger . log ( level , "<STR_LIT:(>" + getLoggerId ( ) + "<STR_LIT>" + msg , t ) ; } public void connect ( ) throws IOException { sock = new Socket ( host , port ) ; sock . setTcpNoDelay ( true ) ; out = new DataOutputStream ( sock . getOutputStream ( ) ) ; in = new DataInputStream ( sock . getInputStream ( ) ) ; } public void run ( ) { try { while ( running ) { byte id = in . readByte ( ) ; Packet packet ; try { if ( ! ( PacketManager . containsID ( id ) ) ) { Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) . log ( Level . SEVERE , "<STR_LIT>" + id + "<STR_LIT>" ) ; continue ; } packet = PacketManager . read ( id , in ) ; packet . toServer = false ; String name = packet . toString ( ) ; that . log ( Level . INFO , "<STR_LIT>" + name ) ; } catch ( UnknownPacketException ex ) { Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; sock . close ( ) ; break ; } parent . handleIncoming ( packet ) ; } } catch ( EOFException e ) { } catch ( IOException e ) { } } public void send ( Packet packet ) throws IOException { out . write ( packet . getId ( ) ) ; packet . write ( out ) ; out . flush ( ) ; } public void stop ( ) { running = false ; try { sock . close ( ) ; } catch ( IOException ex ) { } } } </s>
<s> package com . sk89q . minerhat . util ; public class ItemStack { private int id ; private int count ; private int data ; public ItemStack ( int id , int count , int data ) { this . id = id ; this . count = count ; this . data = data ; } public int getId ( ) { return id ; } public void setId ( int id ) { this . id = id ; } public int getCount ( ) { return count ; } public void setCount ( int count ) { this . count = count ; } public int getDamage ( ) { return data ; } public void setData ( int data ) { this . data = data ; } public String toString ( ) { return "<STR_LIT>" + id + "<STR_LIT>" + count + "<STR_LIT>" + data ; } } </s>
<s> package com . sk89q . minerhat . util ; public class BlockPosition { private int x ; private int y ; private int z ; public BlockPosition ( int x , int y , int z ) { this . x = x ; this . y = y ; this . z = z ; } public int getX ( ) { return x ; } public void setX ( int x ) { this . x = x ; } public int getY ( ) { return y ; } public void setY ( int y ) { this . y = y ; } public int getZ ( ) { return z ; } public void setZ ( int z ) { this . z = z ; } } </s>
<s> package com . sk89q . minerhat ; import java . io . * ; import java . net . * ; import java . util . logging . Level ; import java . util . logging . Logger ; import javax . swing . SwingUtilities ; import com . sk89q . minerhat . packets . Packet1Login ; import com . sk89q . minerhat . packets . Packet ; import com . sk89q . minerhat . packets . PacketManager ; import com . sk89q . minerhat . packets . PacketManager . UnknownPacketException ; public class MinecraftProxyServerClient implements Runnable { public final Object outgoingLock = new Object ( ) ; public final Object incomingLock = new Object ( ) ; private static final Logger logger = Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) ; private boolean running = true ; private MinecraftProxyFrame frame ; private MinecraftProxyServer server ; private Socket sock ; private DataOutputStream out ; private DataInputStream in ; private MinecraftClientConnection client ; public MinecraftProxyServerClient ( MinecraftProxyServer server , Socket sock ) throws IOException { this . server = server ; this . sock = sock ; out = new DataOutputStream ( sock . getOutputStream ( ) ) ; in = new DataInputStream ( sock . getInputStream ( ) ) ; } public MinecraftProxyServer getServer ( ) { return server ; } public String getLoggerId ( ) { return sock . getInetAddress ( ) . getHostAddress ( ) + "<STR_LIT::>" + sock . getPort ( ) ; } protected void log ( Level level , final String msg ) { logger . log ( level , "<STR_LIT:(>" + getLoggerId ( ) + "<STR_LIT>" + msg ) ; SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { frame . log ( msg ) ; } } ) ; } protected void log ( Level level , final String msg , Throwable t ) { logger . log ( level , "<STR_LIT:(>" + getLoggerId ( ) + "<STR_LIT>" + msg , t ) ; SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { frame . log ( msg ) ; } } ) ; } public void run ( ) { client = new MinecraftClientConnection ( this , server . getTargetHost ( ) , server . getTargetPort ( ) , this ) ; frame = new MinecraftProxyFrame ( this ) ; SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { frame . setVisible ( true ) ; frame . setTitle ( "<STR_LIT>" + getLoggerId ( ) ) ; } } ) ; try { log ( Level . INFO , "<STR_LIT>" + server . getTargetHost ( ) + "<STR_LIT:...>" ) ; client . connect ( ) ; Thread thread = new Thread ( client ) ; thread . start ( ) ; log ( Level . INFO , "<STR_LIT>" ) ; while ( running ) { byte id = in . readByte ( ) ; Packet packet ; try { if ( ! ( PacketManager . containsID ( id ) ) ) { Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) . log ( Level . SEVERE , "<STR_LIT>" ) ; Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) . log ( Level . SEVERE , "<STR_LIT>" + id + "<STR_LIT>" ) ; Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) . log ( Level . SEVERE , "<STR_LIT>" ) ; continue ; } packet = PacketManager . read ( id , in ) ; packet . toServer = true ; } catch ( UnknownPacketException ex ) { Logger . getLogger ( MinecraftProxyServerClient . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; sock . close ( ) ; break ; } String name = packet . toString ( ) ; log ( Level . INFO , "<STR_LIT>" + name ) ; try { synchronized ( outgoingLock ) { client . send ( packet ) ; } } catch ( IOException e ) { sock . close ( ) ; log ( Level . INFO , "<STR_LIT>" , e ) ; } } } catch ( EOFException ex ) { } catch ( IOException ex ) { } client . stop ( ) ; log ( Level . INFO , "<STR_LIT>" ) ; SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { frame . handleEndedConnection ( ) ; } } ) ; } public void send ( Packet packet ) throws IOException { synchronized ( outgoingLock ) { client . send ( packet ) ; } } public void receive ( Packet packet ) throws IOException { handleIncoming ( packet ) ; } public void handleIncoming ( Packet packet ) throws IOException { if ( packet instanceof Packet1Login ) { final Packet1Login loginPacket = ( Packet1Login ) packet ; SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { frame . addStatistic ( "<STR_LIT>" , String . valueOf ( loginPacket . mapSeed ) ) ; frame . addStatistic ( "<STR_LIT>" , String . valueOf ( loginPacket . dimension ) ) ; frame . addStatistic ( "<STR_LIT>" , String . valueOf ( loginPacket . version ) ) ; } } ) ; } synchronized ( incomingLock ) { out . write ( packet . getId ( ) ) ; packet . write ( out ) ; } } public void stop ( ) { running = false ; try { sock . close ( ) ; } catch ( IOException ex ) { } } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet101CloseWindow extends Packet { public byte id ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; } @ Override public int length ( ) { return <NUM_LIT:1> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet102WindowClick extends Packet { public byte id ; public short slot ; public byte rightClick ; public short actionNum ; public short itemId ; public byte itemCount ; public short itemUses ; public boolean f ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; this . slot = stream . readShort ( ) ; this . rightClick = stream . readByte ( ) ; this . actionNum = stream . readShort ( ) ; this . f = stream . readBoolean ( ) ; this . itemId = stream . readShort ( ) ; if ( itemId >= <NUM_LIT:0> ) { itemCount = stream . readByte ( ) ; itemUses = stream . readShort ( ) ; } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; stream . writeShort ( this . slot ) ; stream . writeByte ( this . rightClick ) ; stream . writeShort ( this . actionNum ) ; stream . writeBoolean ( this . f ) ; stream . writeShort ( this . itemId ) ; if ( itemId >= <NUM_LIT:0> ) { stream . writeByte ( itemCount ) ; stream . writeShort ( itemUses ) ; } } @ Override public int length ( ) { return <NUM_LIT:11> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet19EntityAction extends Packet { public int eid ; public byte action ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . action = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeByte ( this . action ) ; } @ Override public int length ( ) { return <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import java . util . List ; import com . sk89q . minerhat . packets . MetadataParser . MetadataObject ; public class Packet40EntityMetadata extends Packet { public int eid ; private List < MetadataObject > metadata ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . metadata = MetadataParser . read ( stream ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; MetadataParser . write ( metadata , stream ) ; } @ Override public int length ( ) { return <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet52MultiBlockChange extends Packet { public int chunkX ; public int chunkY ; public short [ ] coordinateArray ; public byte [ ] typeArray ; public byte [ ] metadataArray ; public int arraySize ; @ Override public void read ( DataInputStream stream ) throws IOException { this . chunkX = stream . readInt ( ) ; this . chunkY = stream . readInt ( ) ; this . arraySize = stream . readShort ( ) & '<STR_LIT>' ; this . coordinateArray = new short [ this . arraySize ] ; this . typeArray = new byte [ this . arraySize ] ; this . metadataArray = new byte [ this . arraySize ] ; for ( int i = <NUM_LIT:0> ; i < this . arraySize ; ++ i ) { this . coordinateArray [ i ] = stream . readShort ( ) ; } stream . readFully ( this . typeArray ) ; stream . readFully ( this . metadataArray ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . chunkX ) ; stream . writeInt ( this . chunkY ) ; stream . writeShort ( ( short ) this . arraySize ) ; for ( int i = <NUM_LIT:0> ; i < this . arraySize ; ++ i ) { stream . writeShort ( this . coordinateArray [ i ] ) ; } stream . write ( this . typeArray ) ; stream . write ( this . metadataArray ) ; } @ Override public int length ( ) { return <NUM_LIT:10> + this . arraySize * <NUM_LIT:4> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet130UpdateSign extends Packet { public int x ; public short y ; public int z ; public String [ ] lines ; public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( x ) ; result . append ( "<STR_LIT>" ) ; result . append ( y ) ; result . append ( "<STR_LIT>" ) ; result . append ( z ) ; result . append ( "<STR_LIT>" ) ; result . append ( lines . toString ( ) ) ; return result . toString ( ) ; } @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readShort ( ) ; this . z = stream . readInt ( ) ; this . lines = new String [ <NUM_LIT:4> ] ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; ++ i ) { this . lines [ i ] = read ( stream , <NUM_LIT:15> ) ; } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . writeShort ( this . y ) ; stream . writeInt ( this . z ) ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; ++ i ) { write ( this . lines [ i ] , stream ) ; } } @ Override public int length ( ) { int i = <NUM_LIT:0> ; for ( int j = <NUM_LIT:0> ; j < <NUM_LIT:4> ; ++ j ) { i += this . lines [ j ] . length ( ) ; } return i ; } @ Override public byte getId ( ) { return ( byte ) <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet32EntityLook extends Packet30Entity { public byte dx ; public byte dy ; public byte dz ; public byte yaw ; public byte pitch ; @ Override public void read ( DataInputStream stream ) throws IOException { super . read ( stream ) ; this . yaw = stream . readByte ( ) ; this . pitch = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { super . write ( stream ) ; stream . writeByte ( this . yaw ) ; stream . writeByte ( this . pitch ) ; } @ Override public int length ( ) { return <NUM_LIT:6> ; } @ Override public byte getId ( ) { return <NUM_LIT:32> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet31RelativeEntityMove extends Packet30Entity { public byte dx ; public byte dy ; public byte dz ; @ Override public void read ( DataInputStream stream ) throws IOException { super . read ( stream ) ; this . dx = stream . readByte ( ) ; this . dy = stream . readByte ( ) ; this . dz = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { super . write ( stream ) ; stream . writeByte ( this . dx ) ; stream . writeByte ( this . dy ) ; stream . writeByte ( this . dz ) ; } @ Override public int length ( ) { return <NUM_LIT:7> ; } @ Override public byte getId ( ) { return <NUM_LIT:31> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet103SetSlot extends Packet { public byte id ; public short slot ; public short itemId ; public byte itemCount ; public short itemUses ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; this . slot = stream . readShort ( ) ; this . itemId = stream . readShort ( ) ; if ( itemId >= <NUM_LIT:0> ) { this . itemCount = stream . readByte ( ) ; this . itemUses = stream . readShort ( ) ; } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; stream . writeShort ( this . slot ) ; stream . writeShort ( this . itemId ) ; if ( itemId >= <NUM_LIT:0> ) { stream . writeByte ( this . itemCount ) ; stream . writeShort ( this . itemUses ) ; } } @ Override public int length ( ) { return <NUM_LIT:8> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( id ) ; result . append ( "<STR_LIT>" ) ; result . append ( slot ) ; result . append ( "<STR_LIT>" ) ; result . append ( itemCount ) ; result . append ( "<STR_LIT>" ) ; result . append ( itemId ) ; result . append ( "<STR_LIT>" ) ; result . append ( itemUses ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet12PlayerLook extends Packet10Flying { public float yaw ; public float pitch ; @ Override public void read ( DataInputStream stream ) throws IOException { this . yaw = stream . readFloat ( ) ; this . pitch = stream . readFloat ( ) ; super . read ( stream ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeFloat ( this . yaw ) ; stream . writeFloat ( this . pitch ) ; super . write ( stream ) ; } @ Override public int length ( ) { return <NUM_LIT:9> ; } @ Override public byte getId ( ) { return <NUM_LIT:12> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import com . sk89q . minerhat . util . ItemStack ; public class Packet21PickupSpawn extends Packet { public int eid ; public int x ; public int y ; public int z ; public byte rotation ; public byte pitch ; public byte roll ; public ItemStack item ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . item = new ItemStack ( stream . readShort ( ) , stream . readByte ( ) , stream . readShort ( ) ) ; this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . z = stream . readInt ( ) ; this . rotation = stream . readByte ( ) ; this . pitch = stream . readByte ( ) ; this . roll = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeShort ( this . item . getId ( ) ) ; stream . writeByte ( this . item . getCount ( ) ) ; stream . writeShort ( this . item . getDamage ( ) ) ; stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . writeInt ( this . z ) ; stream . writeByte ( this . rotation ) ; stream . writeByte ( this . pitch ) ; stream . writeByte ( this . roll ) ; } @ Override public int length ( ) { return <NUM_LIT:24> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet2Handshake extends Packet { public String username ; @ Override public void read ( DataInputStream stream ) throws IOException { this . username = read ( stream , <NUM_LIT:32> ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { write ( this . username , stream ) ; } @ Override public int length ( ) { return <NUM_LIT:4> + this . username . length ( ) + <NUM_LIT:4> ; } @ Override public byte getId ( ) { return <NUM_LIT:2> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( username ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet70Bed extends Packet { public int b ; public Packet70Bed ( ) { } @ Override public void read ( DataInputStream stream ) throws IOException { this . b = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . b ) ; } @ Override public int length ( ) { return <NUM_LIT:1> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet18ArmAnimation extends Packet { public int eid ; public int animation ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . animation = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeByte ( this . animation ) ; } @ Override public int length ( ) { return <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet61DoorChange extends Packet { public int a ; public int b ; public int c ; public int d ; public int e ; @ Override public void read ( DataInputStream stream ) throws IOException { this . a = stream . readInt ( ) ; this . c = stream . readInt ( ) ; this . d = stream . readByte ( ) ; this . e = stream . readInt ( ) ; this . b = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . a ) ; stream . writeInt ( this . c ) ; stream . writeByte ( this . d ) ; stream . writeInt ( this . e ) ; stream . writeInt ( this . b ) ; } @ Override public int length ( ) { return <NUM_LIT:20> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet9Respawn extends Packet { public byte dimension ; public Packet9Respawn ( ) { } @ Override public void read ( DataInputStream stream ) throws IOException { this . dimension = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . dimension ) ; } @ Override public int length ( ) { return <NUM_LIT:1> ; } @ Override public byte getId ( ) { return <NUM_LIT:9> ; } @ Override public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( dimension ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet38EntityStatus extends Packet { public int eid ; public byte status ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . status = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeByte ( this . status ) ; } @ Override public int length ( ) { return <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet7UseEntity extends Packet { public int user ; public int target ; public byte leftClick ; @ Override public void read ( DataInputStream stream ) throws IOException { this . user = stream . readInt ( ) ; this . target = stream . readInt ( ) ; this . leftClick = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . user ) ; stream . writeInt ( this . target ) ; stream . writeByte ( this . leftClick ) ; } @ Override public int length ( ) { return <NUM_LIT:9> ; } @ Override public byte getId ( ) { return <NUM_LIT:7> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet51MapChunk extends Packet { public int x ; public int y ; public int z ; public int sizeX ; public int sizeY ; public int sizeZ ; public byte [ ] rawData ; private int compressedSize ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readShort ( ) ; this . z = stream . readInt ( ) ; this . sizeX = stream . read ( ) + <NUM_LIT:1> ; this . sizeY = stream . read ( ) + <NUM_LIT:1> ; this . sizeZ = stream . read ( ) + <NUM_LIT:1> ; this . compressedSize = stream . readInt ( ) ; rawData = new byte [ this . compressedSize ] ; stream . readFully ( rawData ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . writeShort ( this . y ) ; stream . writeInt ( this . z ) ; stream . write ( this . sizeX - <NUM_LIT:1> ) ; stream . write ( this . sizeY - <NUM_LIT:1> ) ; stream . write ( this . sizeZ - <NUM_LIT:1> ) ; stream . writeInt ( this . compressedSize ) ; stream . write ( this . rawData , <NUM_LIT:0> , this . compressedSize ) ; } @ Override public int length ( ) { return <NUM_LIT> + this . compressedSize ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( x ) ; result . append ( "<STR_LIT>" ) ; result . append ( y ) ; result . append ( "<STR_LIT>" ) ; result . append ( z ) ; result . append ( "<STR_LIT>" ) ; result . append ( sizeX ) ; result . append ( "<STR_LIT>" ) ; result . append ( sizeY ) ; result . append ( "<STR_LIT>" ) ; result . append ( sizeZ ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet17UseBed extends Packet { public int id ; public byte inBed ; public int x ; public byte y ; public int z ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readInt ( ) ; this . inBed = stream . readByte ( ) ; this . x = stream . readInt ( ) ; this . y = stream . readByte ( ) ; this . z = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . id ) ; stream . writeByte ( this . inBed ) ; stream . writeInt ( this . x ) ; stream . writeByte ( this . y ) ; stream . writeInt ( this . z ) ; } @ Override public int length ( ) { return <NUM_LIT> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet22Collect extends Packet { public int collectedEID ; public int collectorEID ; @ Override public void read ( DataInputStream stream ) throws IOException { this . collectedEID = stream . readInt ( ) ; this . collectorEID = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . collectedEID ) ; stream . writeInt ( this . collectorEID ) ; } @ Override public int length ( ) { return <NUM_LIT:8> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; public class Packet0KeepAlive extends Packet { public Packet0KeepAlive ( ) { } @ Override public void read ( DataInputStream stream ) { } @ Override public void write ( DataOutputStream stream ) { } @ Override public int length ( ) { return <NUM_LIT:0> ; } @ Override public byte getId ( ) { return <NUM_LIT:0> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet106Transaction extends Packet { public int id ; public short action ; public boolean accepted ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; this . action = stream . readShort ( ) ; this . accepted = stream . readByte ( ) != <NUM_LIT:0> ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; stream . writeShort ( this . action ) ; stream . writeByte ( this . accepted ? <NUM_LIT:1> : <NUM_LIT:0> ) ; } @ Override public int length ( ) { return <NUM_LIT:4> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import java . util . ArrayList ; import java . util . List ; import com . sk89q . minerhat . util . BlockPosition ; import com . sk89q . minerhat . util . ItemStack ; public class MetadataParser { public static List < MetadataObject > read ( DataInputStream stream ) throws IOException { ArrayList < MetadataObject > data = null ; for ( byte id = stream . readByte ( ) ; id != <NUM_LIT> ; id = stream . readByte ( ) ) { if ( data == null ) { data = new ArrayList < MetadataObject > ( ) ; } MetadataObject entry = null ; int type = ( id & <NUM_LIT> ) > > <NUM_LIT:5> ; int mask = id & <NUM_LIT> ; switch ( type ) { case <NUM_LIT:0> : entry = new MetadataObject ( type , mask , Byte . valueOf ( stream . readByte ( ) ) ) ; break ; case <NUM_LIT:1> : entry = new MetadataObject ( type , mask , Short . valueOf ( stream . readShort ( ) ) ) ; break ; case <NUM_LIT:2> : entry = new MetadataObject ( type , mask , Integer . valueOf ( stream . readInt ( ) ) ) ; break ; case <NUM_LIT:3> : entry = new MetadataObject ( type , mask , Float . valueOf ( stream . readFloat ( ) ) ) ; break ; case <NUM_LIT:4> : entry = new MetadataObject ( type , mask , stream . readUTF ( ) ) ; break ; case <NUM_LIT:5> : short itemType = stream . readShort ( ) ; byte itemCount = stream . readByte ( ) ; short itemDamage = stream . readShort ( ) ; entry = new MetadataObject ( type , mask , new ItemStack ( itemType , itemCount , itemDamage ) ) ; case <NUM_LIT:6> : int x = stream . readInt ( ) ; int y = stream . readInt ( ) ; int z = stream . readInt ( ) ; entry = new MetadataObject ( type , mask , new BlockPosition ( x , y , z ) ) ; default : throw new UnsupportedOperationException ( "<STR_LIT>" + type ) ; } data . add ( entry ) ; } return data ; } public static void write ( List < MetadataObject > entries , DataOutputStream stream ) throws IOException { if ( entries == null ) { stream . writeByte ( <NUM_LIT> ) ; return ; } for ( MetadataObject entry : entries ) { write ( entry , stream ) ; } stream . writeByte ( <NUM_LIT> ) ; } public static void write ( MetadataObject entry , DataOutputStream stream ) throws IOException { int id = ( entry . getType ( ) << <NUM_LIT:5> | entry . getMask ( ) & <NUM_LIT> ) & <NUM_LIT> ; stream . writeByte ( id ) ; switch ( entry . getType ( ) ) { case <NUM_LIT:0> : stream . writeByte ( ( Byte ) entry . getData ( ) ) ; break ; case <NUM_LIT:1> : stream . writeShort ( ( Short ) entry . getData ( ) ) ; break ; case <NUM_LIT:2> : stream . writeInt ( ( Integer ) entry . getData ( ) ) ; break ; case <NUM_LIT:3> : stream . writeFloat ( ( Float ) entry . getData ( ) ) ; break ; case <NUM_LIT:4> : stream . writeUTF ( ( String ) entry . getData ( ) ) ; break ; case <NUM_LIT:5> : ItemStack itemstack = ( ItemStack ) entry . getData ( ) ; stream . writeShort ( itemstack . getId ( ) ) ; stream . writeByte ( itemstack . getCount ( ) ) ; stream . writeShort ( itemstack . getDamage ( ) ) ; case <NUM_LIT:6> : BlockPosition pos = ( BlockPosition ) entry . getData ( ) ; stream . writeInt ( pos . getX ( ) ) ; stream . writeInt ( pos . getY ( ) ) ; stream . writeInt ( pos . getZ ( ) ) ; default : throw new UnsupportedOperationException ( "<STR_LIT>" + entry . getType ( ) ) ; } } public static class MetadataObject { private int type ; private int mask ; private Object data ; public MetadataObject ( int type , int mask , Object data ) { this . type = type ; this . mask = mask ; this . data = data ; } public int getType ( ) { return type ; } public void setType ( int type ) { this . type = type ; } public int getMask ( ) { return mask ; } public void setMask ( int mask ) { this . mask = mask ; } public Object getData ( ) { return data ; } public void setData ( Object data ) { this . data = data ; } } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet30Entity extends Packet { public int eid ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; } @ Override public int length ( ) { return <NUM_LIT:4> ; } @ Override public byte getId ( ) { return <NUM_LIT:30> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet1Login extends Packet { public int version ; public String username ; public long mapSeed ; public byte dimension ; @ Override public void read ( DataInputStream stream ) throws IOException { this . version = stream . readInt ( ) ; this . username = read ( stream , <NUM_LIT:16> ) ; this . mapSeed = stream . readLong ( ) ; this . dimension = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . version ) ; write ( this . username , stream ) ; stream . writeLong ( this . mapSeed ) ; stream . writeByte ( this . dimension ) ; } @ Override public int length ( ) { return <NUM_LIT:4> + this . username . length ( ) + <NUM_LIT:4> + <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT:1> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( username ) ; result . append ( "<STR_LIT>" ) ; result . append ( version ) ; result . append ( "<STR_LIT>" ) ; result . append ( mapSeed ) ; result . append ( "<STR_LIT>" ) ; result . append ( dimension ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet50PreChunk extends Packet { public int x ; public int y ; public boolean initialize ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . initialize = stream . read ( ) != <NUM_LIT:0> ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . write ( this . initialize ? <NUM_LIT:1> : <NUM_LIT:0> ) ; } @ Override public int length ( ) { return <NUM_LIT:9> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } public String toString ( ) { return this . getClass ( ) . getName ( ) + "<STR_LIT>" + "<STR_LIT>" + x + "<STR_LIT>" + y + "<STR_LIT>" + initialize ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet33RelativeEntityMoveLook extends Packet30Entity { public byte dx ; public byte dy ; public byte dz ; public byte yaw ; public byte pitch ; @ Override public void read ( DataInputStream stream ) throws IOException { super . read ( stream ) ; this . dx = stream . readByte ( ) ; this . dy = stream . readByte ( ) ; this . dz = stream . readByte ( ) ; this . yaw = stream . readByte ( ) ; this . pitch = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { super . write ( stream ) ; stream . writeByte ( this . dx ) ; stream . writeByte ( this . dy ) ; stream . writeByte ( this . dz ) ; stream . writeByte ( this . yaw ) ; stream . writeByte ( this . pitch ) ; } @ Override public int length ( ) { return <NUM_LIT:9> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet71Weather extends Packet { public int a ; public int b ; public int c ; public int d ; public int e ; public void read ( DataInputStream datainputstream ) throws IOException { this . a = datainputstream . readInt ( ) ; this . e = datainputstream . readByte ( ) ; this . b = datainputstream . readInt ( ) ; this . c = datainputstream . readInt ( ) ; this . d = datainputstream . readInt ( ) ; } public void write ( DataOutputStream dataoutputstream ) throws IOException { dataoutputstream . writeInt ( this . a ) ; dataoutputstream . writeByte ( this . e ) ; dataoutputstream . writeInt ( this . b ) ; dataoutputstream . writeInt ( this . c ) ; dataoutputstream . writeInt ( this . d ) ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } @ Override public int length ( ) { return <NUM_LIT:0> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet5EntityEquipment extends Packet { public int eid ; public int slot ; public int itemId ; public int d ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . slot = stream . readShort ( ) ; this . itemId = stream . readShort ( ) ; this . d = stream . readShort ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeShort ( this . slot ) ; stream . writeShort ( this . itemId ) ; stream . writeShort ( this . d ) ; } @ Override public int length ( ) { return <NUM_LIT:8> ; } @ Override public byte getId ( ) { return <NUM_LIT:5> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet23VehicleSpawn extends Packet { public int eid ; public int x ; public int y ; public int z ; public int type ; public int i ; public short e ; public short f ; public short g ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . type = stream . readByte ( ) ; this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . z = stream . readInt ( ) ; this . i = stream . readInt ( ) ; if ( this . i > <NUM_LIT:0> ) { this . e = stream . readShort ( ) ; this . f = stream . readShort ( ) ; this . g = stream . readShort ( ) ; } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeByte ( this . type ) ; stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . writeInt ( this . z ) ; stream . writeInt ( this . i ) ; if ( this . i > <NUM_LIT:0> ) { stream . writeShort ( this . e ) ; stream . writeShort ( this . f ) ; stream . writeShort ( this . g ) ; } } @ Override public int length ( ) { return <NUM_LIT> + this . i > <NUM_LIT:0> ? <NUM_LIT:6> : <NUM_LIT:0> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import com . sk89q . minerhat . util . ItemStack ; public class Packet15Place extends Packet { public int x ; public byte y ; public int z ; public byte direction ; public ItemStack item ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readByte ( ) ; this . z = stream . readInt ( ) ; this . direction = stream . readByte ( ) ; short id = stream . readShort ( ) ; if ( id >= <NUM_LIT:0> ) { byte amount = stream . readByte ( ) ; short damage = stream . readShort ( ) ; this . item = new ItemStack ( id , amount , damage ) ; } else { this . item = null ; } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . write ( this . y ) ; stream . writeInt ( this . z ) ; stream . write ( this . direction ) ; if ( this . item == null ) { stream . writeShort ( - <NUM_LIT:1> ) ; } else { stream . writeShort ( this . item . getId ( ) ) ; stream . writeByte ( this . item . getCount ( ) ) ; stream . writeShort ( this . item . getDamage ( ) ) ; } } @ Override public int length ( ) { return <NUM_LIT:15> ; } @ Override public byte getId ( ) { return <NUM_LIT:15> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet34EntityTeleport extends Packet30Entity { public int x ; public int y ; public int z ; public byte yaw ; public byte pitch ; @ Override public void read ( DataInputStream stream ) throws IOException { super . read ( stream ) ; this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . z = stream . readInt ( ) ; this . yaw = ( byte ) stream . read ( ) ; this . pitch = ( byte ) stream . read ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { super . write ( stream ) ; stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . writeInt ( this . z ) ; stream . write ( this . yaw ) ; stream . write ( this . pitch ) ; } @ Override public int length ( ) { return <NUM_LIT> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet131 extends Packet { public short a ; public short b ; public byte [ ] c ; @ Override public void read ( DataInputStream stream ) throws IOException { this . a = stream . readShort ( ) ; this . b = stream . readShort ( ) ; this . c = new byte [ stream . readByte ( ) & <NUM_LIT> ] ; stream . readFully ( this . c ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeShort ( this . a ) ; stream . writeShort ( this . b ) ; stream . writeByte ( this . c . length ) ; stream . write ( this . c ) ; } @ Override public int length ( ) { return <NUM_LIT:4> + this . c . length ; } @ Override public byte getId ( ) { return ( byte ) <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet105CraftProgressBar extends Packet { public byte id ; public short progress ; public short value ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; this . progress = stream . readShort ( ) ; this . value = stream . readShort ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; stream . writeShort ( this . progress ) ; stream . writeShort ( this . value ) ; } @ Override public int length ( ) { return <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet200Statistic extends Packet { int id ; byte amount ; @ Override public byte getId ( ) { return ( byte ) <NUM_LIT> ; } @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readInt ( ) ; this . amount = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . id ) ; stream . writeByte ( this . amount ) ; } @ Override public int length ( ) { return <NUM_LIT:6> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet16BlockItemSwitch extends Packet { public int slot ; @ Override public void read ( DataInputStream stream ) throws IOException { this . slot = stream . readShort ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeShort ( this . slot ) ; } @ Override public int length ( ) { return <NUM_LIT:2> ; } @ Override public byte getId ( ) { return <NUM_LIT:16> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet131MapData extends Packet { public short a ; public short b ; public byte [ ] c ; @ Override public void read ( DataInputStream stream ) throws IOException { this . a = stream . readShort ( ) ; this . b = stream . readShort ( ) ; this . c = new byte [ stream . readByte ( ) & <NUM_LIT> ] ; stream . readFully ( this . c ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeShort ( this . a ) ; stream . writeShort ( this . b ) ; stream . writeByte ( this . c . length ) ; stream . write ( this . c ) ; } @ Override public int length ( ) { return <NUM_LIT:4> + this . c . length ; } @ Override public byte getId ( ) { return ( byte ) <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet8UpdateHealth extends Packet { public int health ; @ Override public void read ( DataInputStream stream ) throws IOException { this . health = stream . readShort ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeShort ( this . health ) ; } @ Override public int length ( ) { return <NUM_LIT:2> ; } @ Override public byte getId ( ) { return <NUM_LIT:8> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( health ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet53BlockChange extends Packet { public int x ; public byte y ; public int z ; public byte type ; public byte data ; public Packet53BlockChange ( ) { } @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readByte ( ) ; this . z = stream . readInt ( ) ; this . type = stream . readByte ( ) ; this . data = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . write ( this . y ) ; stream . writeInt ( this . z ) ; stream . write ( this . type ) ; stream . write ( this . data ) ; } @ Override public int length ( ) { return <NUM_LIT:11> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import java . util . ArrayList ; import java . util . List ; import com . sk89q . minerhat . util . BlockPosition ; public class Packet60Explosion extends Packet { public double x ; public double y ; public double z ; public float radius ; public List < BlockPosition > blocks = new ArrayList < BlockPosition > ( ) ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readDouble ( ) ; this . y = stream . readDouble ( ) ; this . z = stream . readDouble ( ) ; this . radius = stream . readFloat ( ) ; int count = stream . readInt ( ) ; this . blocks = new ArrayList < BlockPosition > ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; ++ i ) { int blockX = ( int ) ( stream . readByte ( ) + x ) ; int blockY = ( int ) ( stream . readByte ( ) + y ) ; int blockZ = ( int ) ( stream . readByte ( ) + z ) ; this . blocks . add ( new BlockPosition ( blockX , blockY , blockZ ) ) ; } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeDouble ( this . x ) ; stream . writeDouble ( this . y ) ; stream . writeDouble ( this . z ) ; stream . writeFloat ( this . radius ) ; stream . writeInt ( this . blocks . size ( ) ) ; for ( BlockPosition pos : blocks ) { stream . writeByte ( pos . getX ( ) ) ; stream . writeByte ( pos . getY ( ) ) ; stream . writeByte ( pos . getZ ( ) ) ; } } @ Override public int length ( ) { return <NUM_LIT:32> + this . blocks . size ( ) * <NUM_LIT:3> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet28EntityVelocity extends Packet { public int a ; public int b ; public int c ; public int d ; @ Override public void read ( DataInputStream stream ) throws IOException { this . a = stream . readInt ( ) ; this . b = stream . readShort ( ) ; this . c = stream . readShort ( ) ; this . d = stream . readShort ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . a ) ; stream . writeShort ( this . b ) ; stream . writeShort ( this . c ) ; stream . writeShort ( this . d ) ; } @ Override public int length ( ) { return <NUM_LIT:10> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet14BlockDig extends Packet { public byte status ; public int x ; public byte y ; public int z ; public byte face ; @ Override public void read ( DataInputStream stream ) throws IOException { this . status = stream . readByte ( ) ; this . x = stream . readInt ( ) ; this . y = stream . readByte ( ) ; this . z = stream . readInt ( ) ; this . face = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . status ) ; stream . writeInt ( this . x ) ; stream . writeByte ( this . y ) ; stream . writeInt ( this . z ) ; stream . writeByte ( this . face ) ; } @ Override public int length ( ) { return <NUM_LIT:11> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet27 extends Packet { private float a ; private float b ; private boolean c ; private boolean d ; private float e ; private float f ; @ Override public void read ( DataInputStream stream ) throws IOException { this . a = stream . readFloat ( ) ; this . b = stream . readFloat ( ) ; this . e = stream . readFloat ( ) ; this . f = stream . readFloat ( ) ; this . c = stream . readBoolean ( ) ; this . d = stream . readBoolean ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeFloat ( this . a ) ; stream . writeFloat ( this . b ) ; stream . writeFloat ( this . e ) ; stream . writeFloat ( this . f ) ; stream . writeBoolean ( this . c ) ; stream . writeBoolean ( this . d ) ; } @ Override public int length ( ) { return <NUM_LIT> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet255KickDisconnect extends Packet { public String message ; @ Override public void read ( DataInputStream stream ) throws IOException { this . message = read ( stream , <NUM_LIT:100> ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { write ( this . message , stream ) ; } @ Override public int length ( ) { return this . message . length ( ) ; } @ Override public byte getId ( ) { return ( byte ) <NUM_LIT:255> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( message ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet25EntityPainting extends Packet { public int eid ; public int x ; public int y ; public int z ; public int direction ; public String title ; public Packet25EntityPainting ( ) { } @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . title = read ( stream , "<STR_LIT>" . length ( ) ) ; this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . z = stream . readInt ( ) ; this . direction = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; write ( this . title , stream ) ; stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . writeInt ( this . z ) ; stream . writeInt ( this . direction ) ; } @ Override public int length ( ) { return <NUM_LIT:24> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet10Flying extends Packet { public boolean onGround ; @ Override public void read ( DataInputStream stream ) throws IOException { this . onGround = stream . read ( ) != <NUM_LIT:0> ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . write ( this . onGround ? <NUM_LIT:1> : <NUM_LIT:0> ) ; } @ Override public int length ( ) { return <NUM_LIT:1> ; } @ Override public byte getId ( ) { return <NUM_LIT:10> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( onGround ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public abstract class Packet { public abstract byte getId ( ) ; public abstract void read ( DataInputStream datainputstream ) throws IOException ; public abstract void write ( DataOutputStream dataoutputstream ) throws IOException ; public abstract int length ( ) ; public boolean toServer ; public static String read ( DataInputStream datainputstream , int i ) throws IOException { short short1 = datainputstream . readShort ( ) ; if ( short1 > i ) { throw new IOException ( "<STR_LIT>" + short1 + "<STR_LIT>" + i + "<STR_LIT:)>" ) ; } else if ( short1 < <NUM_LIT:0> ) { throw new IOException ( "<STR_LIT>" ) ; } else { StringBuilder stringbuilder = new StringBuilder ( ) ; for ( int j = <NUM_LIT:0> ; j < short1 ; ++ j ) { stringbuilder . append ( datainputstream . readChar ( ) ) ; } return stringbuilder . toString ( ) ; } } public static void write ( String s , DataOutputStream dataoutputstream ) throws IOException { if ( s . length ( ) > <NUM_LIT> ) { throw new IOException ( "<STR_LIT>" ) ; } else { dataoutputstream . writeShort ( s . length ( ) ) ; dataoutputstream . writeChars ( s ) ; } } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet100OpenWindow extends Packet { public byte id ; public byte type ; public String title ; public byte slotCount ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; this . type = stream . readByte ( ) ; this . title = stream . readUTF ( ) ; this . slotCount = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; stream . writeByte ( this . type ) ; stream . writeUTF ( this . title ) ; stream . writeByte ( this . slotCount ) ; } @ Override public int length ( ) { return <NUM_LIT:3> + this . title . length ( ) ; } @ Override public byte getId ( ) { return <NUM_LIT:100> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet4UpdateTime extends Packet { public long time ; @ Override public void read ( DataInputStream stream ) throws IOException { this . time = stream . readLong ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeLong ( this . time ) ; } @ Override public int length ( ) { return <NUM_LIT:8> ; } @ Override public byte getId ( ) { return <NUM_LIT:4> ; } public String toString ( ) { return this . getClass ( ) . getName ( ) + "<STR_LIT>" + Long . toString ( time ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import java . util . List ; import com . sk89q . minerhat . packets . MetadataParser . MetadataObject ; public class Packet24MobSpawn extends Packet { public int eid ; public byte type ; public int x ; public int y ; public int z ; public byte yaw ; public byte pitch ; private List < MetadataObject > metadata ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . type = stream . readByte ( ) ; this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . z = stream . readInt ( ) ; this . yaw = stream . readByte ( ) ; this . pitch = stream . readByte ( ) ; this . metadata = MetadataParser . read ( stream ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeByte ( this . type ) ; stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . writeInt ( this . z ) ; stream . writeByte ( this . yaw ) ; stream . writeByte ( this . pitch ) ; MetadataParser . write ( metadata , stream ) ; } @ Override public int length ( ) { return <NUM_LIT:20> ; } @ Override public byte getId ( ) { return <NUM_LIT:24> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( eid ) ; result . append ( "<STR_LIT>" ) ; result . append ( type ) ; result . append ( "<STR_LIT>" ) ; result . append ( x ) ; result . append ( "<STR_LIT>" ) ; result . append ( y ) ; result . append ( "<STR_LIT>" ) ; result . append ( z ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet61 extends Packet { public int a ; public int b ; public int c ; public int d ; public int e ; @ Override public void read ( DataInputStream stream ) throws IOException { this . a = stream . readInt ( ) ; this . c = stream . readInt ( ) ; this . d = stream . readByte ( ) ; this . e = stream . readInt ( ) ; this . b = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . a ) ; stream . writeInt ( this . c ) ; stream . writeByte ( this . d ) ; stream . writeInt ( this . e ) ; stream . writeInt ( this . b ) ; } @ Override public int length ( ) { return <NUM_LIT:20> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet11PlayerPosition extends Packet10Flying { public double x ; public double y ; public double stance ; public double z ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readDouble ( ) ; this . y = stream . readDouble ( ) ; this . stance = stream . readDouble ( ) ; this . z = stream . readDouble ( ) ; super . read ( stream ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeDouble ( this . x ) ; stream . writeDouble ( this . y ) ; stream . writeDouble ( this . stance ) ; stream . writeDouble ( this . z ) ; super . write ( stream ) ; } @ Override public int length ( ) { return <NUM_LIT> ; } @ Override public byte getId ( ) { return <NUM_LIT:11> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( x ) ; result . append ( "<STR_LIT>" ) ; result . append ( y ) ; result . append ( "<STR_LIT>" ) ; result . append ( z ) ; result . append ( "<STR_LIT>" ) ; result . append ( stance ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet39AttachEntity extends Packet { public int eid ; public int vehicleId ; public Packet39AttachEntity ( ) { } @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; this . vehicleId = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; stream . writeInt ( this . vehicleId ) ; } @ Override public int length ( ) { return <NUM_LIT:8> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet13PlayerLookMove extends Packet10Flying { public double x ; public double a ; public double b ; public double z ; public float yaw ; public float pitch ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readDouble ( ) ; this . a = stream . readDouble ( ) ; this . b = stream . readDouble ( ) ; this . z = stream . readDouble ( ) ; this . yaw = stream . readFloat ( ) ; this . pitch = stream . readFloat ( ) ; super . read ( stream ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeDouble ( this . x ) ; stream . writeDouble ( this . a ) ; stream . writeDouble ( this . b ) ; stream . writeDouble ( this . z ) ; stream . writeFloat ( this . yaw ) ; stream . writeFloat ( this . pitch ) ; super . write ( stream ) ; } @ Override public int length ( ) { return <NUM_LIT> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( this . x ) ; result . append ( "<STR_LIT>" ) ; if ( this . toServer ) { result . append ( this . a ) ; } else { result . append ( this . b ) ; } result . append ( "<STR_LIT>" ) ; result . append ( z ) ; result . append ( "<STR_LIT>" ) ; result . append ( yaw ) ; result . append ( "<STR_LIT>" ) ; result . append ( pitch ) ; result . append ( "<STR_LIT>" ) ; if ( this . toServer ) { result . append ( this . b ) ; } else { result . append ( this . a ) ; } return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet54PlayNoteBlock extends Packet { public int x ; public short y ; public int z ; public byte instrument ; public byte pitch ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readShort ( ) ; this . z = stream . readInt ( ) ; this . instrument = stream . readByte ( ) ; this . pitch = stream . readByte ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . writeShort ( this . y ) ; stream . writeInt ( this . z ) ; stream . write ( this . instrument ) ; stream . write ( this . pitch ) ; } @ Override public int length ( ) { return <NUM_LIT:12> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet20NamedEntitySpawn extends Packet { public int eid ; public String name ; public int x ; public int y ; public int z ; public byte rotation ; public byte pitch ; public short currentItem ; @ Override public void read ( DataInputStream datainputstream ) throws IOException { this . eid = datainputstream . readInt ( ) ; this . name = read ( datainputstream , <NUM_LIT:16> ) ; this . x = datainputstream . readInt ( ) ; this . y = datainputstream . readInt ( ) ; this . z = datainputstream . readInt ( ) ; this . rotation = datainputstream . readByte ( ) ; this . pitch = datainputstream . readByte ( ) ; this . currentItem = datainputstream . readShort ( ) ; } @ Override public void write ( DataOutputStream dataoutputstream ) throws IOException { dataoutputstream . writeInt ( this . eid ) ; write ( this . name , dataoutputstream ) ; dataoutputstream . writeInt ( this . x ) ; dataoutputstream . writeInt ( this . y ) ; dataoutputstream . writeInt ( this . z ) ; dataoutputstream . writeByte ( this . rotation ) ; dataoutputstream . writeByte ( this . pitch ) ; dataoutputstream . writeShort ( this . currentItem ) ; } @ Override public int length ( ) { return <NUM_LIT> ; } @ Override public byte getId ( ) { return <NUM_LIT:20> ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet3Chat extends Packet { public String message ; @ Override public void read ( DataInputStream stream ) throws IOException { this . message = read ( stream , <NUM_LIT> ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { write ( this . message , stream ) ; } @ Override public int length ( ) { return this . message . length ( ) ; } @ Override public byte getId ( ) { return <NUM_LIT:3> ; } public String toString ( ) { return this . getClass ( ) . getName ( ) + "<STR_LIT>" + message ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . IOException ; import java . util . HashMap ; import java . util . Map ; public class PacketManager { private static final Map < Byte , Class < ? extends Packet > > packets = new HashMap < Byte , Class < ? extends Packet > > ( ) ; static { packets . put ( ( byte ) <NUM_LIT:0> , Packet0KeepAlive . class ) ; packets . put ( ( byte ) <NUM_LIT:1> , Packet1Login . class ) ; packets . put ( ( byte ) <NUM_LIT:2> , Packet2Handshake . class ) ; packets . put ( ( byte ) <NUM_LIT:3> , Packet3Chat . class ) ; packets . put ( ( byte ) <NUM_LIT:4> , Packet4UpdateTime . class ) ; packets . put ( ( byte ) <NUM_LIT:5> , Packet5EntityEquipment . class ) ; packets . put ( ( byte ) <NUM_LIT:6> , Packet6SpawnPosition . class ) ; packets . put ( ( byte ) <NUM_LIT:7> , Packet7UseEntity . class ) ; packets . put ( ( byte ) <NUM_LIT:8> , Packet8UpdateHealth . class ) ; packets . put ( ( byte ) <NUM_LIT:9> , Packet9Respawn . class ) ; packets . put ( ( byte ) <NUM_LIT:10> , Packet10Flying . class ) ; packets . put ( ( byte ) <NUM_LIT:11> , Packet11PlayerPosition . class ) ; packets . put ( ( byte ) <NUM_LIT:12> , Packet12PlayerLook . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet13PlayerLookMove . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet14BlockDig . class ) ; packets . put ( ( byte ) <NUM_LIT:15> , Packet15Place . class ) ; packets . put ( ( byte ) <NUM_LIT:16> , Packet16BlockItemSwitch . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet17UseBed . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet18ArmAnimation . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet19EntityAction . class ) ; packets . put ( ( byte ) <NUM_LIT:20> , Packet20NamedEntitySpawn . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet21PickupSpawn . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet22Collect . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet23VehicleSpawn . class ) ; packets . put ( ( byte ) <NUM_LIT:24> , Packet24MobSpawn . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet25EntityPainting . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet27 . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet28EntityVelocity . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet29DestroyEntity . class ) ; packets . put ( ( byte ) <NUM_LIT:30> , Packet30Entity . class ) ; packets . put ( ( byte ) <NUM_LIT:31> , Packet31RelativeEntityMove . class ) ; packets . put ( ( byte ) <NUM_LIT:32> , Packet32EntityLook . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet33RelativeEntityMoveLook . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet34EntityTeleport . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet38EntityStatus . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet39AttachEntity . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet40EntityMetadata . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet50PreChunk . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet51MapChunk . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet52MultiBlockChange . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet53BlockChange . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet54PlayNoteBlock . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet60Explosion . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet61DoorChange . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet70Bed . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet71Weather . class ) ; packets . put ( ( byte ) <NUM_LIT:100> , Packet100OpenWindow . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet101CloseWindow . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet102WindowClick . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet103SetSlot . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet104WindowItems . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet105CraftProgressBar . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet106Transaction . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet130UpdateSign . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet131MapData . class ) ; packets . put ( ( byte ) <NUM_LIT> , Packet200Statistic . class ) ; packets . put ( ( byte ) <NUM_LIT:255> , Packet255KickDisconnect . class ) ; } public static boolean containsID ( byte id ) { if ( packets . containsKey ( id ) ) { return true ; } else { return false ; } } public static Class < ? extends Packet > get ( byte id ) throws UnknownPacketException { Class < ? extends Packet > cls = packets . get ( id ) ; if ( cls == null ) { throw new UnknownPacketException ( ) ; } return cls ; } public static Packet construct ( byte id ) throws UnknownPacketException { Class < ? extends Packet > cls = get ( id ) ; Packet packet ; try { packet = ( Packet ) cls . newInstance ( ) ; } catch ( InstantiationException e ) { throw new UnknownPacketException ( e ) ; } catch ( IllegalAccessException e ) { throw new UnknownPacketException ( e ) ; } if ( id != packet . getId ( ) ) { throw new RuntimeException ( "<STR_LIT>" + packet . getClass ( ) . getCanonicalName ( ) + "<STR_LIT>" + packet . getId ( ) + "<STR_LIT>" + id ) ; } return packet ; } public static Packet read ( byte id , DataInputStream stream ) throws UnknownPacketException , IOException { Packet packet = construct ( id ) ; packet . read ( stream ) ; return packet ; } public static class UnknownPacketException extends Exception { private static final long serialVersionUID = - <NUM_LIT> ; public UnknownPacketException ( ) { super ( ) ; } public UnknownPacketException ( Throwable t ) { super ( t ) ; } } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import com . sk89q . minerhat . util . ItemStack ; public class Packet104WindowItems extends Packet { public byte id ; public ItemStack [ ] items ; @ Override public void read ( DataInputStream stream ) throws IOException { this . id = stream . readByte ( ) ; short count = stream . readShort ( ) ; this . items = new ItemStack [ count ] ; for ( int i = <NUM_LIT:0> ; i < count ; ++ i ) { short short2 = stream . readShort ( ) ; if ( short2 >= <NUM_LIT:0> ) { byte b0 = stream . readByte ( ) ; short short3 = stream . readShort ( ) ; this . items [ i ] = new ItemStack ( short2 , b0 , short3 ) ; } } } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeByte ( this . id ) ; stream . writeShort ( this . items . length ) ; for ( int i = <NUM_LIT:0> ; i < this . items . length ; ++ i ) { if ( this . items [ i ] == null ) { stream . writeShort ( - <NUM_LIT:1> ) ; } else { stream . writeShort ( ( short ) this . items [ i ] . getId ( ) ) ; stream . writeByte ( ( byte ) this . items [ i ] . getCount ( ) ) ; stream . writeShort ( ( short ) this . items [ i ] . getDamage ( ) ) ; } } } @ Override public int length ( ) { return <NUM_LIT:3> + this . items . length * <NUM_LIT:5> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( id ) ; result . append ( "<STR_LIT>" ) ; result . append ( items . toString ( ) ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet6SpawnPosition extends Packet { private int x ; private int y ; private int z ; @ Override public void read ( DataInputStream stream ) throws IOException { this . x = stream . readInt ( ) ; this . y = stream . readInt ( ) ; this . z = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . x ) ; stream . writeInt ( this . y ) ; stream . writeInt ( this . z ) ; } @ Override public int length ( ) { return <NUM_LIT:12> ; } @ Override public byte getId ( ) { return <NUM_LIT:6> ; } public String toString ( ) { StringBuilder result = new StringBuilder ( ) ; result . append ( this . getClass ( ) . getName ( ) + "<STR_LIT>" ) ; result . append ( "<STR_LIT>" ) ; result . append ( x ) ; result . append ( "<STR_LIT>" ) ; result . append ( y ) ; result . append ( "<STR_LIT>" ) ; result . append ( z ) ; return result . toString ( ) ; } } </s>
<s> package com . sk89q . minerhat . packets ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . IOException ; public class Packet29DestroyEntity extends Packet { public int eid ; @ Override public void read ( DataInputStream stream ) throws IOException { this . eid = stream . readInt ( ) ; } @ Override public void write ( DataOutputStream stream ) throws IOException { stream . writeInt ( this . eid ) ; } @ Override public int length ( ) { return <NUM_LIT:4> ; } @ Override public byte getId ( ) { return <NUM_LIT> ; } } </s>
<s> package com . sk89q . minerhat ; import java . io . * ; import java . net . * ; import java . util . logging . Level ; import java . util . logging . Logger ; public class MinecraftProxyServer implements Runnable { private static final Logger logger = Logger . getLogger ( MinecraftProxyServer . class . getName ( ) ) ; private int port ; private InetAddress targetHost ; private int targetPort ; public MinecraftProxyServer ( int port , InetAddress targetHost , int targetPort ) { this . port = port ; this . targetHost = targetHost ; this . targetPort = targetPort ; } public void listen ( ) throws IOException { ServerSocket serverSocket = new ServerSocket ( getPort ( ) ) ; logger . info ( "<STR_LIT>" ) ; while ( ! serverSocket . isClosed ( ) ) { Socket clientSocket = serverSocket . accept ( ) ; clientSocket . setTcpNoDelay ( true ) ; logger . info ( "<STR_LIT>" + clientSocket . toString ( ) ) ; MinecraftProxyServerClient client = new MinecraftProxyServerClient ( this , clientSocket ) ; Thread thread = new Thread ( client ) ; thread . start ( ) ; } } public int getPort ( ) { return port ; } public InetAddress getTargetHost ( ) { return targetHost ; } public int getTargetPort ( ) { return targetPort ; } public void setTargetHost ( InetAddress targetHost ) { this . targetHost = targetHost ; } public void setTargetPort ( int targetPort ) { this . targetPort = targetPort ; } public void run ( ) { try { listen ( ) ; } catch ( IOException ex ) { Logger . getLogger ( MinecraftProxyServer . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } } } </s>
<s> package com . sk89q . minerhat ; import java . io . IOException ; import java . net . InetAddress ; import java . net . UnknownHostException ; import java . util . logging . Formatter ; import java . util . logging . Handler ; import java . util . logging . Logger ; import javax . swing . UIManager ; import javax . swing . UnsupportedLookAndFeelException ; import jline . ConsoleReader ; public class MinerHat { private static final Logger logger = Logger . getLogger ( MinerHat . class . getName ( ) ) ; public static void main ( String [ ] args ) throws IOException { System . out . println ( "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( ) ; Logger rootLogger = Logger . getLogger ( "<STR_LIT>" ) ; Formatter formatter = new SimpleLoggerFormatter ( ) ; for ( Handler handler : rootLogger . getHandlers ( ) ) { handler . setFormatter ( formatter ) ; } try { UIManager . setLookAndFeel ( UIManager . getSystemLookAndFeelClassName ( ) ) ; } catch ( ClassNotFoundException ex ) { } catch ( InstantiationException ex ) { } catch ( IllegalAccessException ex ) { } catch ( UnsupportedLookAndFeelException ex ) { } MinecraftProxyServer server = null ; try { server = new MinecraftProxyServer ( <NUM_LIT> , InetAddress . getLocalHost ( ) , <NUM_LIT> ) ; } catch ( UnknownHostException ex ) { logger . severe ( "<STR_LIT>" ) ; System . exit ( <NUM_LIT:1> ) ; return ; } ( new Thread ( server ) ) . start ( ) ; ConsoleReader reader = new ConsoleReader ( ) ; String line ; while ( ( line = reader . readLine ( "<STR_LIT>" ) ) != null ) { String [ ] parts = line . split ( "<STR_LIT:U+0020>" ) ; if ( parts [ <NUM_LIT:0> ] . equalsIgnoreCase ( "<STR_LIT>" ) ) { if ( parts . length == <NUM_LIT:2> ) { try { server . setTargetHost ( InetAddress . getByName ( parts [ <NUM_LIT:1> ] ) ) ; System . out . println ( "<STR_LIT>" + parts [ <NUM_LIT:1> ] ) ; } catch ( IOException e ) { System . out . println ( "<STR_LIT>" + parts [ <NUM_LIT:1> ] ) ; } } else { System . out . println ( "<STR_LIT>" ) ; } } else if ( parts [ <NUM_LIT:0> ] . equalsIgnoreCase ( "<STR_LIT>" ) ) { if ( parts . length == <NUM_LIT:2> ) { try { server . setTargetPort ( Integer . parseInt ( parts [ <NUM_LIT:1> ] ) ) ; System . out . println ( "<STR_LIT>" + parts [ <NUM_LIT:1> ] ) ; } catch ( NumberFormatException e ) { System . out . println ( "<STR_LIT>" + parts [ <NUM_LIT:1> ] ) ; } } else { System . out . println ( "<STR_LIT>" ) ; } } else if ( parts [ <NUM_LIT:0> ] . equalsIgnoreCase ( "<STR_LIT>" ) ) { System . exit ( <NUM_LIT:0> ) ; } else { System . out . println ( "<STR_LIT>" ) ; } } } } </s>