text
stringlengths
30
1.67M
<s> package annis . sqlgen ; import static org . hamcrest . Matchers . is ; import static org . junit . Assert . assertThat ; import static org . mockito . Mockito . mock ; import static org . mockito . Mockito . when ; import java . sql . ResultSet ; import java . sql . SQLException ; import org . junit . Before ; import org . junit . Test ; import annis . model . Annotation ; public class TestListCorpusAnnotationsSqlHelper { private ListCorpusAnnotationsSqlHelper listCorpusAnnotationsHelper ; @ Before public void setup ( ) { listCorpusAnnotationsHelper = new ListCorpusAnnotationsSqlHelper ( ) ; } @ Test public void mapRow ( ) throws SQLException { ResultSet resultSet = mock ( ResultSet . class ) ; final String NAMESPACE = "<STR_LIT>" ; final String NAME = "<STR_LIT>" ; final String VALUE = "<STR_LIT>" ; when ( resultSet . getString ( "<STR_LIT>" ) ) . thenReturn ( NAMESPACE ) ; when ( resultSet . getString ( "<STR_LIT:name>" ) ) . thenReturn ( NAME ) ; when ( resultSet . getString ( "<STR_LIT:value>" ) ) . thenReturn ( VALUE ) ; Annotation expected = new Annotation ( NAMESPACE , NAME , VALUE ) ; assertThat ( listCorpusAnnotationsHelper . mapRow ( resultSet , <NUM_LIT:1> ) , is ( expected ) ) ; } } </s>
<s> package annis . sqlgen ; import static annis . test . TestUtils . uniqueString ; import static java . util . Arrays . asList ; import static org . hamcrest . CoreMatchers . is ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . Mockito . mock ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . List ; import org . apache . commons . lang3 . StringUtils ; import org . junit . Test ; public class CsvCorpusPathExtractorTest { CorpusPathExtractor extractor = new CsvCorpusPathExtractor ( ) ; @ Test public void shouldExtractCorpusPath ( ) throws SQLException { String pathAlias = uniqueString ( <NUM_LIT:5> ) ; String path1 = uniqueString ( <NUM_LIT:3> ) ; String path2 = uniqueString ( <NUM_LIT:3> ) ; String path3 = uniqueString ( <NUM_LIT:3> ) ; ResultSet resultSet = mock ( ResultSet . class ) ; String csv = StringUtils . join ( asList ( path1 , path2 , path3 ) , "<STR_LIT:U+002C>" ) ; given ( resultSet . getString ( pathAlias ) ) . willReturn ( csv ) ; List < String > path = extractor . extractCorpusPath ( resultSet , pathAlias ) ; assertThat ( path , is ( asList ( path3 , path2 , path1 ) ) ) ; } } </s>
<s> package annis . sqlgen ; import static annis . test . TestUtils . size ; import static org . junit . Assert . assertThat ; import static org . junit . Assert . fail ; import static org . junit . matchers . JUnitMatchers . hasItems ; import static org . mockito . Mockito . mock ; import static org . mockito . Mockito . when ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import annis . service . objects . AnnisAttribute ; import annis . service . objects . AnnisAttribute ; public class TestListAnnotationsSqlHelper { private ListAnnotationsSqlHelper listNodeAnnotationsSqlHelper ; private static final String NULL = null ; private static final String NAME1 = "<STR_LIT>" ; private static final String NAME2 = "<STR_LIT>" ; private static final String NAME3 = "<STR_LIT>" ; private static final String VALUE1 = "<STR_LIT>" ; private static final String VALUE2 = "<STR_LIT>" ; private static final String VALUE3 = "<STR_LIT>" ; @ Before public void setup ( ) { listNodeAnnotationsSqlHelper = new ListAnnotationsSqlHelper ( ) ; } public void createSqlQueryNoEmptyCorpusList ( ) { try { listNodeAnnotationsSqlHelper . createSqlQuery ( null , true , true ) ; } catch ( IllegalArgumentException ex ) { return ; } fail ( "<STR_LIT>" ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) @ Test public void extractDataNoValues ( ) throws SQLException { ResultSet resultSet = mock ( ResultSet . class ) ; when ( resultSet . next ( ) ) . thenReturn ( true , true , false ) ; when ( resultSet . getString ( "<STR_LIT:name>" ) ) . thenReturn ( NAME1 , NAME2 ) ; when ( resultSet . getString ( "<STR_LIT:value>" ) ) . thenReturn ( NULL ) ; AnnisAttribute attribute1 = newNamedAnnisAttribute ( NAME1 ) ; AnnisAttribute attribute2 = newNamedAnnisAttribute ( NAME2 ) ; List < AnnisAttribute > annotations = ( List < AnnisAttribute > ) listNodeAnnotationsSqlHelper . extractData ( resultSet ) ; assertThat ( annotations , size ( <NUM_LIT:2> ) ) ; assertThat ( annotations , hasItems ( attribute1 , attribute2 ) ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) @ Test public void extractDataWithValues ( ) throws SQLException { ResultSet resultSet = mock ( ResultSet . class ) ; when ( resultSet . next ( ) ) . thenReturn ( true , true , true , true , true , false ) ; when ( resultSet . getString ( "<STR_LIT:name>" ) ) . thenReturn ( NAME1 , NAME1 , NAME1 , NAME2 , NAME3 ) ; when ( resultSet . getString ( "<STR_LIT:value>" ) ) . thenReturn ( VALUE1 , VALUE2 , VALUE3 , VALUE1 , NULL ) ; AnnisAttribute attribute1 = newNamedAnnisAttribute ( NAME1 , VALUE1 , VALUE2 , VALUE3 ) ; AnnisAttribute attribute2 = newNamedAnnisAttribute ( NAME2 , VALUE1 ) ; AnnisAttribute attribute3 = newNamedAnnisAttribute ( NAME3 ) ; List < AnnisAttribute > annotations = ( List < AnnisAttribute > ) listNodeAnnotationsSqlHelper . extractData ( resultSet ) ; assertThat ( annotations , size ( <NUM_LIT:3> ) ) ; assertThat ( annotations , hasItems ( attribute1 , attribute2 , attribute3 ) ) ; } private AnnisAttribute newNamedAnnisAttribute ( String name , String ... values ) { AnnisAttribute attribute = new AnnisAttribute ( ) ; attribute . setName ( name ) ; for ( String value : values ) attribute . addValue ( value ) ; return attribute ; } } </s>
<s> package annis . sqlgen ; import static annis . sqlgen . TableAccessStrategy . NODE_TABLE ; import static annis . test . TestUtils . uniqueInt ; import static annis . test . TestUtils . uniqueString ; import static java . util . Arrays . asList ; import static org . hamcrest . CoreMatchers . is ; import static org . hamcrest . CoreMatchers . nullValue ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . Matchers . anyString ; import static org . mockito . Mockito . mock ; import static org . mockito . MockitoAnnotations . initMocks ; import java . sql . Array ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . sql . Types ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; public class NodeNameAndIdPostgreSqlArraySolutionKeyTest { private SolutionKey < List < String > > key = new NodeNameAndIdPostgreSqlArraySolutionKey ( ) ; @ Mock private TableAccessStrategy tableAccessStrategy ; @ Mock private ResultSet resultSet ; @ Before public void setup ( ) { initMocks ( this ) ; } @ Test public void shouldGenerateColumnsForInnerQuery ( ) { String idAlias = uniqueString ( <NUM_LIT:3> ) ; String nameAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT:id>" ) ) . willReturn ( idAlias ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT:name>" ) ) . willReturn ( nameAlias ) ; int index = uniqueInt ( <NUM_LIT:1> , <NUM_LIT:10> ) ; List < String > actual = key . generateInnerQueryColumns ( tableAccessStrategy , index ) ; List < String > expected = asList ( idAlias + "<STR_LIT>" + index , nameAlias + "<STR_LIT>" + index ) ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldGenerateColumnsForOuterQuery ( ) { String idAlias = uniqueString ( <NUM_LIT:3> ) ; String nameAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . aliasedColumn ( "<STR_LIT>" , "<STR_LIT:id>" ) ) . willReturn ( idAlias ) ; given ( tableAccessStrategy . aliasedColumn ( "<STR_LIT>" , "<STR_LIT:name>" ) ) . willReturn ( nameAlias ) ; int size = <NUM_LIT:3> ; List < String > actual = key . generateOuterQueryColumns ( tableAccessStrategy , size ) ; List < String > expected = asList ( "<STR_LIT>" + idAlias + "<STR_LIT:1>" + "<STR_LIT:U+002CU+0020>" + idAlias + "<STR_LIT:2>" + "<STR_LIT:U+002CU+0020>" + idAlias + "<STR_LIT:3>" + "<STR_LIT>" , "<STR_LIT>" + nameAlias + "<STR_LIT:1>" + "<STR_LIT:U+002CU+0020>" + nameAlias + "<STR_LIT:2>" + "<STR_LIT:U+002CU+0020>" + nameAlias + "<STR_LIT:3>" + "<STR_LIT>" ) ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldRetreiveKeyFromResultSetAndValidateIt ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; String key2 = uniqueString ( <NUM_LIT:3> ) ; String key3 = uniqueString ( <NUM_LIT:3> ) ; Array array = createKeyJdbcArray ( key1 , key2 , key3 ) ; given ( resultSet . getArray ( "<STR_LIT>" ) ) . willReturn ( array ) ; List < String > actual = key . retrieveKey ( resultSet ) ; List < String > expected = asList ( key1 , key2 , key3 ) ; assertThat ( actual , is ( expected ) ) ; } private Array createKeyJdbcArray ( String ... keys ) throws SQLException { Array array = mock ( Array . class ) ; given ( array . getBaseType ( ) ) . willReturn ( Types . VARCHAR ) ; given ( array . getArray ( ) ) . willReturn ( keys ) ; return array ; } @ Test ( expected = IllegalStateException . class ) public void errorIfResultSetThrowsSqlException ( ) throws SQLException { given ( resultSet . getArray ( anyString ( ) ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; } @ Test ( expected = IllegalStateException . class ) public void errorIfKeyIsNull ( ) throws SQLException { given ( resultSet . wasNull ( ) ) . willReturn ( true ) ; key . retrieveKey ( resultSet ) ; } @ Test public void shouldSignalNewKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; String key2 = uniqueString ( <NUM_LIT:3> ) ; Array array1 = createKeyJdbcArray ( key1 ) ; Array array2 = createKeyJdbcArray ( key2 ) ; given ( resultSet . getArray ( "<STR_LIT>" ) ) . willReturn ( array1 , array2 ) ; key . retrieveKey ( resultSet ) ; resultSet . next ( ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . isNewKey ( ) , is ( true ) ) ; } @ Test public void shouldRecognizeOldKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; Array array1 = createKeyJdbcArray ( key1 ) ; Array array2 = createKeyJdbcArray ( key1 ) ; given ( resultSet . getArray ( "<STR_LIT>" ) ) . willReturn ( array1 , array2 ) ; key . retrieveKey ( resultSet ) ; resultSet . next ( ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . isNewKey ( ) , is ( false ) ) ; } @ Test public void shouldSignalMatchedNodes ( ) throws SQLException { String [ ] keys = { uniqueString ( <NUM_LIT:3> ) , uniqueString ( <NUM_LIT:3> ) , uniqueString ( <NUM_LIT:3> ) } ; Array array = createKeyJdbcArray ( keys ) ; given ( resultSet . getArray ( "<STR_LIT>" ) ) . willReturn ( array ) ; key . retrieveKey ( resultSet ) ; for ( int i = <NUM_LIT:0> ; i < keys . length ; ++ i ) { assertThat ( key . getMatchedNodeIndex ( keys [ i ] ) , is ( i + <NUM_LIT:1> ) ) ; } } @ Test public void shouldReturnNullForUnmatchedNodes ( ) throws SQLException { Array array = createKeyJdbcArray ( uniqueString ( ) ) ; given ( resultSet . getArray ( "<STR_LIT>" ) ) . willReturn ( array ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . getMatchedNodeIndex ( uniqueString ( ) ) , is ( nullValue ( ) ) ) ; } @ Test public void shouldCreateStringRepresentationOfKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; String key2 = uniqueString ( <NUM_LIT:3> ) ; String key3 = uniqueString ( <NUM_LIT:3> ) ; Array array = createKeyJdbcArray ( key1 , key2 , key3 ) ; given ( resultSet . getArray ( "<STR_LIT>" ) ) . willReturn ( array ) ; key . retrieveKey ( resultSet ) ; String actual = key . getCurrentKeyAsString ( ) ; String expected = key1 + "<STR_LIT:U+002C>" + key2 + "<STR_LIT:U+002C>" + key3 ; assertThat ( actual , is ( expected ) ) ; } } </s>
<s> package annis . sqlgen ; import static annis . sqlgen . TableAccessStrategy . NODE_TABLE ; import static annis . test . TestUtils . createJdbcArray ; import static annis . test . TestUtils . uniqueInt ; import static annis . test . TestUtils . uniqueString ; import static java . util . Arrays . asList ; import static org . hamcrest . CoreMatchers . is ; import static org . hamcrest . CoreMatchers . nullValue ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . Matchers . anyString ; import static org . mockito . MockitoAnnotations . initMocks ; import java . sql . Array ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; public class PostgreSqlArraySolutionKeyTest { private PostgreSqlArraySolutionKey < String > key = new PostgreSqlArraySolutionKey < String > ( ) ; @ Mock private TableAccessStrategy tableAccessStrategy ; @ Mock private ResultSet resultSet ; private static String idColumnName = uniqueString ( <NUM_LIT:3> ) ; private static String keyColumnName = uniqueString ( <NUM_LIT:3> ) ; @ Before public void setup ( ) { initMocks ( this ) ; key . setIdColumnName ( idColumnName ) ; key . setKeyColumnName ( keyColumnName ) ; } @ Test public void shouldGenerateColumnsForInnerQuery ( ) { String nameAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , idColumnName ) ) . willReturn ( nameAlias ) ; int index = uniqueInt ( <NUM_LIT:1> , <NUM_LIT:10> ) ; List < String > actual = key . generateInnerQueryColumns ( tableAccessStrategy , index ) ; List < String > expected = asList ( nameAlias + "<STR_LIT>" + idColumnName + index ) ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldGenerateColumnsForOuterQuery ( ) { String nameAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . aliasedColumn ( "<STR_LIT>" , idColumnName ) ) . willReturn ( nameAlias ) ; int size = <NUM_LIT:3> ; List < String > actual = key . generateOuterQueryColumns ( tableAccessStrategy , size ) ; List < String > expected = asList ( "<STR_LIT>" + nameAlias + "<STR_LIT:1>" + "<STR_LIT:U+002CU+0020>" + nameAlias + "<STR_LIT:2>" + "<STR_LIT:U+002CU+0020>" + nameAlias + "<STR_LIT:3>" + "<STR_LIT>" + keyColumnName ) ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldRetreiveKeyFromResultSet ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; String key2 = uniqueString ( <NUM_LIT:3> ) ; String key3 = uniqueString ( <NUM_LIT:3> ) ; Array array = createJdbcArray ( key1 , key2 , key3 ) ; given ( resultSet . getArray ( keyColumnName ) ) . willReturn ( array ) ; List < String > actual = key . retrieveKey ( resultSet ) ; List < String > expected = asList ( key1 , key2 , key3 ) ; assertThat ( actual , is ( expected ) ) ; } @ Test ( expected = IllegalStateException . class ) public void errorIfResultSetThrowsSqlExceptionInRetrieveKey ( ) throws SQLException { given ( resultSet . getArray ( anyString ( ) ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; } @ Test ( expected = IllegalStateException . class ) public void errorIfKeyIsNull ( ) throws SQLException { given ( resultSet . wasNull ( ) ) . willReturn ( true ) ; key . retrieveKey ( resultSet ) ; } @ Test public void shouldSignalNewKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; String key2 = uniqueString ( <NUM_LIT:3> ) ; Array array1 = createJdbcArray ( key1 ) ; Array array2 = createJdbcArray ( key2 ) ; given ( resultSet . getArray ( keyColumnName ) ) . willReturn ( array1 , array2 ) ; key . retrieveKey ( resultSet ) ; resultSet . next ( ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . isNewKey ( ) , is ( true ) ) ; } @ Test public void shouldRecognizeOldKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; Array array1 = createJdbcArray ( key1 ) ; Array array2 = createJdbcArray ( key1 ) ; given ( resultSet . getArray ( keyColumnName ) ) . willReturn ( array1 , array2 ) ; key . retrieveKey ( resultSet ) ; resultSet . next ( ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . isNewKey ( ) , is ( false ) ) ; } @ Test public void shouldSignalMatchedNodes ( ) throws SQLException { String [ ] keys = { uniqueString ( <NUM_LIT:3> ) , uniqueString ( <NUM_LIT:3> ) , uniqueString ( <NUM_LIT:3> ) } ; Array array = createJdbcArray ( keys ) ; given ( resultSet . getArray ( keyColumnName ) ) . willReturn ( array ) ; key . retrieveKey ( resultSet ) ; for ( int i = <NUM_LIT:0> ; i < keys . length ; ++ i ) { assertThat ( key . getMatchedNodeIndex ( keys [ i ] ) , is ( i + <NUM_LIT:1> ) ) ; } } @ Test public void shouldReturnNullForUnmatchedNodes ( ) throws SQLException { Array array = createJdbcArray ( uniqueString ( ) ) ; given ( resultSet . getArray ( keyColumnName ) ) . willReturn ( array ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . getMatchedNodeIndex ( uniqueString ( ) ) , is ( nullValue ( ) ) ) ; } @ Test public void shouldCreateStringRepresentationOfKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; String key2 = uniqueString ( <NUM_LIT:3> ) ; String key3 = uniqueString ( <NUM_LIT:3> ) ; Array array = createJdbcArray ( key1 , key2 , key3 ) ; given ( resultSet . getArray ( keyColumnName ) ) . willReturn ( array ) ; key . retrieveKey ( resultSet ) ; String actual = key . getCurrentKeyAsString ( ) ; String expected = key1 + "<STR_LIT:U+002C>" + key2 + "<STR_LIT:U+002C>" + key3 ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldReturnKeyArrayNameAsKeyColumn ( ) { List < String > keyColumns = key . getKeyColumns ( <NUM_LIT:0> ) ; assertThat ( keyColumns , is ( asList ( keyColumnName ) ) ) ; } } </s>
<s> package annis . sqlgen ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertTrue ; import static org . mockito . MockitoAnnotations . initMocks ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . Comparator ; import org . eclipse . emf . common . util . ECollections ; import org . eclipse . emf . common . util . EList ; import org . junit . Before ; import org . junit . Test ; import annis . test . CsvResultSetProvider ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . SaltProject ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . sCorpusStructure . SCorpusGraph ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . sDocumentStructure . SDocumentGraph ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . sDocumentStructure . SDominanceRelation ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . sDocumentStructure . SPointingRelation ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . sDocumentStructure . SSpanningRelation ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . sDocumentStructure . STextualRelation ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCore . SLayer ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCore . SNamedElement ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCore . SNode ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCore . SRelation ; public class SaltAnnotateExtractorTest { private CsvResultSetProvider resultSetProvider ; private PostgreSqlArraySolutionKey < String > solutionKey = new PostgreSqlArraySolutionKey < String > ( ) ; private SaltProject project ; @ Before public void setUp ( ) throws SQLException { initMocks ( this ) ; solutionKey . setKeyColumnName ( "<STR_LIT:key>" ) ; resultSetProvider = new CsvResultSetProvider ( getClass ( ) . getResourceAsStream ( "<STR_LIT>" ) ) ; ResultSet resultSet = resultSetProvider . getResultSet ( ) ; SaltAnnotateExtractor instance = new SaltAnnotateExtractor ( ) { protected SolutionKey < ? > createSolutionKey ( ) { return solutionKey ; } } ; CorpusPathExtractor corpusPathExtractor = new ArrayCorpusPathExtractor ( ) ; instance . setCorpusPathExtractor ( corpusPathExtractor ) ; TestAnnotateSqlGenerator . setupOuterQueryFactsTableColumnAliases ( instance ) ; project = instance . extractData ( resultSet ) ; assertNotNull ( project ) ; } @ Test public void testCorpusGraph ( ) throws Exception { assertEquals ( <NUM_LIT:1> , project . getSCorpusGraphs ( ) . size ( ) ) ; SCorpusGraph corpusGraph = project . getSCorpusGraphs ( ) . get ( <NUM_LIT:0> ) ; assertEquals ( <NUM_LIT:1> , corpusGraph . getSCorpora ( ) . size ( ) ) ; assertEquals ( "<STR_LIT>" , corpusGraph . getSCorpora ( ) . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( <NUM_LIT:1> , corpusGraph . getSDocuments ( ) . size ( ) ) ; assertEquals ( "<STR_LIT>" , corpusGraph . getSDocuments ( ) . get ( <NUM_LIT:0> ) . getSName ( ) ) ; } @ Test public void testLayerNames ( ) { SDocumentGraph g = project . getSCorpusGraphs ( ) . get ( <NUM_LIT:0> ) . getSDocuments ( ) . get ( <NUM_LIT:0> ) . getSDocumentGraph ( ) ; EList < SLayer > layers = g . getSLayers ( ) ; ECollections . sort ( layers , new NameComparator ( ) ) ; assertEquals ( <NUM_LIT:6> , layers . size ( ) ) ; assertEquals ( "<STR_LIT>" , layers . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , layers . get ( <NUM_LIT:1> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , layers . get ( <NUM_LIT:2> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , layers . get ( <NUM_LIT:3> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , layers . get ( <NUM_LIT:4> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , layers . get ( <NUM_LIT:5> ) . getSName ( ) ) ; } @ Test public void testLayerNodes ( ) { SDocumentGraph g = project . getSCorpusGraphs ( ) . get ( <NUM_LIT:0> ) . getSDocuments ( ) . get ( <NUM_LIT:0> ) . getSDocumentGraph ( ) ; EList < SNode > n = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSNodes ( ) ; ECollections . sort ( n , new NameComparator ( ) ) ; assertEquals ( <NUM_LIT:9> , n . size ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:1> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:2> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:3> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:4> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:5> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:6> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:7> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:8> ) . getSName ( ) ) ; n = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSNodes ( ) ; ECollections . sort ( n , new NameComparator ( ) ) ; assertEquals ( <NUM_LIT:5> , n . size ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:1> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:2> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:3> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:4> ) . getSName ( ) ) ; n = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSNodes ( ) ; ECollections . sort ( n , new NameComparator ( ) ) ; assertEquals ( <NUM_LIT:10> , n . size ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:1> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:2> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:3> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:4> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:5> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:6> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:7> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:8> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:9> ) . getSName ( ) ) ; n = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSNodes ( ) ; ECollections . sort ( n , new NameComparator ( ) ) ; assertEquals ( <NUM_LIT:12> , n . size ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:1> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:2> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:3> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:4> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:5> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:6> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:7> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:8> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:9> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:10> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:11> ) . getSName ( ) ) ; n = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSNodes ( ) ; ECollections . sort ( n , new NameComparator ( ) ) ; assertEquals ( <NUM_LIT:2> , n . size ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:0> ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , n . get ( <NUM_LIT:1> ) . getSName ( ) ) ; assertEquals ( <NUM_LIT:0> , g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSNodes ( ) . size ( ) ) ; } @ Test public void testLayerRelations ( ) { SDocumentGraph g = project . getSCorpusGraphs ( ) . get ( <NUM_LIT:0> ) . getSDocuments ( ) . get ( <NUM_LIT:0> ) . getSDocumentGraph ( ) ; EList < SRelation > e = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSRelations ( ) ; ECollections . sort ( e , new EdgeComparator ( ) ) ; assertEquals ( <NUM_LIT:9> , e . size ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:0> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:0> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:1> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:1> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:2> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:2> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:3> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:3> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:4> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:4> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:5> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:5> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:6> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:6> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:7> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:7> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:8> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:8> ) . getSTarget ( ) . getSName ( ) ) ; e = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSRelations ( ) ; ECollections . sort ( e , new EdgeComparator ( ) ) ; assertEquals ( <NUM_LIT:30> , e . size ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:0> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:0> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:1> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:1> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:2> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:2> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:3> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:3> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:4> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:4> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:5> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:5> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:6> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:6> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:7> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:7> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:8> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:8> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:9> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:9> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:10> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:10> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:11> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:11> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:12> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:12> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:15> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:15> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:16> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:16> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:20> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:20> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:24> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:24> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; e = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSRelations ( ) ; ECollections . sort ( e , new EdgeComparator ( ) ) ; assertEquals ( <NUM_LIT> , e . size ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:2> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:2> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:3> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:3> ) . getSTarget ( ) . getSName ( ) ) ; e = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSRelations ( ) ; ECollections . sort ( e , new EdgeComparator ( ) ) ; assertEquals ( <NUM_LIT> , e . size ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT> ) . getSTarget ( ) . getSName ( ) ) ; e = g . getSLayerByName ( "<STR_LIT>" ) . get ( <NUM_LIT:0> ) . getSRelations ( ) ; ECollections . sort ( e , new EdgeComparator ( ) ) ; assertEquals ( <NUM_LIT:12> , e . size ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:0> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:0> ) . getSTarget ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:6> ) . getSSource ( ) . getSName ( ) ) ; assertEquals ( "<STR_LIT>" , e . get ( <NUM_LIT:6> ) . getSTarget ( ) . getSName ( ) ) ; } @ Test public void testRelationType ( ) { SDocumentGraph g = project . getSCorpusGraphs ( ) . get ( <NUM_LIT:0> ) . getSDocuments ( ) . get ( <NUM_LIT:0> ) . getSDocumentGraph ( ) ; for ( SRelation r : g . getSRelations ( ) ) { if ( ! ( r instanceof STextualRelation ) ) { assertEquals ( <NUM_LIT:1> , r . getSLayers ( ) . size ( ) ) ; String layerName = r . getSLayers ( ) . get ( <NUM_LIT:0> ) . getSName ( ) ; if ( "<STR_LIT>" . equals ( layerName ) || "<STR_LIT>" . equals ( layerName ) || "<STR_LIT>" . equals ( layerName ) ) { assertTrue ( "<STR_LIT>" , r instanceof SSpanningRelation ) ; } else if ( "<STR_LIT>" . equals ( layerName ) ) { assertTrue ( "<STR_LIT>" , r instanceof SPointingRelation ) ; } else if ( "<STR_LIT>" . equals ( layerName ) ) { assertTrue ( "<STR_LIT>" , r instanceof SDominanceRelation ) ; } } } } public static class NameComparator implements Comparator < SNamedElement > { @ Override public int compare ( SNamedElement arg0 , SNamedElement arg1 ) { return arg0 . getSName ( ) . compareTo ( arg1 . getSName ( ) ) ; } } public static class EdgeComparator implements Comparator < SRelation > { @ Override public int compare ( SRelation arg0 , SRelation arg1 ) { int result = arg0 . getSSource ( ) . getSName ( ) . compareTo ( arg1 . getSSource ( ) . getSName ( ) ) ; if ( result == <NUM_LIT:0> ) { result = arg0 . getSTarget ( ) . getSName ( ) . compareTo ( arg1 . getSTarget ( ) . getSName ( ) ) ; } if ( result == <NUM_LIT:0> ) { String t0 = arg0 . getSTypes ( ) != null && arg0 . getSTypes ( ) . size ( ) > <NUM_LIT:0> ? arg0 . getSTypes ( ) . get ( <NUM_LIT:0> ) : null ; String t1 = arg1 . getSTypes ( ) != null && arg1 . getSTypes ( ) . size ( ) > <NUM_LIT:0> ? arg1 . getSTypes ( ) . get ( <NUM_LIT:0> ) : null ; if ( t0 == null && t1 == null ) { result = <NUM_LIT:0> ; } else if ( t0 == null && t1 != null ) { result = - <NUM_LIT:1> ; } else if ( t0 != null && t1 == null ) { result = + <NUM_LIT:1> ; } else { result = t0 . compareTo ( t1 ) ; } } return result ; } } } </s>
<s> package annis . sqlgen ; import static org . hamcrest . CoreMatchers . is ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . MockitoAnnotations . initMocks ; import static annis . test . TestUtils . uniqueInt ; import static annis . test . TestUtils . uniqueLong ; import static annis . test . TestUtils . uniqueString ; import java . util . HashMap ; import java . util . List ; import org . apache . commons . collections . Bag ; import org . apache . commons . collections . bag . HashBag ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Spy ; import annis . model . QueryNode ; import annis . ql . parser . QueryData ; public class TestAbstractFromClauseGenerator { private AbstractFromClauseGenerator generator ; @ Spy private TableAccessStrategy tableAccessStrategy = new TableAccessStrategy ( ) ; @ Before public void setup ( ) { initMocks ( this ) ; generator = new AbstractFromClauseGenerator ( ) { @ Override public String fromClause ( QueryData queryData , List < QueryNode > alternative , String indent ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } @ Override protected TableAccessStrategy createTableAccessStrategy ( ) { return tableAccessStrategy ; } } ; } @ Test public void shouldCreateTableAliasWithoutCount ( ) { long id = uniqueLong ( ) ; QueryNode node = new QueryNode ( id ) ; String table = uniqueString ( ) ; String tableAlias = uniqueString ( ) ; int count = <NUM_LIT:1> ; setupTableAliases ( table , tableAlias , count ) ; String alias = generator . tableAliasDefinition ( node , table , count ) ; String expected = tableAlias + "<STR_LIT>" + tableAlias + id ; assertThat ( alias , is ( expected ) ) ; } @ Test public void shouldCreateTableAliasWithCount ( ) { long id = uniqueLong ( ) ; QueryNode node = new QueryNode ( id ) ; String table = uniqueString ( ) ; String tableAlias = uniqueString ( ) ; int count = uniqueInt ( ) ; setupTableAliases ( table , tableAlias , count ) ; String alias = generator . tableAliasDefinition ( node , table , count ) ; String expected = tableAlias + "<STR_LIT>" + tableAlias + id + "<STR_LIT:_>" + count ; assertThat ( alias , is ( expected ) ) ; } private void setupTableAliases ( String table , String tableAlias , int count ) { HashMap < String , String > tableAliases = new HashMap < String , String > ( ) ; tableAliases . put ( table , tableAlias ) ; tableAccessStrategy . setTableAliases ( tableAliases ) ; Bag tables = new HashBag ( ) ; tables . add ( tableAlias , count ) ; given ( tableAccessStrategy . computeSourceTables ( ) ) . willReturn ( tables ) ; } } </s>
<s> package annis . sqlgen ; import static annis . sqlgen . TableAccessStrategy . NODE_TABLE ; import static annis . test . TestUtils . uniqueInt ; import static annis . test . TestUtils . uniqueString ; import static java . util . Arrays . asList ; import static org . hamcrest . CoreMatchers . is ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . Matchers . anyString ; import static org . mockito . Matchers . anyInt ; import static org . mockito . MockitoAnnotations . initMocks ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; public class AbstractSolutionKeyTest { AbstractSolutionKey < Integer > key = new AbstractSolutionKey < Integer > ( ) ; @ Mock private TableAccessStrategy tableAccessStrategy ; @ Mock private ResultSet resultSet ; private static String idColumnName = uniqueString ( <NUM_LIT:3> ) ; @ Before public void setup ( ) { initMocks ( this ) ; key . setIdColumnName ( idColumnName ) ; } @ Test public void shouldGenerateColumnsForInnerQuery ( ) { String nameAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , idColumnName ) ) . willReturn ( nameAlias ) ; int index = uniqueInt ( <NUM_LIT:1> , <NUM_LIT:10> ) ; List < String > actual = key . generateInnerQueryColumns ( tableAccessStrategy , index ) ; List < String > expected = asList ( nameAlias + "<STR_LIT>" + idColumnName + index ) ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldReturnTheIdOfTheNode ( ) throws SQLException { Object expected = new Object ( ) ; String idAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . columnName ( NODE_TABLE , idColumnName ) ) . willReturn ( idAlias ) ; given ( resultSet . getObject ( <NUM_LIT:1> ) ) . willReturn ( expected ) ; given ( resultSet . findColumn ( idAlias ) ) . willReturn ( <NUM_LIT:1> ) ; given ( resultSet . getObject ( idAlias ) ) . willReturn ( expected ) ; Object actual = key . getNodeId ( resultSet , tableAccessStrategy ) ; assertThat ( actual , is ( expected ) ) ; } @ Test ( expected = IllegalStateException . class ) public void errorIfResultSetThrowsSqlExceptionInGetNodeId ( ) throws SQLException { given ( resultSet . getObject ( anyString ( ) ) ) . willThrow ( new SQLException ( ) ) ; given ( resultSet . getObject ( anyInt ( ) ) ) . willThrow ( new SQLException ( ) ) ; key . getNodeId ( resultSet , tableAccessStrategy ) ; } } </s>
<s> package annis . sqlgen ; import static annis . test . TestUtils . uniqueInt ; import static annis . test . TestUtils . uniqueString ; import static java . util . Arrays . asList ; import static org . hamcrest . CoreMatchers . is ; import static org . hamcrest . CoreMatchers . nullValue ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . Matchers . anyString ; import static org . mockito . MockitoAnnotations . initMocks ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; public class MultipleColumnsSolutionKeyTest { private MultipleColumnsSolutionKey < Integer > key = new MultipleColumnsSolutionKey < Integer > ( ) ; @ Mock private TableAccessStrategy tableAccessStrategy ; @ Mock private ResultSet resultSet ; private static String idColumnName = uniqueString ( <NUM_LIT:3> ) ; private static String keyColumnName = uniqueString ( <NUM_LIT:3> ) ; @ Before public void setup ( ) { initMocks ( this ) ; key . setIdColumnName ( idColumnName ) ; key . setKeyColumnName ( keyColumnName ) ; } @ Test public void shouldGenerateColumnsForOuterQuery ( ) { String nameAlias = uniqueString ( <NUM_LIT:3> ) ; given ( tableAccessStrategy . aliasedColumn ( "<STR_LIT>" , idColumnName ) ) . willReturn ( nameAlias ) ; int size = <NUM_LIT:3> ; List < String > actual = key . generateOuterQueryColumns ( tableAccessStrategy , size ) ; List < String > expected = asList ( nameAlias + "<STR_LIT:1>" + "<STR_LIT>" + keyColumnName + "<STR_LIT:1>" , nameAlias + "<STR_LIT:2>" + "<STR_LIT>" + keyColumnName + "<STR_LIT:2>" , nameAlias + "<STR_LIT:3>" + "<STR_LIT>" + keyColumnName + "<STR_LIT:3>" ) ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldRetreiveKeyFromResultSetAndValidateIt ( ) throws SQLException { int key1 = uniqueInt ( <NUM_LIT:3> ) ; int key2 = uniqueInt ( <NUM_LIT:3> ) ; int key3 = uniqueInt ( <NUM_LIT:3> ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:1> ) ) . willReturn ( key1 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:2> ) ) . willReturn ( key2 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:3> ) ) . willReturn ( key3 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:4> ) ) . willThrow ( new SQLException ( ) ) ; List < Integer > actual = key . retrieveKey ( resultSet ) ; List < Integer > expected = asList ( key1 , key2 , key3 ) ; assertThat ( actual , is ( expected ) ) ; } @ Test ( expected = IllegalStateException . class ) public void errorIfResultSetThrowsSqlExceptionInRetrieveKey ( ) throws SQLException { given ( resultSet . getObject ( anyString ( ) ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; } @ Test public void shouldSignalNewKey ( ) throws SQLException { int key1 = uniqueInt ( <NUM_LIT:1> , <NUM_LIT:3> ) ; int key2 = uniqueInt ( <NUM_LIT:4> , <NUM_LIT:6> ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:1> ) ) . willReturn ( key1 , key2 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:2> ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; resultSet . next ( ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . isNewKey ( ) , is ( true ) ) ; } @ Test public void shouldRecognizeOldKey ( ) throws SQLException { String key1 = uniqueString ( <NUM_LIT:3> ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:1> ) ) . willReturn ( key1 , key1 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:2> ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; resultSet . next ( ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . isNewKey ( ) , is ( false ) ) ; } @ Test public void shouldSignalMatchedNodes ( ) throws SQLException { int [ ] keys = { uniqueInt ( <NUM_LIT:1> , <NUM_LIT:3> ) , uniqueInt ( <NUM_LIT:4> , <NUM_LIT:6> ) , uniqueInt ( <NUM_LIT:7> , <NUM_LIT:9> ) } ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:1> ) ) . willReturn ( keys [ <NUM_LIT:0> ] ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:2> ) ) . willReturn ( keys [ <NUM_LIT:1> ] ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:3> ) ) . willReturn ( keys [ <NUM_LIT:2> ] ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:4> ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; for ( int i = <NUM_LIT:0> ; i < keys . length ; ++ i ) { assertThat ( key . getMatchedNodeIndex ( keys [ i ] ) , is ( i + <NUM_LIT:1> ) ) ; } } @ Test public void shouldReturnNullForUnmatchedNodes ( ) throws SQLException { int key1 = uniqueInt ( <NUM_LIT:1> , <NUM_LIT:3> ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:1> ) ) . willReturn ( key1 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:2> ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; assertThat ( key . getMatchedNodeIndex ( uniqueInt ( <NUM_LIT:4> , <NUM_LIT:6> ) ) , is ( nullValue ( ) ) ) ; } @ Test public void shouldCreateStringRepresentationOfKey ( ) throws SQLException { int key1 = uniqueInt ( <NUM_LIT:3> ) ; int key2 = uniqueInt ( <NUM_LIT:3> ) ; int key3 = uniqueInt ( <NUM_LIT:3> ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:1> ) ) . willReturn ( key1 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:2> ) ) . willReturn ( key2 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:3> ) ) . willReturn ( key3 ) ; given ( resultSet . getObject ( keyColumnName + <NUM_LIT:4> ) ) . willThrow ( new SQLException ( ) ) ; key . retrieveKey ( resultSet ) ; String actual = key . getCurrentKeyAsString ( ) ; String expected = key1 + "<STR_LIT:U+002C>" + key2 + "<STR_LIT:U+002C>" + key3 ; assertThat ( actual , is ( expected ) ) ; } @ Test public void shouldReturnKeyArrayNameAsKeyColumn ( ) { int size = <NUM_LIT:3> ; List < String > keyColumns = key . getKeyColumns ( size ) ; assertThat ( keyColumns , is ( asList ( keyColumnName + <NUM_LIT:1> , keyColumnName + <NUM_LIT:2> , keyColumnName + <NUM_LIT:3> ) ) ) ; } } </s>
<s> package annis . sqlgen ; import static annis . sqlgen . AbstractSqlGenerator . TABSTOP ; import static annis . sqlgen . TableAccessStrategy . NODE_TABLE ; import static annis . test . TestUtils . newSet ; import static annis . test . TestUtils . uniqueAlphaString ; import static annis . test . TestUtils . uniqueInt ; import static java . util . Arrays . asList ; import static org . hamcrest . CoreMatchers . is ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . MockitoAnnotations . initMocks ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import org . mockito . InjectMocks ; import org . mockito . Mock ; import annis . model . QueryNode ; import annis . ql . parser . QueryData ; public class TestAnnotateInnerQuerySqlGenerator { @ InjectMocks private AnnotateInnerQuerySqlGenerator generator = new AnnotateInnerQuerySqlGenerator ( ) { @ Override protected TableAccessStrategy createTableAccessStrategy ( ) { return tableAccessStrategy ; } } ; @ Mock private TableAccessStrategy tableAccessStrategy ; @ Mock private SolutionKey key ; @ Mock private QueryData queryData ; @ Mock private AnnotateQueryData annotateQueryData ; private List < QueryNode > alternative = new ArrayList < QueryNode > ( ) ; private static final String INDENT = TABSTOP ; @ Before public void setup ( ) { initMocks ( this ) ; } @ Test public void shouldGenerateSelectClause ( ) { alternative = Collections . nCopies ( <NUM_LIT:2> , new QueryNode ( ) ) ; int left = uniqueInt ( <NUM_LIT:10> ) ; int right = uniqueInt ( <NUM_LIT:20> ) ; List extensions = new ArrayList < AnnotateQueryData > ( ) ; extensions . add ( annotateQueryData ) ; given ( annotateQueryData . getLeft ( ) ) . willReturn ( left ) ; given ( annotateQueryData . getRight ( ) ) . willReturn ( right ) ; given ( queryData . getExtensions ( AnnotateQueryData . class ) ) . willReturn ( extensions ) ; String key1Column1 = uniqueAlphaString ( ) ; String key1Column2 = uniqueAlphaString ( ) ; String key2Column1 = uniqueAlphaString ( ) ; String key2Column2 = uniqueAlphaString ( ) ; given ( key . generateInnerQueryColumns ( tableAccessStrategy , <NUM_LIT:1> ) ) . willReturn ( asList ( key1Column1 , key1Column2 ) ) ; given ( key . generateInnerQueryColumns ( tableAccessStrategy , <NUM_LIT:2> ) ) . willReturn ( asList ( key2Column1 , key2Column2 ) ) ; String textRefAlias1 = uniqueAlphaString ( ) ; String leftTokenAlias1 = uniqueAlphaString ( ) ; String rightTokenAlias1 = uniqueAlphaString ( ) ; String textRefAlias2 = uniqueAlphaString ( ) ; String leftTokenAlias2 = uniqueAlphaString ( ) ; String rightTokenAlias2 = uniqueAlphaString ( ) ; String corpusRefAlias1 = uniqueAlphaString ( ) ; String corpusRefAlias2 = uniqueAlphaString ( ) ; String nodeNameAlias1 = uniqueAlphaString ( ) ; String nodeNameAlias2 = uniqueAlphaString ( ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT>" ) ) . willReturn ( textRefAlias1 , textRefAlias2 ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT>" ) ) . willReturn ( leftTokenAlias1 , leftTokenAlias2 ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT>" ) ) . willReturn ( rightTokenAlias1 , rightTokenAlias2 ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT>" ) ) . willReturn ( corpusRefAlias1 , corpusRefAlias2 ) ; given ( tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT:name>" ) ) . willReturn ( nodeNameAlias1 , nodeNameAlias2 ) ; String actual = generator . selectClause ( queryData , alternative , INDENT ) ; String expected = "<STR_LIT>" + "<STR_LIT:n>" + INDENT + TABSTOP + key1Column1 + "<STR_LIT:U+002CU+0020>" + key1Column2 + "<STR_LIT:U+002CU+0020>" + textRefAlias1 + "<STR_LIT>" + "<STR_LIT:text>" + <NUM_LIT:1> + "<STR_LIT:U+002CU+0020>" + leftTokenAlias1 + "<STR_LIT:U+0020-U+0020>" + left + "<STR_LIT>" + "<STR_LIT>" + <NUM_LIT:1> + "<STR_LIT:U+002CU+0020>" + rightTokenAlias1 + "<STR_LIT>" + right + "<STR_LIT>" + "<STR_LIT>" + <NUM_LIT:1> + "<STR_LIT:U+002CU+0020>" + corpusRefAlias1 + "<STR_LIT>" + nodeNameAlias1 + "<STR_LIT>" + "<STR_LIT:n>" + INDENT + TABSTOP + key2Column1 + "<STR_LIT:U+002CU+0020>" + key2Column2 + "<STR_LIT:U+002CU+0020>" + textRefAlias2 + "<STR_LIT>" + "<STR_LIT:text>" + <NUM_LIT:2> + "<STR_LIT:U+002CU+0020>" + leftTokenAlias2 + "<STR_LIT:U+0020-U+0020>" + left + "<STR_LIT>" + "<STR_LIT>" + <NUM_LIT:2> + "<STR_LIT:U+002CU+0020>" + rightTokenAlias2 + "<STR_LIT>" + right + "<STR_LIT>" + "<STR_LIT>" + <NUM_LIT:2> + "<STR_LIT:U+002CU+0020>" + corpusRefAlias2 + "<STR_LIT>" + nodeNameAlias2 + "<STR_LIT>" ; assertThat ( actual , is ( expected ) ) ; } } </s>
<s> package annis . sqlgen ; import static annis . sqlgen . TableAccessStrategy . COMPONENT_TABLE ; import static annis . sqlgen . TableAccessStrategy . EDGE_ANNOTATION_TABLE ; import static annis . sqlgen . TableAccessStrategy . NODE_ANNOTATION_TABLE ; import static annis . sqlgen . TableAccessStrategy . NODE_TABLE ; import static annis . sqlgen . TableAccessStrategy . RANK_TABLE ; import static org . junit . Assert . assertEquals ; import static org . mockito . Mockito . mock ; import static org . mockito . Mockito . when ; import static org . mockito . MockitoAnnotations . initMocks ; import java . util . Set ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; import annis . model . QueryNode ; import annis . model . QueryAnnotation ; public class TestTableJoinsInFromClauseSqlGenerator { private TableJoinsInFromClauseSqlGenerator tableJoinsInFromClauseSqlGenerator ; private TableAccessStrategy tableAccessStrategy ; private QueryNode node23 ; @ Mock Set < QueryAnnotation > annotations ; @ Before public void setup ( ) { initMocks ( this ) ; tableJoinsInFromClauseSqlGenerator = new TableJoinsInFromClauseSqlGenerator ( ) { @ Override protected TableAccessStrategy createTableAccessStrategy ( ) { return tableAccessStrategy ; } } ; node23 = new QueryNode ( <NUM_LIT> ) ; when ( annotations . size ( ) ) . thenReturn ( <NUM_LIT:3> ) ; tableAccessStrategy = new TableAccessStrategy ( node23 ) ; tableAccessStrategy . addTableAlias ( NODE_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , "<STR_LIT>" ) ; } @ Test public void fromClauseDefault ( ) { String expected = "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseUsesRank ( ) { node23 . setRoot ( true ) ; String expected = "<STR_LIT>" + "<STR_LIT:U+0020>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseUsesComponent ( ) { node23 . setPartOfEdge ( true ) ; String expected = "<STR_LIT>" + "<STR_LIT:U+0020>" + "<STR_LIT>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseUsesRankAndComponentAliasedToNode ( ) { node23 . setRoot ( true ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , "<STR_LIT>" ) ; String expected = "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseNodeAnnotations ( ) { node23 . setNodeAnnotations ( annotations ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseNodeAnnotationsAliasedToNode ( ) { node23 . setNodeAnnotations ( annotations ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addColumnAlias ( NODE_ANNOTATION_TABLE , "<STR_LIT>" , "<STR_LIT:id>" ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseOfEdgeAnnotations ( ) { node23 . setEdgeAnnotations ( annotations ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } @ Test public void fromClauseEdgeAnnotationsAliasedToNode ( ) { node23 . setEdgeAnnotations ( annotations ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addColumnAlias ( EDGE_ANNOTATION_TABLE , "<STR_LIT>" , "<STR_LIT>" ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) @ Test public void fromClauseTablesAliasedToNode ( ) { Set < QueryAnnotation > annotations1 = mock ( Set . class ) ; when ( annotations1 . size ( ) ) . thenReturn ( <NUM_LIT:2> ) ; node23 . setNodeAnnotations ( annotations1 ) ; Set < QueryAnnotation > annotations2 = mock ( Set . class ) ; when ( annotations2 . size ( ) ) . thenReturn ( <NUM_LIT:3> ) ; node23 . setEdgeAnnotations ( annotations2 ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addColumnAlias ( NODE_ANNOTATION_TABLE , "<STR_LIT>" , "<STR_LIT:id>" ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , "<STR_LIT>" ) ; tableAccessStrategy . addColumnAlias ( EDGE_ANNOTATION_TABLE , "<STR_LIT>" , "<STR_LIT>" ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertFromClause ( expected ) ; } private void assertFromClause ( String expected ) { assertEquals ( expected , tableJoinsInFromClauseSqlGenerator . fromClauseForNode ( node23 , false ) ) ; } } </s>
<s> package annis . sqlgen ; import static org . hamcrest . CoreMatchers . is ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . Mockito . * ; import static org . mockito . MockitoAnnotations . initMocks ; import static annis . test . TestUtils . emptySetOf ; import static annis . test . TestUtils . newSet ; import static annis . test . TestUtils . uniqueString ; import java . sql . ResultSet ; import java . sql . SQLException ; import java . util . ArrayList ; import java . util . List ; import org . junit . Before ; import org . junit . Test ; import org . mockito . InjectMocks ; import org . mockito . Mock ; import org . mockito . Spy ; import org . springframework . dao . DataAccessException ; import annis . model . QueryNode ; import annis . ql . parser . QueryData ; import java . util . LinkedList ; public class TestAbstractSqlGenerator { @ InjectMocks private AbstractSqlGenerator < ? > generator ; @ Mock private WithClauseSqlGenerator < QueryData > withClauseSqlGenerator ; @ Mock private SelectClauseSqlGenerator < QueryData > selectClauseSqlGenerator ; @ Mock private FromClauseSqlGenerator < QueryData > fromClauseSqlGenerator ; @ Spy private List < FromClauseSqlGenerator < QueryData > > fromClauseSqlGenerators = new ArrayList < FromClauseSqlGenerator < QueryData > > ( ) ; @ Mock private WhereClauseSqlGenerator < QueryData > whereClauseSqlGenerator ; @ Spy private List < WhereClauseSqlGenerator < QueryData > > whereClauseSqlGenerators = new ArrayList < WhereClauseSqlGenerator < QueryData > > ( ) ; private QueryData queryData = new QueryData ( ) ; private QueryNode annisNode = new QueryNode ( ) ; private List < QueryNode > alternative = new ArrayList < QueryNode > ( ) ; private List < List < QueryNode > > alternatives = new ArrayList < List < QueryNode > > ( ) ; @ Before public void setup ( ) { generator = new AbstractSqlGenerator < Object > ( ) { @ Override public Object extractData ( ResultSet rs ) throws SQLException , DataAccessException { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } } ; initMocks ( this ) ; fromClauseSqlGenerators . add ( fromClauseSqlGenerator ) ; whereClauseSqlGenerators . add ( whereClauseSqlGenerator ) ; generator . setSelectClauseSqlGenerator ( selectClauseSqlGenerator ) ; generator . setFromClauseSqlGenerators ( fromClauseSqlGenerators ) ; generator . setWhereClauseSqlGenerators ( whereClauseSqlGenerators ) ; generator . setWithClauseSqlGenerator ( withClauseSqlGenerator ) ; alternative . add ( annisNode ) ; alternatives . add ( alternative ) ; queryData . setAlternatives ( alternatives ) ; } @ Test ( expected = IllegalArgumentException . class ) public void errorIfZeroAlternativesInQueryData ( ) { alternatives . clear ( ) ; generator . toSql ( queryData ) ; } @ Test public void shouldAppendSelectAndFromClauseForMinimalQuery ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldJoinMultipleFromClausesWithComma ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String fromClause2 = uniqueString ( ) ; FromClauseSqlGenerator fromClauseSqlGenerator2 = mock ( FromClauseSqlGenerator . class ) ; given ( fromClauseSqlGenerator2 . fromClause ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( fromClause2 ) ; fromClauseSqlGenerators . add ( fromClauseSqlGenerator2 ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; expected = expected . substring ( <NUM_LIT:0> , expected . length ( ) - <NUM_LIT:1> ) ; expected += "<STR_LIT>" + "<STR_LIT:U+0020U+0020>" + fromClause2 + "<STR_LIT:n>" ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldAppendWithClause ( ) { LinkedList < String > clauses = new LinkedList < String > ( ) ; clauses . add ( "<STR_LIT>" ) ; clauses . add ( "<STR_LIT>" ) ; clauses . add ( "<STR_LIT>" ) ; when ( withClauseSqlGenerator . withClauses ( any ( QueryData . class ) , anyListOf ( QueryNode . class ) , anyString ( ) ) ) . thenReturn ( clauses ) ; String sql = generator . toSql ( queryData ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldAndWhereConditionsFromOneWhereClauseSqlGenerator ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String whereCondition1 = "<STR_LIT:a>" + uniqueString ( ) ; String whereCondition2 = "<STR_LIT:b>" + uniqueString ( ) ; given ( whereClauseSqlGenerator . whereConditions ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( newSet ( whereCondition1 , whereCondition2 ) ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; expected += "<STR_LIT>" + "<STR_LIT:U+0020U+0020>" + whereCondition1 + "<STR_LIT>" + "<STR_LIT:U+0020U+0020>" + whereCondition2 + "<STR_LIT:n>" ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldAndWhereConditionsFromMultipeWhereClauseSqlGenerators ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String whereCondition1 = "<STR_LIT:a>" + uniqueString ( ) ; String whereCondition2 = "<STR_LIT:b>" + uniqueString ( ) ; given ( whereClauseSqlGenerator . whereConditions ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( newSet ( whereCondition1 ) ) ; WhereClauseSqlGenerator whereClauseSqlGenerator2 = mock ( WhereClauseSqlGenerator . class ) ; given ( whereClauseSqlGenerator2 . whereConditions ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( newSet ( whereCondition2 ) ) ; whereClauseSqlGenerators . add ( whereClauseSqlGenerator2 ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; expected += "<STR_LIT>" + "<STR_LIT:U+0020U+0020>" + whereCondition1 + "<STR_LIT>" + "<STR_LIT:U+0020U+0020>" + whereCondition2 + "<STR_LIT:n>" ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldNotAppendWhereConditionIfEmpty ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; given ( whereClauseSqlGenerator . whereConditions ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( emptySetOf ( String . class ) ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldAppendGroupByClause ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String groupBy = uniqueString ( ) ; GroupByClauseSqlGenerator groupByClauseSqlGenerator = mock ( GroupByClauseSqlGenerator . class ) ; generator . setGroupByClauseSqlGenerator ( groupByClauseSqlGenerator ) ; given ( groupByClauseSqlGenerator . groupByAttributes ( eq ( queryData ) , eq ( alternative ) ) ) . willReturn ( groupBy ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; expected += "<STR_LIT>" + groupBy + "<STR_LIT:n>" ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldAppendOrderByClause ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String orderBy = uniqueString ( ) ; OrderByClauseSqlGenerator orderByClauseSqlGenerator = mock ( OrderByClauseSqlGenerator . class ) ; generator . setOrderByClauseSqlGenerator ( orderByClauseSqlGenerator ) ; given ( orderByClauseSqlGenerator . orderByClause ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( orderBy ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; expected += "<STR_LIT>" + orderBy + "<STR_LIT:n>" ; assertThat ( sql , is ( expected ) ) ; } @ Test public void shouldAppendLimitAndOffsetClause ( ) { String selectClause = uniqueString ( ) ; String fromClause = uniqueString ( ) ; setupSelectAndFromClause ( selectClause , fromClause ) ; String limitOffset = uniqueString ( ) ; LimitOffsetClauseSqlGenerator limitOffsetClauseSqlGenerator = mock ( LimitOffsetClauseSqlGenerator . class ) ; generator . setLimitOffsetClauseSqlGenerator ( limitOffsetClauseSqlGenerator ) ; given ( limitOffsetClauseSqlGenerator . limitOffsetClause ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( limitOffset ) ; String sql = generator . toSql ( queryData ) ; String expected = createMinimalSqlStatement ( selectClause , fromClause ) ; expected += limitOffset + "<STR_LIT:n>" ; assertThat ( sql , is ( expected ) ) ; } private void setupSelectAndFromClause ( String selectClause , String fromClause ) { given ( selectClauseSqlGenerator . selectClause ( eq ( queryData ) , anyListOf ( QueryNode . class ) , anyString ( ) ) ) . willReturn ( selectClause ) ; given ( fromClauseSqlGenerator . fromClause ( eq ( queryData ) , eq ( alternative ) , anyString ( ) ) ) . willReturn ( fromClause ) ; } private String createMinimalSqlStatement ( String selectClause , String fromClause ) { String expected = "<STR_LIT>" + selectClause + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT:U+0020U+0020>" + fromClause + "<STR_LIT:n>" ; return expected ; } } </s>
<s> package annis . sqlgen ; import static annis . sqlgen . TableAccessStrategy . COMPONENT_TABLE ; import static annis . sqlgen . TableAccessStrategy . EDGE_ANNOTATION_TABLE ; import static annis . sqlgen . TableAccessStrategy . NODE_ANNOTATION_TABLE ; import static annis . sqlgen . TableAccessStrategy . NODE_TABLE ; import static annis . sqlgen . TableAccessStrategy . RANK_TABLE ; import static org . hamcrest . Matchers . is ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertThat ; import static org . mockito . Mockito . mock ; import static org . mockito . Mockito . when ; import static org . mockito . MockitoAnnotations . initMocks ; import java . util . HashMap ; import java . util . Map ; import java . util . Set ; import org . apache . commons . collections . Bag ; import org . hamcrest . Description ; import org . hamcrest . Matcher ; import org . hamcrest . TypeSafeMatcher ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; import annis . model . QueryNode ; import annis . model . QueryAnnotation ; public class TestTableAccessStrategy { private Map < String , Integer > expected ; private TableAccessStrategy tableAccessStrategy ; @ Mock private QueryNode node23 ; @ Mock private Set < QueryAnnotation > annotations ; @ Before public void setup ( ) { initMocks ( this ) ; when ( node23 . getId ( ) ) . thenReturn ( <NUM_LIT> ) ; when ( annotations . size ( ) ) . thenReturn ( <NUM_LIT:3> ) ; tableAccessStrategy = new TableAccessStrategy ( node23 ) ; expected = new HashMap < String , Integer > ( ) ; expected . put ( NODE_TABLE , <NUM_LIT:0> ) ; expected . put ( RANK_TABLE , <NUM_LIT:0> ) ; expected . put ( COMPONENT_TABLE , <NUM_LIT:0> ) ; expected . put ( NODE_ANNOTATION_TABLE , <NUM_LIT:0> ) ; expected . put ( EDGE_ANNOTATION_TABLE , <NUM_LIT:0> ) ; } @ Test public void computeSourceTablesFreshNode ( ) { expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesRootNode ( ) { when ( node23 . isRoot ( ) ) . thenReturn ( true ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; expectTableCount ( RANK_TABLE , <NUM_LIT:1> ) ; expectTableCount ( COMPONENT_TABLE , <NUM_LIT:1> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesRootNodeComponentAliasedToRank ( ) { when ( node23 . isRoot ( ) ) . thenReturn ( true ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , RANK_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; expectTableCount ( RANK_TABLE , <NUM_LIT:1> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesRootNodeRankAndComponentAliasedToStruct ( ) { when ( node23 . isRoot ( ) ) . thenReturn ( true ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , NODE_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesPartOfEdge ( ) { when ( node23 . isPartOfEdge ( ) ) . thenReturn ( true ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; expectTableCount ( RANK_TABLE , <NUM_LIT:1> ) ; expectTableCount ( COMPONENT_TABLE , <NUM_LIT:1> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesPartOfEdgeRankAliasedToStruct ( ) { when ( node23 . isPartOfEdge ( ) ) . thenReturn ( true ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , NODE_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesNodeAnnotations ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; expectTableCount ( NODE_ANNOTATION_TABLE , <NUM_LIT:3> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesNodeAnnotationsAliasedToStruct ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , NODE_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:3> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesEdgeAnnotations ( ) { when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; expectTableCount ( RANK_TABLE , <NUM_LIT:1> ) ; expectTableCount ( COMPONENT_TABLE , <NUM_LIT:1> ) ; expectTableCount ( EDGE_ANNOTATION_TABLE , <NUM_LIT:3> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesEdgeAnnotationsAliasedToRank ( ) { when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , RANK_TABLE ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , RANK_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:1> ) ; expectTableCount ( RANK_TABLE , <NUM_LIT:3> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesEdgeAnnotationsAliasedToStruct ( ) { when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , NODE_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:3> ) ; assertUsedTables ( ) ; } @ Test public void computeSourceTablesNodeAndEdgeAnnotationsAliasedToStruct ( ) { when ( node23 . isRoot ( ) ) . thenReturn ( true ) ; when ( node23 . isPartOfEdge ( ) ) . thenReturn ( true ) ; when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . addTableAlias ( RANK_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( COMPONENT_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , NODE_TABLE ) ; expectTableCount ( NODE_TABLE , <NUM_LIT:6> ) ; assertUsedTables ( ) ; } @ Test public void tableName ( ) { assertEquals ( "<STR_LIT:foo>" , tableAccessStrategy . tableName ( "<STR_LIT:foo>" ) ) ; } @ Test public void tableNameAliased ( ) { tableAccessStrategy . addTableAlias ( "<STR_LIT:foo>" , "<STR_LIT>" ) ; assertEquals ( "<STR_LIT>" , tableAccessStrategy . tableName ( "<STR_LIT:foo>" ) ) ; } @ Test public void columnName ( ) { assertEquals ( "<STR_LIT:bar>" , tableAccessStrategy . columnName ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) ) ; } @ Test public void columnNameAliased ( ) { tableAccessStrategy . addColumnAlias ( "<STR_LIT:foo>" , "<STR_LIT:bar>" , "<STR_LIT>" ) ; assertEquals ( "<STR_LIT>" , tableAccessStrategy . columnName ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) ) ; } @ Test public void aliasedTableStruct ( ) { assertSingleTable ( NODE_TABLE ) ; } @ Test public void aliasedTableNodeAnnotations ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; assertMultipleTables ( NODE_ANNOTATION_TABLE , <NUM_LIT:3> ) ; } @ Test public void aliasedTableEdgeAnnotations ( ) { when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; assertMultipleTables ( EDGE_ANNOTATION_TABLE , <NUM_LIT:3> ) ; } @ Test public void aliasedTableNodeAndEdgeAnnotationsDifferentTable ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; assertMultipleTables ( NODE_ANNOTATION_TABLE , <NUM_LIT:3> ) ; assertMultipleTables ( EDGE_ANNOTATION_TABLE , <NUM_LIT:3> ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) @ Test public void aliasedTableNodeAndEdgeAnnotationsSameTable ( ) { final int NODE_ANNOTATION_COUNT = <NUM_LIT:2> ; Set < QueryAnnotation > nodeAnnotations = mock ( Set . class ) ; when ( nodeAnnotations . size ( ) ) . thenReturn ( NODE_ANNOTATION_COUNT ) ; when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( nodeAnnotations ) ; final int EDGE_ANNOTATION_COUNT = <NUM_LIT:3> ; Set < QueryAnnotation > edgeAnnotations = mock ( Set . class ) ; when ( edgeAnnotations . size ( ) ) . thenReturn ( EDGE_ANNOTATION_COUNT ) ; when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( edgeAnnotations ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , NODE_TABLE ) ; tableAccessStrategy . addTableAlias ( EDGE_ANNOTATION_TABLE , NODE_TABLE ) ; assertMultipleAliasedTables ( NODE_ANNOTATION_TABLE , NODE_ANNOTATION_COUNT , NODE_TABLE , <NUM_LIT:0> ) ; assertMultipleAliasedTables ( EDGE_ANNOTATION_TABLE , EDGE_ANNOTATION_COUNT , NODE_TABLE , NODE_ANNOTATION_COUNT - <NUM_LIT:1> ) ; } @ Test ( expected = IllegalArgumentException . class ) public void onlyOneStructTable ( ) { tableAccessStrategy . aliasedTable ( NODE_TABLE , <NUM_LIT:2> ) ; } @ Test ( expected = IllegalArgumentException . class ) public void onlyOneRankTable ( ) { tableAccessStrategy . aliasedTable ( RANK_TABLE , <NUM_LIT:2> ) ; } @ Test ( expected = IllegalArgumentException . class ) public void nodeAnnotationsUnknownAnnotation ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . aliasedTable ( NODE_ANNOTATION_TABLE , <NUM_LIT:4> ) ; } @ Test ( expected = IllegalArgumentException . class ) public void edgeAnnotationsUnknownAnnotation ( ) { when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . aliasedTable ( EDGE_ANNOTATION_TABLE , <NUM_LIT:4> ) ; } @ Test public void aliasedColumn ( ) { tableAccessStrategy . addColumnAlias ( NODE_TABLE , "<STR_LIT:bar>" , "<STR_LIT>" ) ; assertEquals ( NODE_TABLE + "<STR_LIT>" , tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT:bar>" ) ) ; } @ Test public void aliasedColumnManyTables ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; tableAccessStrategy . addTableAlias ( NODE_ANNOTATION_TABLE , NODE_TABLE ) ; tableAccessStrategy . addColumnAlias ( NODE_TABLE , "<STR_LIT:foo>" , "<STR_LIT>" ) ; tableAccessStrategy . addColumnAlias ( NODE_ANNOTATION_TABLE , "<STR_LIT:bar>" , "<STR_LIT>" ) ; assertEquals ( NODE_TABLE + "<STR_LIT>" , tableAccessStrategy . aliasedColumn ( NODE_TABLE , "<STR_LIT:foo>" ) ) ; assertEquals ( NODE_TABLE + "<STR_LIT>" , tableAccessStrategy . aliasedColumn ( NODE_ANNOTATION_TABLE , "<STR_LIT:bar>" , <NUM_LIT:1> ) ) ; assertEquals ( NODE_TABLE + "<STR_LIT>" , tableAccessStrategy . aliasedColumn ( NODE_ANNOTATION_TABLE , "<STR_LIT:bar>" , <NUM_LIT:2> ) ) ; assertEquals ( NODE_TABLE + "<STR_LIT>" , tableAccessStrategy . aliasedColumn ( NODE_ANNOTATION_TABLE , "<STR_LIT:bar>" , <NUM_LIT:3> ) ) ; } @ Test public void usedTablesFreshNode ( ) { assertThat ( tableAccessStrategy . usesEdgeAnnotationTable ( ) , is ( false ) ) ; assertThat ( tableAccessStrategy . usesNodeAnnotationTable ( ) , is ( false ) ) ; } @ Test public void usesRankTableEdge ( ) { when ( node23 . isPartOfEdge ( ) ) . thenReturn ( true ) ; assertThat ( tableAccessStrategy . usesRankTable ( ) , is ( true ) ) ; } @ Test public void usesRankTableRoot ( ) { when ( node23 . isRoot ( ) ) . thenReturn ( true ) ; assertThat ( tableAccessStrategy . usesRankTable ( ) , is ( true ) ) ; } @ Test public void usedTableEdgeAnnotation ( ) { when ( node23 . getEdgeAnnotations ( ) ) . thenReturn ( annotations ) ; assertThat ( tableAccessStrategy . usesRankTable ( ) , is ( true ) ) ; assertThat ( tableAccessStrategy . usesEdgeAnnotationTable ( ) , is ( true ) ) ; } @ Test public void usedTableNodeAnnotation ( ) { when ( node23 . getNodeAnnotations ( ) ) . thenReturn ( annotations ) ; assertThat ( tableAccessStrategy . usesNodeAnnotationTable ( ) , is ( true ) ) ; } @ Test public void isMaterializedTrue ( ) { tableAccessStrategy . addTableAlias ( RANK_TABLE , NODE_TABLE ) ; assertThat ( tableAccessStrategy . isMaterialized ( RANK_TABLE , NODE_TABLE ) , is ( true ) ) ; } @ Test public void isMaterializedFalse ( ) { assertThat ( tableAccessStrategy . isMaterialized ( RANK_TABLE , NODE_TABLE ) , is ( false ) ) ; } private void expectTableCount ( String table , int count ) { expected . put ( table , count ) ; } private void assertUsedTables ( ) { assertThat ( tableAccessStrategy . computeSourceTables ( ) , hasTables ( expected ) ) ; } private void assertSingleTable ( String table ) { assertThat ( tableAccessStrategy . aliasedTable ( table , <NUM_LIT:1> ) , is ( table + node23 . getId ( ) ) ) ; } private void assertMultipleTables ( String table , int count ) { for ( int i = <NUM_LIT:1> ; i <= count ; ++ i ) assertThat ( tableAccessStrategy . aliasedTable ( table , i ) , is ( table + node23 . getId ( ) + "<STR_LIT:_>" + i ) ) ; } private void assertMultipleAliasedTables ( String table , int count , String alias , int offset ) { for ( int i = <NUM_LIT:2> ; i <= count ; ++ i ) assertThat ( tableAccessStrategy . aliasedTable ( table , i ) , is ( alias + node23 . getId ( ) + "<STR_LIT:_>" + ( i + offset ) ) ) ; } private Matcher < Bag > hasTables ( final Map < String , Integer > expectedTables ) { return new TypeSafeMatcher < Bag > ( ) { @ Override public boolean matchesSafely ( Bag item ) { for ( String table : expectedTables . keySet ( ) ) { if ( item . getCount ( table ) != expectedTables . get ( table ) ) return false ; } return true ; } public void describeTo ( Description description ) { description . appendValue ( expectedTables ) ; } } ; } } </s>
<s> package annis . sqlgen ; import static org . hamcrest . CoreMatchers . not ; import static org . hamcrest . text . StringStartsWith . startsWith ; import static org . junit . Assert . assertThat ; import static org . mockito . BDDMockito . given ; import static org . mockito . MockitoAnnotations . initMocks ; import java . util . ArrayList ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mock ; import annis . model . QueryNode ; import annis . ql . parser . QueryData ; public class TestFindSqlGenerator { private FindSqlGenerator generator ; @ Mock private TableAccessStrategy tableAccessStrategy ; @ Mock private QueryData queryData ; @ Mock private QueryNode queryNode ; private ArrayList < QueryNode > alternative = new ArrayList < QueryNode > ( ) ; @ Before public void setup ( ) { initMocks ( this ) ; generator = new FindSqlGenerator ( ) { protected TableAccessStrategy createTableAccessStrategy ( ) { return tableAccessStrategy ; } } ; } private void setupQueryData ( ) { alternative . add ( queryNode ) ; given ( queryData . getMaxWidth ( ) ) . willReturn ( <NUM_LIT:1> ) ; } @ Test public void shouldNotOptimizeDistinct ( ) { generator . setOptimizeDistinct ( false ) ; setupQueryData ( ) ; given ( tableAccessStrategy . usesRankTable ( ) ) . willReturn ( false ) ; String actual = generator . selectClause ( queryData , alternative , "<STR_LIT>" ) ; assertThat ( actual , startsWith ( "<STR_LIT>" ) ) ; } @ Test public void shouldSkipDistinctIfOnlyNodeTablesAreUsed ( ) { generator . setOptimizeDistinct ( true ) ; setupQueryData ( ) ; given ( tableAccessStrategy . usesRankTable ( ) ) . willReturn ( false ) ; String actual = generator . selectClause ( queryData , alternative , "<STR_LIT>" ) ; assertThat ( actual , not ( startsWith ( "<STR_LIT>" ) ) ) ; } @ Test public void shouldUseDistinctIfEdgeTablesAreUsed ( ) { generator . setOptimizeDistinct ( true ) ; setupQueryData ( ) ; given ( tableAccessStrategy . usesRankTable ( ) ) . willReturn ( true ) ; String actual = generator . selectClause ( queryData , alternative , "<STR_LIT>" ) ; assertThat ( actual , startsWith ( "<STR_LIT>" ) ) ; } } </s>
<s> package annis ; import static org . hamcrest . Matchers . is ; import static org . hamcrest . Matchers . not ; import static org . hamcrest . Matchers . nullValue ; import static org . hamcrest . Matchers . sameInstance ; import static org . junit . Assert . assertThat ; import java . io . PrintStream ; import org . junit . Before ; import org . junit . BeforeClass ; import org . junit . Test ; public class TestAnnisBaseRunner { public static class MockAnnisRunner extends AnnisBaseRunner { boolean interactive = false ; String args ; @ Override protected void runInteractive ( ) { interactive = true ; } public void doKnownCommand ( String args ) { this . args = args ; } } ; private MockAnnisRunner instance ; @ Before public void setupRunnerInstance ( ) { instance = ( MockAnnisRunner ) MockAnnisRunner . getInstance ( "<STR_LIT>" , false , "<STR_LIT>" ) ; } @ Test public void freshInstanceOutIsSystemOut ( ) { PrintStream out = instance . getOut ( ) ; assertThat ( out , is ( not ( nullValue ( ) ) ) ) ; assertThat ( out , is ( sameInstance ( System . out ) ) ) ; } @ Test public void runInteractive ( ) { assertThat ( instance . interactive , is ( false ) ) ; String [ ] args = { } ; instance . run ( args ) ; assertThat ( instance . interactive , is ( true ) ) ; } @ Test public void runKnownCommand ( ) { assertThat ( instance . args , is ( nullValue ( ) ) ) ; String [ ] args = { "<STR_LIT>" } ; instance . run ( args ) ; assertThat ( instance . args , is ( "<STR_LIT>" ) ) ; } @ Test ( expected = UsageException . class ) public void runCommandUnknownCommand ( ) { instance . runCommand ( "<STR_LIT>" , "<STR_LIT>" ) ; } } </s>
<s> package annis . utils ; import static org . hamcrest . Matchers . is ; import static org . junit . Assert . assertThat ; import java . util . Arrays ; import java . util . List ; import org . junit . Test ; public class TestUtils { @ Test public void min ( ) { List < Long > values = Arrays . asList ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; assertThat ( Utils . min ( values ) , is ( "<STR_LIT>" ) ) ; } @ Test public void max ( ) { List < Long > values = Arrays . asList ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; assertThat ( Utils . max ( values ) , is ( "<STR_LIT>" ) ) ; } @ Test public void avg ( ) { List < Long > values = Arrays . asList ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; assertThat ( Utils . avg ( values ) , is ( "<STR_LIT>" ) ) ; } } </s>
<s> package annis . utils ; import annis . AnnisXmlContextLoader ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertTrue ; import java . sql . SQLException ; import java . util . Collections ; import java . util . Comparator ; import java . util . Iterator ; import java . util . List ; import java . util . Set ; import org . junit . After ; import org . junit . AfterClass ; import org . junit . Before ; import org . junit . BeforeClass ; import org . junit . Test ; import org . junit . runner . RunWith ; import org . springframework . beans . factory . annotation . Autowired ; import org . springframework . test . context . ContextConfiguration ; import org . springframework . test . context . junit4 . SpringJUnit4ClassRunner ; import annis . model . AnnisNode ; import annis . model . Annotation ; import annis . model . AnnotationGraph ; import annis . model . Edge ; import annis . sqlgen . * ; import annis . test . CsvResultSetProvider ; import de . hu_berlin . german . korpling . saltnpepper . salt . saltCommon . SaltProject ; import org . springframework . context . annotation . PropertySource ; @ RunWith ( SpringJUnit4ClassRunner . class ) @ ContextConfiguration ( locations = { "<STR_LIT>" } , loader = AnnisXmlContextLoader . class ) public class LegacyGraphConverterTest { @ Autowired AomAnnotateExtractor aomSqlGen ; public LegacyGraphConverterTest ( ) { } @ BeforeClass public static void setUpClass ( ) throws Exception { } @ AfterClass public static void tearDownClass ( ) throws Exception { } @ Before public void setUp ( ) { } @ After public void tearDown ( ) { } @ Test public void testConvertToAOM ( ) throws SQLException { SaltAnnotateExtractor saltExtractor = new SaltAnnotateExtractor ( ) { @ Override protected SolutionKey < ? > createSolutionKey ( ) { PostgreSqlArraySolutionKey < Long > key = new PostgreSqlArraySolutionKey < Long > ( ) ; key . setKeyColumnName ( "<STR_LIT:key>" ) ; key . setIdColumnName ( "<STR_LIT:id>" ) ; return key ; } } ; CorpusPathExtractor corpusPathExtractor = new ArrayCorpusPathExtractor ( ) ; saltExtractor . setCorpusPathExtractor ( corpusPathExtractor ) ; TestAnnotateSqlGenerator . setupOuterQueryFactsTableColumnAliases ( saltExtractor ) ; SaltProject p = saltExtractor . extractData ( new CsvResultSetProvider ( annis . sqlgen . SaltAnnotateExtractorTest . class . getResourceAsStream ( "<STR_LIT>" ) ) . getResultSet ( ) ) ; List < AnnotationGraph > expected = aomSqlGen . extractData ( new CsvResultSetProvider ( annis . sqlgen . SaltAnnotateExtractorTest . class . getResourceAsStream ( "<STR_LIT>" ) ) . getResultSet ( ) ) ; List < AnnotationGraph > result = LegacyGraphConverter . convertToAOM ( p ) ; assertEquals ( expected . size ( ) , result . size ( ) ) ; Iterator < AnnotationGraph > itGraphExpected = expected . iterator ( ) ; Iterator < AnnotationGraph > itGraphResult = result . iterator ( ) ; while ( itGraphExpected . hasNext ( ) && itGraphResult . hasNext ( ) ) { AnnotationGraph graphExpected = itGraphExpected . next ( ) ; AnnotationGraph graphResult = itGraphResult . next ( ) ; List < AnnisNode > nodeListExpected = graphExpected . getNodes ( ) ; List < AnnisNode > nodeListResult = graphResult . getNodes ( ) ; assertEquals ( nodeListExpected . size ( ) , nodeListResult . size ( ) ) ; Collections . sort ( nodeListExpected , new Comparator < AnnisNode > ( ) { @ Override public int compare ( AnnisNode arg0 , AnnisNode arg1 ) { return Long . valueOf ( arg0 . getId ( ) ) . compareTo ( Long . valueOf ( arg1 . getId ( ) ) ) ; } } ) ; Collections . sort ( nodeListResult , new Comparator < AnnisNode > ( ) { @ Override public int compare ( AnnisNode arg0 , AnnisNode arg1 ) { return Long . valueOf ( arg0 . getId ( ) ) . compareTo ( Long . valueOf ( arg1 . getId ( ) ) ) ; } } ) ; Iterator < AnnisNode > itNodeExpected = nodeListExpected . iterator ( ) ; Iterator < AnnisNode > itNodeResult = nodeListResult . iterator ( ) ; while ( itNodeExpected . hasNext ( ) && itNodeResult . hasNext ( ) ) { checkAnnisNodeEqual ( itNodeExpected . next ( ) , itNodeResult . next ( ) ) ; } } } private void checkAnnisNodeEqual ( AnnisNode n1 , AnnisNode n2 ) { checkAnnotationSetEqual ( n1 . getNodeAnnotations ( ) , n2 . getNodeAnnotations ( ) ) ; checkAnnotationSetEqual ( n1 . getEdgeAnnotations ( ) , n2 . getEdgeAnnotations ( ) ) ; assertEquals ( n1 . getCorpus ( ) , n2 . getCorpus ( ) ) ; assertEquals ( n1 . getId ( ) , n2 . getId ( ) ) ; assertEquals ( n1 . getLeft ( ) , n2 . getLeft ( ) ) ; assertEquals ( n1 . getLeftToken ( ) , n2 . getLeftToken ( ) ) ; assertEquals ( n1 . getMatchedNodeInQuery ( ) , n2 . getMatchedNodeInQuery ( ) ) ; assertEquals ( n1 . getName ( ) , n2 . getName ( ) ) ; assertEquals ( n1 . getNamespace ( ) , n2 . getNamespace ( ) ) ; assertEquals ( n1 . getRight ( ) , n2 . getRight ( ) ) ; assertEquals ( n1 . getRightToken ( ) , n2 . getRightToken ( ) ) ; assertEquals ( n1 . getSpannedText ( ) , n2 . getSpannedText ( ) ) ; assertEquals ( n1 . getTextId ( ) , n2 . getTextId ( ) ) ; assertEquals ( n1 . getTokenIndex ( ) , n2 . getTokenIndex ( ) ) ; Set < Edge > out1 = n1 . getOutgoingEdges ( ) ; Set < Edge > out2 = n2 . getOutgoingEdges ( ) ; assertEquals ( out1 . size ( ) , out2 . size ( ) ) ; for ( Edge e1 : out1 ) { assertTrue ( out2 . contains ( e1 ) ) ; for ( Edge e2 : out2 ) { if ( e1 . getPre ( ) == e2 . getPre ( ) ) { checkAnnisEdgeEqual ( e1 , e2 ) ; break ; } } } Set < Edge > in1 = n1 . getIncomingEdges ( ) ; Set < Edge > in2 = n2 . getIncomingEdges ( ) ; assertEquals ( in1 . size ( ) , in2 . size ( ) ) ; for ( Edge e1 : in1 ) { assertTrue ( in2 . contains ( e1 ) ) ; for ( Edge e2 : in2 ) { if ( e1 . getPre ( ) == e2 . getPre ( ) && e1 . getComponentID ( ) == e2 . getComponentID ( ) ) { checkAnnisEdgeEqual ( e1 , e2 ) ; break ; } } } } private void checkAnnisEdgeEqual ( Edge e1 , Edge e2 ) { checkAnnotationSetEqual ( e1 . getAnnotations ( ) , e1 . getAnnotations ( ) ) ; assertEquals ( e1 . getSource ( ) . getId ( ) , e2 . getSource ( ) . getId ( ) ) ; assertEquals ( e1 . getDestination ( ) . getId ( ) , e2 . getDestination ( ) . getId ( ) ) ; } private void checkAnnotationSetEqual ( Set < Annotation > annos1 , Set < Annotation > annos2 ) { for ( Annotation a : annos1 ) { assertTrue ( "<STR_LIT>" + a . getQualifiedName ( ) + "<STR_LIT>" + a . getValue ( ) + "<STR_LIT>" , annos2 . contains ( a ) ) ; } for ( Annotation a : annos2 ) { assertTrue ( "<STR_LIT>" + a . getQualifiedName ( ) + "<STR_LIT>" + a . getValue ( ) + "<STR_LIT>" , annos2 . contains ( a ) ) ; } } } </s>
<s> package annis ; import static org . hamcrest . Matchers . is ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertThat ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collection ; import org . junit . Before ; import org . junit . Test ; public class TestTableFormatter { private static final String PRINTME1 = "<STR_LIT>" ; private static final String DONTPRINTME1 = "<STR_LIT>" ; private static final String PRINTME2 = "<STR_LIT>" ; private static final String METO2 = "<STR_LIT>" ; private static final String DONTPRINTME2 = "<STR_LIT>" ; private TableFormatter tableFormatter ; @ SuppressWarnings ( "<STR_LIT:unused>" ) private class ObjectWithTableColumns { private String printMe ; private String meTo ; private String dontPrintMe ; public ObjectWithTableColumns ( String printMe , String meTo , String dontPrintMe ) { this . printMe = printMe ; this . meTo = meTo ; this . dontPrintMe = dontPrintMe ; } } @ Before public void setup ( ) { tableFormatter = new TableFormatter ( ) ; } @ Test public void formatAsTable ( ) { ObjectWithTableColumns o1 = new ObjectWithTableColumns ( PRINTME1 , null , DONTPRINTME1 ) ; ObjectWithTableColumns o2 = new ObjectWithTableColumns ( PRINTME2 , METO2 , DONTPRINTME2 ) ; String [ ] fields = { "<STR_LIT>" , "<STR_LIT>" } ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; System . out . println ( tableFormatter . formatAsTable ( Arrays . asList ( o1 , o2 ) , fields ) ) ; assertEquals ( expected , tableFormatter . formatAsTable ( Arrays . asList ( o1 , o2 ) , fields ) ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) @ Test public void collection ( ) { Collection < String > c1 = Arrays . asList ( "<STR_LIT:1>" ) ; Collection < String > c2 = Arrays . asList ( "<STR_LIT:2>" , "<STR_LIT:3>" ) ; String expected = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; System . out . println ( tableFormatter . formatAsTable ( Arrays . asList ( c1 , c2 ) ) ) ; assertEquals ( expected , tableFormatter . formatAsTable ( Arrays . asList ( c1 , c2 ) ) ) ; } @ Test public void empty ( ) { assertThat ( tableFormatter . formatAsTable ( new ArrayList < Object > ( ) ) , is ( "<STR_LIT>" ) ) ; } @ Test public void noFields ( ) { assertThat ( tableFormatter . formatAsTable ( Arrays . asList ( new Object ( ) ) ) , is ( "<STR_LIT>" ) ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) @ Test public void emptyCollection ( ) { assertThat ( tableFormatter . formatAsTable ( Arrays . asList ( new ArrayList < Object > ( ) ) ) , is ( "<STR_LIT>" ) ) ; } @ Test public void unknownField ( ) { assertThat ( tableFormatter . formatAsTable ( Arrays . asList ( new Object ( ) ) , "<STR_LIT>" ) , is ( "<STR_LIT>" ) ) ; } } </s>
<s> package annis . gui . widgets ; import annis . gui . widgets . gwt . client . VAutoHeightIFrame ; import com . vaadin . terminal . PaintException ; import com . vaadin . terminal . PaintTarget ; import com . vaadin . terminal . Sizeable ; import com . vaadin . ui . AbstractComponent ; import com . vaadin . ui . ClientWidget ; import java . util . Map ; @ ClientWidget ( VAutoHeightIFrame . class ) public class AutoHeightIFrame extends AbstractComponent { private String url ; private boolean urlUpdated = false ; public static final int ADDITIONAL_HEIGHT = <NUM_LIT> ; public AutoHeightIFrame ( String url ) { this . url = url ; urlUpdated = false ; setWidth ( "<STR_LIT>" ) ; } @ Override public void paintContent ( PaintTarget target ) throws PaintException { super . paintContent ( target ) ; if ( ! urlUpdated ) { target . addAttribute ( "<STR_LIT:url>" , url ) ; target . addAttribute ( "<STR_LIT>" , ADDITIONAL_HEIGHT ) ; urlUpdated = true ; } } @ Override public void changeVariables ( Object source , Map < String , Object > variables ) { if ( variables . containsKey ( "<STR_LIT>" ) ) { int height = ( Integer ) variables . get ( "<STR_LIT>" ) ; this . setHeight ( ( float ) height , Sizeable . UNITS_PIXELS ) ; } } } </s>
<s> package annis . gui . widgets ; import annis . gui . widgets . gwt . client . VAudioPlayer ; import com . vaadin . ui . ClientWidget ; @ ClientWidget ( VAudioPlayer . class ) public class AudioPlayer extends MediaPlayerBase { public AudioPlayer ( String resourceURL , String mimeType ) { super ( resourceURL , mimeType ) ; } } </s>
<s> package annis . gui . widgets ; import annis . gui . widgets . gwt . client . VSimpleCanvas ; import com . vaadin . terminal . PaintException ; import com . vaadin . terminal . PaintTarget ; import com . vaadin . ui . AbstractComponent ; import com . vaadin . ui . ClientWidget ; import java . awt . geom . Line2D ; import java . util . LinkedList ; import java . util . List ; @ ClientWidget ( VSimpleCanvas . class ) public class SimpleCanvas extends AbstractComponent { private List < Line2D > lines ; public SimpleCanvas ( ) { lines = new LinkedList < Line2D > ( ) ; } @ Override public void paintContent ( PaintTarget target ) throws PaintException { super . paintContent ( target ) ; target . startTag ( "<STR_LIT>" ) ; target . endTag ( "<STR_LIT>" ) ; for ( Line2D l : lines ) { target . startTag ( "<STR_LIT>" ) ; target . addAttribute ( "<STR_LIT>" , l . getX1 ( ) ) ; target . addAttribute ( "<STR_LIT>" , l . getY1 ( ) ) ; target . addAttribute ( "<STR_LIT>" , l . getX2 ( ) ) ; target . addAttribute ( "<STR_LIT>" , l . getY2 ( ) ) ; target . endTag ( "<STR_LIT>" ) ; } } public List < Line2D > getLines ( ) { return lines ; } public void setLines ( List < Line2D > lines ) { this . lines = lines ; } } </s>
<s> package annis . gui . widgets . gwt . client ; import com . google . gwt . canvas . client . Canvas ; import com . google . gwt . canvas . dom . client . Context2d ; import com . google . gwt . user . client . ui . Composite ; import com . google . gwt . user . client . ui . Label ; import com . vaadin . terminal . gwt . client . ApplicationConnection ; import com . vaadin . terminal . gwt . client . Paintable ; import com . vaadin . terminal . gwt . client . UIDL ; import java . util . Iterator ; public class VSimpleCanvas extends Composite implements Paintable { public static final String CLASSNAME = "<STR_LIT>" ; protected String paintableId ; ApplicationConnection gClient ; static final int height = <NUM_LIT> ; static final int width = <NUM_LIT> ; Canvas canvas ; Context2d context ; public VSimpleCanvas ( ) { super ( ) ; canvas = Canvas . createIfSupported ( ) ; if ( canvas == null ) { Label lblErrorMessage = new Label ( "<STR_LIT>" ) ; initWidget ( lblErrorMessage ) ; } else { initWidget ( canvas ) ; canvas . setHeight ( "<STR_LIT>" + height + "<STR_LIT>" ) ; canvas . setWidth ( "<STR_LIT>" + width + "<STR_LIT>" ) ; canvas . setCoordinateSpaceHeight ( height ) ; canvas . setCoordinateSpaceWidth ( width ) ; context = canvas . getContext2d ( ) ; } setStyleName ( CLASSNAME ) ; } @ Override public void updateFromUIDL ( UIDL uidl , ApplicationConnection client ) { if ( client . updateComponent ( this , uidl , true ) ) { return ; } this . gClient = client ; paintableId = uidl . getId ( ) ; if ( context != null ) { Iterator < Object > it = uidl . getChildIterator ( ) ; while ( it . hasNext ( ) ) { UIDL child = ( UIDL ) it . next ( ) ; if ( "<STR_LIT>" . equals ( child . getTag ( ) ) ) { context . clearRect ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ) ; } else if ( "<STR_LIT>" . equals ( child . getTag ( ) ) ) { context . beginPath ( ) ; context . moveTo ( child . getIntAttribute ( "<STR_LIT>" ) , child . getIntAttribute ( "<STR_LIT>" ) ) ; context . lineTo ( child . getIntAttribute ( "<STR_LIT>" ) , child . getIntAttribute ( "<STR_LIT>" ) ) ; context . stroke ( ) ; context . closePath ( ) ; } } } } } </s>
<s> package annis . gui . widgets . gwt . client ; import com . google . gwt . core . client . JavaScriptException ; import com . google . gwt . dom . client . * ; import com . google . gwt . event . dom . client . LoadEvent ; import com . google . gwt . event . dom . client . LoadHandler ; import com . google . gwt . user . client . Timer ; import com . google . gwt . user . client . ui . Widget ; import com . vaadin . terminal . gwt . client . ApplicationConnection ; import com . vaadin . terminal . gwt . client . Paintable ; import com . vaadin . terminal . gwt . client . UIDL ; import com . vaadin . terminal . gwt . client . VConsole ; public class VAutoHeightIFrame extends Widget implements Paintable { public static final String CLASSNAME = "<STR_LIT>" ; protected String paintableId ; ApplicationConnection gClient ; private IFrameElement iframe ; private int additionalHeight ; public VAutoHeightIFrame ( ) { super ( ) ; iframe = Document . get ( ) . createIFrameElement ( ) ; setElement ( iframe ) ; setStyleName ( CLASSNAME ) ; addDomHandler ( new LoadHandler ( ) { @ Override public void onLoad ( LoadEvent event ) { if ( ! iframe . getSrc ( ) . endsWith ( "<STR_LIT>" ) ) { try { final Document doc = iframe . getContentDocument ( ) ; if ( doc != null ) { Timer t = new Timer ( ) { @ Override public void run ( ) { checkIFrameLoaded ( doc ) ; } } ; t . schedule ( <NUM_LIT:100> ) ; } } catch ( JavaScriptException ex ) { VConsole . log ( "<STR_LIT>" ) ; } } } } , LoadEvent . getType ( ) ) ; iframe . setFrameBorder ( <NUM_LIT:0> ) ; } private void checkIFrameLoaded ( Document doc ) { int newHeight = - <NUM_LIT:1> ; doc . getScrollLeft ( ) ; String contentType = getContentType ( doc ) ; if ( contentType != null && contentType . startsWith ( "<STR_LIT>" ) ) { NodeList < Element > imgList = doc . getElementsByTagName ( "<STR_LIT>" ) ; if ( imgList . getLength ( ) > <NUM_LIT:0> ) { ImageElement img = ( ImageElement ) imgList . getItem ( <NUM_LIT:0> ) ; newHeight = img . getPropertyInt ( "<STR_LIT>" ) ; } } else { VConsole . log ( "<STR_LIT>" + doc . getBody ( ) . hasAttribute ( "<STR_LIT>" ) ) ; VConsole . log ( "<STR_LIT>" + doc . getDocumentElement ( ) . hasAttribute ( "<STR_LIT>" ) ) ; int bodyHeight = doc . getBody ( ) . getScrollHeight ( ) ; int documentHeight = doc . getDocumentElement ( ) . getScrollHeight ( ) ; int maxHeight = Math . max ( bodyHeight , documentHeight ) ; VConsole . log ( "<STR_LIT>" + bodyHeight + "<STR_LIT>" + documentHeight ) ; if ( maxHeight > <NUM_LIT:20> ) { newHeight = maxHeight + additionalHeight ; } } VConsole . log ( "<STR_LIT>" + newHeight ) ; if ( newHeight > - <NUM_LIT:1> ) { gClient . updateVariable ( paintableId , "<STR_LIT>" , newHeight , true ) ; } } @ Override public void updateFromUIDL ( UIDL uidl , ApplicationConnection client ) { if ( client . updateComponent ( this , uidl , true ) ) { return ; } String url = uidl . getStringAttribute ( "<STR_LIT:url>" ) ; if ( iframe . getSrc ( ) != null && url != null && iframe . getSrc ( ) . equals ( url ) ) { return ; } this . gClient = client ; paintableId = uidl . getId ( ) ; if ( uidl . hasAttribute ( "<STR_LIT>" ) ) { additionalHeight = uidl . getIntAttribute ( "<STR_LIT>" ) ; } final Style style = iframe . getStyle ( ) ; style . setWidth ( <NUM_LIT:100> , Style . Unit . PCT ) ; if ( url != null ) { url = client . translateVaadinUri ( url ) ; iframe . setSrc ( url ) ; } } public final native String getContentType ( Document doc ) ; } </s>
<s> package annis . gui . widgets . gwt . client ; import com . google . common . collect . BiMap ; import com . google . common . collect . HashBiMap ; import com . google . gwt . dom . client . Element ; import com . google . gwt . dom . client . TableCellElement ; import com . google . gwt . dom . client . TableRowElement ; import com . google . gwt . user . client . Event ; import com . google . gwt . user . client . ui . Composite ; import com . google . gwt . user . client . ui . FlexTable ; import com . google . gwt . user . client . ui . HTMLTable . Cell ; import com . vaadin . terminal . gwt . client . ApplicationConnection ; import com . vaadin . terminal . gwt . client . Paintable ; import com . vaadin . terminal . gwt . client . UIDL ; import com . vaadin . terminal . gwt . client . VConsole ; import com . vaadin . terminal . gwt . client . ui . VLabel ; import java . util . HashMap ; import java . util . Map ; public class VAnnotationGrid extends Composite implements Paintable { public static final String CLASSNAME = "<STR_LIT>" ; protected String paintableId ; ApplicationConnection gClient ; private AnnotationGridTable table ; private FlexTable . FlexCellFormatter formatter ; private BiMap < Position , String > position2id ; private Map < String , String [ ] > highlighted ; private Map < Position , Double > startTimes ; private Map < Position , Double > endTimes ; public VAnnotationGrid ( ) { super ( ) ; table = new AnnotationGridTable ( ) ; formatter = table . getFlexCellFormatter ( ) ; initWidget ( table ) ; setStyleName ( CLASSNAME ) ; highlighted = new HashMap < String , String [ ] > ( ) ; position2id = HashBiMap . create ( ) ; startTimes = new HashMap < Position , Double > ( ) ; endTimes = new HashMap < Position , Double > ( ) ; } @ Override public void updateFromUIDL ( UIDL uidl , ApplicationConnection client ) { if ( client . updateComponent ( this , uidl , true ) ) { return ; } this . gClient = client ; paintableId = uidl . getId ( ) ; try { UIDL rows = uidl . getChildByTagName ( "<STR_LIT>" ) ; if ( rows != null ) { table . removeAllRows ( ) ; highlighted . clear ( ) ; position2id . clear ( ) ; for ( int i = <NUM_LIT:0> ; i < rows . getChildCount ( ) ; i ++ ) { UIDL row = rows . getChildUIDL ( i ) ; if ( "<STR_LIT>" . equals ( row . getTag ( ) ) ) { addRow ( row , i ) ; } } } int maxCellCount = <NUM_LIT:0> ; for ( int row = <NUM_LIT:0> ; row < table . getRowCount ( ) ; row ++ ) { maxCellCount = Math . max ( maxCellCount , getRealColumnCount ( row ) ) ; } for ( int row = <NUM_LIT:0> ; row < table . getRowCount ( ) ; row ++ ) { int isValue = getRealColumnCount ( row ) ; if ( isValue < maxCellCount ) { int diff = maxCellCount - isValue ; table . setHTML ( row , table . getCellCount ( row ) + diff - <NUM_LIT:1> , "<STR_LIT>" ) ; } } } catch ( Exception ex ) { VConsole . log ( ex ) ; } } private int getRealColumnCount ( int row ) { int result = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < table . getCellCount ( row ) ; i ++ ) { result += formatter . getColSpan ( row , i ) ; } return result ; } private void addRow ( UIDL row , int rowNumber ) { String caption = row . getStringAttribute ( "<STR_LIT>" ) ; String [ ] captionSplit = caption . split ( "<STR_LIT>" ) ; String name = captionSplit [ captionSplit . length - <NUM_LIT:1> ] ; VLabel lblCaption = new VLabel ( name ) ; table . setWidget ( rowNumber , <NUM_LIT:0> , lblCaption ) ; formatter . addStyleName ( rowNumber , <NUM_LIT:0> , "<STR_LIT>" ) ; int colspanOffset = <NUM_LIT:0> ; UIDL events = row . getChildByTagName ( "<STR_LIT>" ) ; for ( int j = <NUM_LIT:0> ; j < events . getChildCount ( ) ; j ++ ) { UIDL event = events . getChildUIDL ( j ) ; String id = event . getStringAttribute ( "<STR_LIT:id>" ) ; int left = event . getIntAttribute ( "<STR_LIT>" ) ; int right = event . getIntAttribute ( "<STR_LIT>" ) ; String value = event . getStringAttribute ( "<STR_LIT:value>" ) ; VLabel label = new VLabel ( value ) ; label . setTitle ( caption ) ; int col = left + <NUM_LIT:1> - colspanOffset ; table . setWidget ( rowNumber , col , label ) ; position2id . put ( new Position ( rowNumber , col ) , id ) ; int colspan = right - left + <NUM_LIT:1> ; formatter . setColSpan ( rowNumber , col , colspan ) ; if ( colspan > <NUM_LIT:1> ) { colspanOffset += ( colspan - <NUM_LIT:1> ) ; } addStyleForEvent ( event , rowNumber , col ) ; } } private void addStyleForEvent ( UIDL event , int rowNumber , int col ) { String id = event . getStringAttribute ( "<STR_LIT:id>" ) ; if ( event . hasAttribute ( "<STR_LIT>" ) ) { String [ ] styles = event . getStringArrayAttribute ( "<STR_LIT>" ) ; for ( String s : styles ) { formatter . addStyleName ( rowNumber , col , s ) ; } } else { formatter . addStyleName ( rowNumber , col , "<STR_LIT>" ) ; } if ( event . hasAttribute ( "<STR_LIT>" ) ) { highlighted . put ( id , event . getStringArrayAttribute ( "<STR_LIT>" ) ) ; } if ( event . hasAttribute ( "<STR_LIT>" ) ) { formatter . addStyleName ( rowNumber , col , "<STR_LIT>" ) ; startTimes . put ( new Position ( rowNumber , col ) , event . getDoubleAttribute ( "<STR_LIT>" ) ) ; if ( event . hasAttribute ( "<STR_LIT>" ) ) { endTimes . put ( new Position ( rowNumber , col ) , event . getDoubleAttribute ( "<STR_LIT>" ) ) ; } } } public void onClick ( int row , int col ) { Position pos = new Position ( row , col ) ; if ( startTimes . containsKey ( pos ) ) { if ( endTimes . containsKey ( pos ) ) { gClient . updateVariable ( paintableId , "<STR_LIT>" , "<STR_LIT>" + startTimes . get ( pos ) + "<STR_LIT:->" + endTimes . get ( pos ) , true ) ; } else { gClient . updateVariable ( paintableId , "<STR_LIT>" , "<STR_LIT>" + startTimes . get ( pos ) , true ) ; } } } public static class Position { private int column , row ; public Position ( Cell cell ) { this . column = cell . getCellIndex ( ) ; this . row = cell . getRowIndex ( ) ; } public Position ( int row , int column ) { this . column = column ; this . row = row ; } public int getColumn ( ) { return column ; } public void setColumn ( int column ) { this . column = column ; } public int getRow ( ) { return row ; } public void setRow ( int row ) { this . row = row ; } @ Override public int hashCode ( ) { int hash = <NUM_LIT:7> ; hash = <NUM_LIT> * hash + this . column ; hash = <NUM_LIT> * hash + this . row ; return hash ; } @ Override public boolean equals ( Object obj ) { if ( obj == null ) { return false ; } if ( getClass ( ) != obj . getClass ( ) ) { return false ; } final Position other = ( Position ) obj ; if ( this . column != other . column ) { return false ; } if ( this . row != other . row ) { return false ; } return true ; } } public class AnnotationGridTable extends FlexTable { public AnnotationGridTable ( ) { sinkEvents ( Event . ONMOUSEOVER | Event . ONMOUSEOUT | Event . ONCLICK ) ; } @ Override public void onBrowserEvent ( Event event ) { Element td = getEventTargetCell ( event ) ; if ( td == null ) { return ; } int row = TableRowElement . as ( td . getParentElement ( ) ) . getSectionRowIndex ( ) ; int column = TableCellElement . as ( td ) . getCellIndex ( ) ; String id = position2id . get ( new Position ( row , column ) ) ; String [ ] targetIDs = highlighted . get ( id ) ; if ( targetIDs != null && targetIDs . length > <NUM_LIT:0> ) { switch ( event . getTypeInt ( ) ) { case Event . ONMOUSEOVER : td . addClassName ( "<STR_LIT>" ) ; for ( String targetID : targetIDs ) { Position pos = position2id . inverse ( ) . get ( targetID ) ; if ( pos != null ) { formatter . addStyleName ( pos . getRow ( ) , pos . getColumn ( ) , "<STR_LIT>" ) ; } } break ; case Event . ONMOUSEOUT : td . removeClassName ( "<STR_LIT>" ) ; for ( String targetID : targetIDs ) { Position pos = position2id . inverse ( ) . get ( targetID ) ; if ( pos != null ) { formatter . removeStyleName ( pos . getRow ( ) , pos . getColumn ( ) , "<STR_LIT>" ) ; } } break ; case Event . ONCLICK : onClick ( row , column ) ; break ; default : break ; } } } } } </s>
<s> package annis . gui . widgets . gwt . client ; import com . google . gwt . dom . client . Element ; import com . google . gwt . dom . client . MediaElement ; import com . google . gwt . user . client . ui . Widget ; import com . vaadin . terminal . gwt . client . ApplicationConnection ; import com . vaadin . terminal . gwt . client . Paintable ; import com . vaadin . terminal . gwt . client . UIDL ; import com . vaadin . terminal . gwt . client . VConsole ; public class VMediaPlayerBase extends Widget implements Paintable { public static final String PLAY = "<STR_LIT>" ; public static final String PAUSE = "<STR_LIT>" ; public static final String STOP = "<STR_LIT>" ; public static final String SOURCE_URL = "<STR_LIT:url>" ; public static final String MIME_TYPE = "<STR_LIT>" ; public static final String CANNOT_PLAY = "<STR_LIT>" ; public static final String PLAYER_LOADED = "<STR_LIT>" ; private MediaElement media ; protected String paintableId ; ApplicationConnection gClient ; public VMediaPlayerBase ( MediaElement media ) { this . media = media ; setElement ( this . media ) ; media . setControls ( true ) ; media . setAutoplay ( false ) ; media . setPreload ( MediaElement . PRELOAD_METADATA ) ; media . setLoop ( false ) ; } @ Override protected void onUnload ( ) { media . pause ( ) ; media . setSrc ( "<STR_LIT>" ) ; } @ Override public void updateFromUIDL ( UIDL uidl , ApplicationConnection client ) { if ( client . updateComponent ( this , uidl , true ) ) { return ; } this . gClient = client ; paintableId = uidl . getId ( ) ; if ( media == null ) { VConsole . error ( "<STR_LIT>" ) ; return ; } if ( uidl . hasAttribute ( SOURCE_URL ) ) { registerMetadataLoadedEvent ( media ) ; if ( uidl . hasAttribute ( MIME_TYPE ) ) { VConsole . log ( "<STR_LIT>" + media . canPlayType ( uidl . getStringAttribute ( MIME_TYPE ) ) + "<STR_LIT:\">" ) ; if ( media . canPlayType ( uidl . getStringAttribute ( MIME_TYPE ) ) . equals ( MediaElement . CANNOT_PLAY ) ) { VConsole . log ( "<STR_LIT>" ) ; gClient . updateVariable ( paintableId , CANNOT_PLAY , true , true ) ; } } media . setSrc ( uidl . getStringAttribute ( SOURCE_URL ) ) ; } if ( uidl . hasAttribute ( PLAY ) ) { String [ ] time = uidl . getStringArrayAttribute ( PLAY ) ; if ( time . length == <NUM_LIT:1> ) { media . setCurrentTime ( Double . parseDouble ( time [ <NUM_LIT:0> ] ) ) ; } else if ( time . length == <NUM_LIT:2> ) { media . setCurrentTime ( Double . parseDouble ( time [ <NUM_LIT:0> ] ) ) ; setEndTimeOnce ( media , Double . parseDouble ( time [ <NUM_LIT:1> ] ) ) ; } media . play ( ) ; } else if ( uidl . hasAttribute ( PAUSE ) ) { media . pause ( ) ; } else if ( uidl . hasAttribute ( STOP ) ) { media . pause ( ) ; media . setSrc ( "<STR_LIT>" ) ; } } public String getMimeType ( ) { Exception ex = new UnsupportedOperationException ( "<STR_LIT>" ) ; VConsole . error ( ex ) ; return null ; } ; private void metaDataWasLoaded ( ) { if ( gClient != null && paintableId != null ) { gClient . updateVariable ( paintableId , PLAYER_LOADED , true , true ) ; } } private native void setEndTimeOnce ( Element elem , double endTime ) ; private native void registerMetadataLoadedEvent ( Element el ) ; public MediaElement getMedia ( ) { return media ; } } </s>
<s> package annis . gui . widgets . gwt . client ; import com . google . gwt . dom . client . Document ; import com . google . gwt . dom . client . Element ; import com . google . gwt . dom . client . Style ; import com . vaadin . terminal . gwt . client . Util ; public class VVideoPlayer extends VMediaPlayerBase { private static String CLASSNAME = "<STR_LIT>" ; public VVideoPlayer ( ) { super ( Document . get ( ) . createVideoElement ( ) ) ; setStyleName ( CLASSNAME ) ; updateDimensionsWhenMetadataLoaded ( getMedia ( ) ) ; } @ Override public String getMimeType ( ) { return "<STR_LIT>" ; } private void updateSizeFromMetadata ( int width , int height ) { getMedia ( ) . getStyle ( ) . setWidth ( width , Style . Unit . PX ) ; getMedia ( ) . getStyle ( ) . setHeight ( height , Style . Unit . PX ) ; Util . notifyParentOfSizeChange ( this , true ) ; } private native void updateDimensionsWhenMetadataLoaded ( Element el ) ; } </s>
<s> package annis . gui . widgets . gwt . client ; import com . google . gwt . dom . client . Document ; import com . google . gwt . dom . client . Style ; import com . vaadin . terminal . gwt . client . ApplicationConnection ; import com . vaadin . terminal . gwt . client . BrowserInfo ; import com . vaadin . terminal . gwt . client . UIDL ; public class VAudioPlayer extends VMediaPlayerBase { private static String CLASSNAME = "<STR_LIT>" ; public VAudioPlayer ( ) { super ( Document . get ( ) . createAudioElement ( ) ) ; setStyleName ( CLASSNAME ) ; } @ Override public void updateFromUIDL ( UIDL uidl , ApplicationConnection client ) { if ( client . updateComponent ( this , uidl , true ) ) { return ; } super . updateFromUIDL ( uidl , client ) ; Style mediaStyle = getMedia ( ) . getStyle ( ) ; if ( ( mediaStyle . getHeight ( ) == null || "<STR_LIT>" . equals ( mediaStyle . getHeight ( ) ) ) ) { if ( BrowserInfo . get ( ) . isChrome ( ) ) { mediaStyle . setHeight ( <NUM_LIT:32> , Style . Unit . PX ) ; } else { mediaStyle . setHeight ( <NUM_LIT> , Style . Unit . PX ) ; } } } @ Override public String getMimeType ( ) { return "<STR_LIT>" ; } } </s>
<s> package annis . gui . widgets ; import annis . gui . widgets . gwt . client . VVideoPlayer ; import com . vaadin . ui . ClientWidget ; @ ClientWidget ( VVideoPlayer . class ) public class VideoPlayer extends MediaPlayerBase { public VideoPlayer ( String resourceURL , String mimeType ) { super ( resourceURL , mimeType ) ; } } </s>
<s> package annis . gui . widgets . grid ; import java . util . ArrayList ; import java . util . BitSet ; public class Row { private ArrayList < GridEvent > events ; private BitSet occupancySet ; public Row ( ) { this . events = new ArrayList < GridEvent > ( ) ; occupancySet = new BitSet ( ) ; } public boolean addEvent ( GridEvent e ) { BitSet eventOccupance = new BitSet ( e . getRight ( ) ) ; eventOccupance . set ( e . getLeft ( ) , e . getRight ( ) + <NUM_LIT:1> , true ) ; if ( occupancySet . intersects ( eventOccupance ) ) { return false ; } occupancySet . or ( eventOccupance ) ; events . add ( e ) ; return true ; } public boolean canMerge ( Row other ) { return ! occupancySet . intersects ( other . occupancySet ) ; } public boolean merge ( Row other ) throws IllegalArgumentException { if ( canMerge ( other ) ) { occupancySet . or ( other . occupancySet ) ; for ( GridEvent e : other . events ) { events . add ( e ) ; } return true ; } else { return false ; } } public ArrayList < GridEvent > getEvents ( ) { return events ; } } </s>
<s> package annis . gui . widgets . grid ; import java . util . LinkedList ; import java . util . List ; public class GridEvent { private String id ; private int left ; private int right ; private String value ; private Long match ; private List < String > coveredIDs ; private Double startTime ; private Double endTime ; private boolean gap ; public GridEvent ( String id , int left , int right , String value ) { this . id = id ; this . left = left ; this . right = right ; this . value = value ; this . coveredIDs = new LinkedList < String > ( ) ; } public String getId ( ) { return id ; } public void setId ( String id ) { this . id = id ; } public int getLeft ( ) { return left ; } public void setLeft ( int left ) { this . left = left ; } public int getRight ( ) { return right ; } public void setRight ( int right ) { this . right = right ; } public String getValue ( ) { return value ; } public void setValue ( String value ) { this . value = value ; } public List < String > getCoveredIDs ( ) { return coveredIDs ; } public Long getMatch ( ) { return match ; } public void setMatch ( Long match ) { this . match = match ; } public Double getStartTime ( ) { return startTime ; } public void setStartTime ( Double startTime ) { this . startTime = startTime ; } public Double getEndTime ( ) { return endTime ; } public void setEndTime ( Double endTime ) { this . endTime = endTime ; } public boolean isGap ( ) { return gap ; } public void setGap ( boolean gap ) { this . gap = gap ; } @ Override public String toString ( ) { return "<STR_LIT>" + id + "<STR_LIT>" + value + "<STR_LIT:U+0020(>" + left + "<STR_LIT:->" + right + "<STR_LIT:)>" ; } } </s>
<s> package annis . gui . widgets . grid ; import annis . gui . MatchedNodeColors ; import annis . gui . media . MediaController ; import annis . gui . widgets . gwt . client . VAnnotationGrid ; import com . vaadin . terminal . PaintException ; import com . vaadin . terminal . PaintTarget ; import com . vaadin . ui . AbstractComponent ; import com . vaadin . ui . ClientWidget ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . Map ; @ ClientWidget ( VAnnotationGrid . class ) public class AnnotationGrid extends AbstractComponent { private Map < String , ArrayList < Row > > rowsByAnnotation ; private MediaController mediaController ; private String resultID ; public AnnotationGrid ( MediaController mediaController , String resultID ) { this . mediaController = mediaController ; this . resultID = resultID ; } @ Override public void changeVariables ( Object source , Map < String , Object > variables ) { if ( variables . containsKey ( "<STR_LIT>" ) ) { if ( mediaController != null && resultID != null ) { String playString = ( String ) variables . get ( "<STR_LIT>" ) ; String [ ] split = playString . split ( "<STR_LIT:->" ) ; if ( split . length == <NUM_LIT:1> ) { mediaController . play ( resultID , Double . parseDouble ( split [ <NUM_LIT:0> ] ) ) ; } else if ( split . length == <NUM_LIT:2> ) { mediaController . play ( resultID , Double . parseDouble ( split [ <NUM_LIT:0> ] ) , Double . parseDouble ( split [ <NUM_LIT:1> ] ) ) ; } } } } @ Override public void paintContent ( PaintTarget target ) throws PaintException { super . paintContent ( target ) ; if ( rowsByAnnotation != null ) { target . startTag ( "<STR_LIT>" ) ; for ( Map . Entry < String , ArrayList < Row > > anno : rowsByAnnotation . entrySet ( ) ) { for ( Row row : anno . getValue ( ) ) { target . startTag ( "<STR_LIT>" ) ; target . addAttribute ( "<STR_LIT>" , anno . getKey ( ) ) ; ArrayList < GridEvent > rowEvents = row . getEvents ( ) ; Collections . sort ( rowEvents , new Comparator < GridEvent > ( ) { @ Override public int compare ( GridEvent o1 , GridEvent o2 ) { return ( ( Integer ) o1 . getLeft ( ) ) . compareTo ( o2 . getLeft ( ) ) ; } } ) ; target . startTag ( "<STR_LIT>" ) ; for ( GridEvent event : rowEvents ) { target . startTag ( "<STR_LIT>" ) ; target . addAttribute ( "<STR_LIT:id>" , event . getId ( ) ) ; target . addAttribute ( "<STR_LIT>" , event . getLeft ( ) ) ; target . addAttribute ( "<STR_LIT>" , event . getRight ( ) ) ; target . addAttribute ( "<STR_LIT:value>" , event . getValue ( ) ) ; if ( event . getStartTime ( ) != null ) { target . addAttribute ( "<STR_LIT>" , event . getStartTime ( ) ) ; if ( event . getEndTime ( ) != null ) { target . addAttribute ( "<STR_LIT>" , event . getEndTime ( ) ) ; } } ArrayList < String > styles = getStyles ( event , anno . getKey ( ) ) ; if ( styles . size ( ) > <NUM_LIT:0> ) { target . addAttribute ( "<STR_LIT>" , styles . toArray ( ) ) ; } target . addAttribute ( "<STR_LIT>" , event . getCoveredIDs ( ) . toArray ( ) ) ; target . endTag ( "<STR_LIT>" ) ; } target . endTag ( "<STR_LIT>" ) ; target . endTag ( "<STR_LIT>" ) ; } } target . endTag ( "<STR_LIT>" ) ; } } private ArrayList < String > getStyles ( GridEvent event , String annoName ) { ArrayList < String > styles = new ArrayList < String > ( ) ; if ( "<STR_LIT>" . equals ( annoName ) ) { styles . add ( "<STR_LIT>" ) ; } else if ( event . isGap ( ) ) { styles . add ( "<STR_LIT>" ) ; } else { styles . add ( "<STR_LIT>" ) ; } if ( event . getMatch ( ) != null ) { styles . add ( "<STR_LIT>" + MatchedNodeColors . colorClassByMatch ( event . getMatch ( ) ) ) ; } return styles ; } public Map < String , ArrayList < Row > > getRowsByAnnotation ( ) { return rowsByAnnotation ; } public void setRowsByAnnotation ( Map < String , ArrayList < Row > > rowsByAnnotation ) { this . rowsByAnnotation = rowsByAnnotation ; } } </s>
<s> package annis . gui . widgets ; import annis . gui . media . MediaPlayer ; import annis . gui . media . MimeTypeErrorListener ; import annis . gui . widgets . gwt . client . VMediaPlayerBase ; import annis . visualizers . LoadableVisualizer ; import com . vaadin . terminal . PaintException ; import com . vaadin . terminal . PaintTarget ; import com . vaadin . terminal . gwt . client . VConsole ; import com . vaadin . ui . AbstractComponent ; import java . util . HashSet ; import java . util . Map ; import java . util . Set ; public abstract class MediaPlayerBase extends AbstractComponent implements MediaPlayer , LoadableVisualizer { public enum PlayerAction { idle , play , pause , stop } private PlayerAction action ; private Double startTime ; private Double endTime ; private boolean sourcesAdded ; private String resourceURL ; private String mimeType ; private boolean wasLoaded ; private Set < Callback > callbacks ; public MediaPlayerBase ( String resourceURL , String mimeType ) { this . resourceURL = resourceURL ; this . mimeType = mimeType ; this . callbacks = new HashSet < Callback > ( ) ; this . wasLoaded = false ; } @ Override public void play ( double start ) { action = PlayerAction . play ; startTime = start ; endTime = null ; requestRepaint ( ) ; } @ Override public void play ( double start , double end ) { action = PlayerAction . play ; startTime = start ; endTime = end ; requestRepaint ( ) ; } @ Override public void pause ( ) { action = PlayerAction . pause ; requestRepaint ( ) ; } @ Override public void stop ( ) { action = PlayerAction . stop ; requestRepaint ( ) ; } @ Override public void changeVariables ( Object source , Map < String , Object > variables ) { super . changeVariables ( source , variables ) ; if ( ( Boolean ) variables . get ( VMediaPlayerBase . CANNOT_PLAY ) == Boolean . TRUE ) { if ( getWindow ( ) instanceof MimeTypeErrorListener ) { ( ( MimeTypeErrorListener ) getWindow ( ) ) . notifyCannotPlayMimeType ( mimeType ) ; } } if ( ( Boolean ) variables . get ( VMediaPlayerBase . PLAYER_LOADED ) == Boolean . TRUE ) { wasLoaded = true ; for ( Callback c : callbacks ) { c . visualizerLoaded ( this ) ; } } } @ Override public void detach ( ) { super . detach ( ) ; wasLoaded = false ; sourcesAdded = false ; startTime = null ; endTime = null ; } @ Override public void paintContent ( PaintTarget target ) throws PaintException { super . paintContent ( target ) ; if ( target . isFullRepaint ( ) ) { sourcesAdded = false ; wasLoaded = false ; } boolean sourcesNeeded = true ; if ( action == PlayerAction . play ) { String [ ] args ; if ( endTime == null ) { args = new String [ ] { "<STR_LIT>" + startTime } ; } else { args = new String [ ] { "<STR_LIT>" + startTime , "<STR_LIT>" + endTime } ; } target . addAttribute ( VMediaPlayerBase . PLAY , args ) ; action = PlayerAction . idle ; } else if ( action == PlayerAction . pause ) { target . addAttribute ( VMediaPlayerBase . PAUSE , true ) ; action = PlayerAction . idle ; } else if ( action == PlayerAction . stop ) { target . addAttribute ( VMediaPlayerBase . STOP , true ) ; action = PlayerAction . idle ; sourcesAdded = false ; sourcesNeeded = false ; } if ( sourcesNeeded && ! sourcesAdded ) { target . addAttribute ( VMediaPlayerBase . SOURCE_URL , resourceURL ) ; target . addAttribute ( VMediaPlayerBase . MIME_TYPE , mimeType ) ; sourcesAdded = true ; } } @ Override public void addOnLoadCallBack ( Callback callback ) { this . callbacks . add ( callback ) ; } @ Override public void clearCallbacks ( ) { this . callbacks . clear ( ) ; } @ Override public boolean isLoaded ( ) { return wasLoaded ; } } </s>
<s> package net . wessendorf . enterprise . service ; import java . util . List ; import javax . inject . Inject ; import net . wessendorf . enterprise . beans . Person ; import net . wessendorf . enterprise . jpa . dao . PersonDao ; public class PersonServerImpl implements PersonService { @ Inject private PersonDao dao ; public void removePerson ( Person person ) { dao . delete ( person ) ; } public Person savePerson ( Person person ) { return dao . persist ( person ) ; } public Person updatePerson ( Person person ) { return dao . update ( person ) ; } public List < Person > findAllPersons ( ) { return dao . loadAll ( ) ; } public Person findPersonById ( String id ) { return dao . loadById ( id ) ; } public List < Person > findPersonsByLastName ( String lastName ) { return dao . findByLastName ( lastName ) ; } } </s>
<s> package net . wessendorf . enterprise . service ; import java . util . List ; import net . wessendorf . enterprise . beans . Person ; public interface PersonService { Person savePerson ( Person person ) ; void removePerson ( Person person ) ; Person updatePerson ( Person person ) ; Person findPersonById ( String id ) ; List < Person > findAllPersons ( ) ; List < Person > findPersonsByLastName ( String lastName ) ; } </s>
<s> package net . wessendorf . enterprise . jpa . dao ; import java . io . Serializable ; import java . util . Collections ; import java . util . List ; import javax . persistence . EntityManager ; import javax . persistence . PersistenceContext ; import javax . persistence . Query ; import org . apache . myfaces . extensions . cdi . jpa . api . Transactional ; import net . wessendorf . enterprise . beans . Person ; public class PersonDao { @ Transactional public void delete ( Person entity ) { em . remove ( em . merge ( entity ) ) ; } @ Transactional public Person persist ( Person entity ) { em . persist ( entity ) ; return entity ; } @ Transactional public Person update ( Person entity ) { return em . merge ( entity ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) public List < Person > loadAll ( ) { return em . createQuery ( "<STR_LIT>" + Person . class . getSimpleName ( ) + "<STR_LIT>" ) . getResultList ( ) ; } public Person loadById ( Serializable id ) { return em . find ( Person . class , id ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) public List < Person > findByLastName ( String lastname ) { if ( lastname == null ) return Collections . emptyList ( ) ; Query q = em . createQuery ( QUERY_BY_LASTNAME ) ; q . setParameter ( "<STR_LIT>" , lastname . toLowerCase ( ) + "<STR_LIT:%>" ) ; return q . getResultList ( ) ; } @ PersistenceContext ( unitName = "<STR_LIT>" ) protected EntityManager em ; private final String QUERY_BY_LASTNAME = "<STR_LIT>" ; } </s>
<s> package net . wessendorf . enterprise . beans ; import javax . persistence . Basic ; import javax . persistence . DiscriminatorValue ; import javax . persistence . Entity ; @ Entity @ DiscriminatorValue ( "<STR_LIT>" ) public class Friend extends Person { private static final long serialVersionUID = <NUM_LIT:1L> ; @ Basic private String nickname ; public String getNickname ( ) { return nickname ; } public void setNickname ( String nickname ) { this . nickname = nickname ; } } </s>
<s> package net . wessendorf . enterprise . beans ; import java . io . Serializable ; import javax . persistence . GeneratedValue ; import javax . persistence . GenerationType ; import javax . persistence . Id ; import javax . persistence . MappedSuperclass ; import javax . persistence . Version ; @ MappedSuperclass public abstract class PersistentObject implements Serializable { private static final long serialVersionUID = <NUM_LIT:1L> ; @ Id @ GeneratedValue ( strategy = GenerationType . AUTO ) private String id ; @ Version private int versionId ; public String getId ( ) { return id ; } public void setId ( String id ) { this . id = id ; } public int getVersionId ( ) { return versionId ; } } </s>
<s> package net . wessendorf . enterprise . beans ; import javax . persistence . DiscriminatorColumn ; import javax . persistence . DiscriminatorType ; import javax . persistence . Entity ; import javax . persistence . Inheritance ; import javax . persistence . InheritanceType ; @ Entity @ DiscriminatorColumn ( name = "<STR_LIT>" , discriminatorType = DiscriminatorType . STRING ) @ Inheritance ( strategy = InheritanceType . JOINED ) public abstract class Person extends PersistentObject { private static final long serialVersionUID = <NUM_LIT:1L> ; private String firstname ; private String lastname ; public String getFirstname ( ) { return firstname ; } public void setFirstname ( String firstname ) { this . firstname = firstname ; } public String getLastname ( ) { return lastname ; } public void setLastname ( String lastname ) { this . lastname = lastname ; } } </s>
<s> package net . wessendorf . enterprise . faces ; import java . util . List ; import javax . enterprise . context . RequestScoped ; import javax . inject . Inject ; import javax . inject . Named ; import net . wessendorf . enterprise . beans . Person ; import net . wessendorf . enterprise . service . PersonService ; @ Named ( "<STR_LIT>" ) @ RequestScoped public class AllPersonsController { @ Inject private PersonService service ; private Person toDelete ; public List < Person > getPersons ( ) { return service . findAllPersons ( ) ; } public void setToDelete ( Person toDelete ) { this . toDelete = toDelete ; } public Person getToDelete ( ) { return toDelete ; } public String delete ( ) { service . removePerson ( toDelete ) ; return null ; } } </s>
<s> package net . wessendorf . enterprise . faces ; import javax . enterprise . context . RequestScoped ; import javax . inject . Inject ; import javax . inject . Named ; import net . wessendorf . enterprise . beans . Friend ; import net . wessendorf . enterprise . service . PersonService ; @ Named ( "<STR_LIT>" ) @ RequestScoped public class CreatePersonController { @ Inject private PersonService service ; private Friend person = new Friend ( ) ; public String createPerson ( ) { service . savePerson ( person ) ; return "<STR_LIT>" ; } public Friend getPerson ( ) { return person ; } public void setPerson ( Friend person ) { this . person = person ; } } </s>
<s> package org . elasticsearch . river . redis ; import static org . junit . Assert . * ; import org . junit . * ; import static org . elasticsearch . common . xcontent . XContentFactory . jsonBuilder ; import org . elasticsearch . action . admin . indices . create . CreateIndexRequest ; import org . elasticsearch . action . admin . indices . delete . DeleteIndexRequest ; import org . elasticsearch . common . settings . ImmutableSettings ; import org . elasticsearch . common . xcontent . XContentBuilder ; import org . elasticsearch . indices . IndexMissingException ; import org . elasticsearch . node . Node ; import org . elasticsearch . node . NodeBuilder ; import redis . clients . jedis . Jedis ; public class RedisRiverTest { private static Node node ; private static Jedis jedis ; @ BeforeClass public static void setupTest ( ) throws Exception { jedis = new Jedis ( "<STR_LIT:localhost>" ) ; } @ Test public void canConnect ( ) throws Exception { assertNotNull ( jedis ) ; } @ Test public void canPush ( ) throws Exception { assertNotNull ( jedis ) ; } } </s>
<s> package org . elasticsearch . river . redis ; import org . elasticsearch . ExceptionsHelper ; import org . elasticsearch . action . ActionListener ; import org . elasticsearch . action . bulk . BulkRequestBuilder ; import org . elasticsearch . action . bulk . BulkResponse ; import org . elasticsearch . client . Client ; import org . elasticsearch . client . Requests ; import org . elasticsearch . cluster . block . ClusterBlockException ; import org . elasticsearch . common . Strings ; import org . elasticsearch . common . inject . Inject ; import org . elasticsearch . common . unit . TimeValue ; import org . elasticsearch . common . xcontent . XContentBuilder ; import org . elasticsearch . common . xcontent . XContentFactory ; import org . elasticsearch . common . xcontent . support . XContentMapValues ; import org . elasticsearch . indices . IndexAlreadyExistsException ; import org . elasticsearch . river . AbstractRiverComponent ; import org . elasticsearch . river . River ; import org . elasticsearch . river . RiverName ; import org . elasticsearch . river . RiverSettings ; import org . elasticsearch . common . util . concurrent . EsExecutors ; import org . elasticsearch . threadpool . ThreadPool ; import java . util . concurrent . Executors ; import java . util . concurrent . ScheduledExecutorService ; import java . util . concurrent . ScheduledFuture ; import java . util . concurrent . TimeUnit ; import java . util . List ; import java . util . Map ; import redis . clients . jedis . Jedis ; import redis . clients . jedis . JedisPool ; import redis . clients . jedis . JedisPubSub ; public class RedisRiver extends AbstractRiverComponent implements River { private final Client client ; private volatile Thread thread ; private volatile boolean closed = false ; private volatile BulkRequestBuilder currentRequest ; private volatile JedisPool jedisPool ; private final String redisHost ; private final int redisPort ; private final String redisKey ; private final String redisMode ; private final int redisDB ; private final int bulkSize ; private final int bulkTimeout ; @ Inject public RedisRiver ( RiverName riverName , RiverSettings settings , Client client ) { super ( riverName , settings ) ; this . client = client ; if ( settings . settings ( ) . containsKey ( "<STR_LIT>" ) ) { Map < String , Object > redisSettings = ( Map < String , Object > ) settings . settings ( ) . get ( "<STR_LIT>" ) ; redisHost = XContentMapValues . nodeStringValue ( redisSettings . get ( "<STR_LIT>" ) , "<STR_LIT:localhost>" ) ; redisPort = XContentMapValues . nodeIntegerValue ( redisSettings . get ( "<STR_LIT>" ) , <NUM_LIT> ) ; redisKey = XContentMapValues . nodeStringValue ( redisSettings . get ( "<STR_LIT:key>" ) , "<STR_LIT>" ) ; redisMode = XContentMapValues . nodeStringValue ( redisSettings . get ( "<STR_LIT>" ) , "<STR_LIT:list>" ) ; redisDB = XContentMapValues . nodeIntegerValue ( redisSettings . get ( "<STR_LIT>" ) , <NUM_LIT:0> ) ; } else { redisHost = "<STR_LIT:localhost>" ; redisPort = <NUM_LIT> ; redisKey = "<STR_LIT>" ; redisMode = "<STR_LIT:list>" ; redisDB = <NUM_LIT:0> ; } if ( settings . settings ( ) . containsKey ( "<STR_LIT:index>" ) ) { Map < String , Object > indexSettings = ( Map < String , Object > ) settings . settings ( ) . get ( "<STR_LIT:index>" ) ; bulkSize = XContentMapValues . nodeIntegerValue ( indexSettings . get ( "<STR_LIT>" ) , <NUM_LIT:100> ) ; bulkTimeout = XContentMapValues . nodeIntegerValue ( indexSettings . get ( "<STR_LIT>" ) , <NUM_LIT:5> ) ; } else { bulkSize = <NUM_LIT:100> ; bulkTimeout = <NUM_LIT:5> ; } if ( logger . isInfoEnabled ( ) ) logger . info ( "<STR_LIT>" , redisHost , redisPort , redisKey , redisDB , bulkSize , bulkTimeout ) ; } @ Override public void start ( ) { if ( logger . isInfoEnabled ( ) ) logger . info ( "<STR_LIT>" ) ; try { this . jedisPool = new JedisPool ( this . redisHost , this . redisPort ) ; } catch ( Exception e ) { logger . error ( "<STR_LIT>" ) ; return ; } currentRequest = client . prepareBulk ( ) ; if ( redisMode . equalsIgnoreCase ( "<STR_LIT:list>" ) ) { thread = EsExecutors . daemonThreadFactory ( settings . globalSettings ( ) , "<STR_LIT>" ) . newThread ( new RedisListRunner ( ) ) ; } else if ( redisMode . equalsIgnoreCase ( "<STR_LIT>" ) ) { logger . error ( "<STR_LIT>" ) ; return ; } else { logger . error ( "<STR_LIT>" ) ; return ; } thread . start ( ) ; } @ Override public void close ( ) { if ( logger . isInfoEnabled ( ) ) logger . info ( "<STR_LIT>" ) ; closed = true ; if ( thread != null ) { thread . interrupt ( ) ; } } private class RedisPubSubRunner implements Runnable { private Jedis jedis ; private boolean updating = false ; private final ScheduledExecutorService watchScheduler ; private ScheduledFuture < ? > watchFuture ; public RedisPubSubRunner ( ) { super ( ) ; this . watchScheduler = Executors . newScheduledThreadPool ( <NUM_LIT:1> ) ; } @ Override public void run ( ) { try { this . jedis = jedisPool . getResource ( ) ; if ( redisDB > <NUM_LIT:0> ) { this . jedis . select ( redisDB ) ; } } catch ( Exception e ) { logger . error ( "<STR_LIT>" ) ; return ; } if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" , redisKey ) ; this . jedis . subscribe ( new RiverListener ( ) , redisKey ) ; watchFuture = watchScheduler . scheduleWithFixedDelay ( ( Runnable ) new BulkWatcher ( ) , <NUM_LIT:5> , <NUM_LIT:5> , TimeUnit . SECONDS ) ; } private void processBulkIfNeeded ( Boolean force ) { logger . info ( "<STR_LIT>" ) ; if ( updating ) { return ; } updating = true ; int actionCount = currentRequest . numberOfActions ( ) ; if ( actionCount != <NUM_LIT:0> && ( actionCount > bulkSize || force == true ) ) { try { BulkResponse response = currentRequest . execute ( ) . actionGet ( ) ; if ( response . hasFailures ( ) ) { logger . error ( "<STR_LIT>" + response . buildFailureMessage ( ) ) ; } } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; } currentRequest = client . prepareBulk ( ) ; } updating = false ; logger . info ( "<STR_LIT>" ) ; } private class BulkWatcher implements Runnable { @ Override public void run ( ) { processBulkIfNeeded ( true ) ; } } private class RiverListener extends JedisPubSub { private void queueMessage ( String message ) { try { if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" ) ; byte [ ] data = message . getBytes ( ) ; currentRequest . add ( data , <NUM_LIT:0> , data . length , false ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" + currentRequest . numberOfActions ( ) ) ; processBulkIfNeeded ( false ) ; } catch ( Exception e ) { logger . error ( "<STR_LIT>" ) ; } } public void onMessage ( String channel , String message ) { queueMessage ( message ) ; } public void onSubscribe ( String channel , int subscribedChannels ) { } public void onUnsubscribe ( String channel , int subscribedChannels ) { } public void onPSubscribe ( String pattern , int subscribedChannels ) { } public void onPUnsubscribe ( String pattern , int subscribedChannels ) { } public void onPMessage ( String pattern , String channel , String message ) { } } } private class RedisListRunner implements Runnable { private Jedis jedis ; @ Override public void run ( ) { logger . info ( "<STR_LIT>" ) ; while ( true ) { if ( closed ) { return ; } loop ( ) ; } } private void loop ( ) { List < String > response ; try { this . jedis = jedisPool . getResource ( ) ; if ( redisDB > <NUM_LIT:0> ) { jedis . select ( redisDB ) ; } if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" ) ; response = jedis . blpop ( bulkTimeout , redisKey ) ; } catch ( Exception e ) { if ( logger . isInfoEnabled ( ) ) logger . info ( "<STR_LIT>" ) ; jedisPool . returnBrokenResource ( this . jedis ) ; try { Thread . sleep ( <NUM_LIT> ) ; } catch ( InterruptedException e1 ) { } return ; } if ( response != null ) { try { if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" , response ) ; byte [ ] data = response . get ( <NUM_LIT:1> ) . getBytes ( ) ; currentRequest . add ( data , <NUM_LIT:0> , data . length , false ) ; processBulkIfNeeded ( false ) ; } catch ( Exception e ) { logger . error ( "<STR_LIT>" ) ; } } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" ) ; processBulkIfNeeded ( true ) ; } jedisPool . returnResource ( this . jedis ) ; } private void processBulkIfNeeded ( Boolean force ) { int actionCount = currentRequest . numberOfActions ( ) ; if ( actionCount != <NUM_LIT:0> && ( actionCount > bulkSize || force == true ) ) { try { if ( logger . isDebugEnabled ( ) ) logger . debug ( "<STR_LIT>" , actionCount , bulkSize , force ) ; BulkResponse response = currentRequest . execute ( ) . actionGet ( ) ; if ( response . hasFailures ( ) ) { logger . error ( "<STR_LIT>" + response . buildFailureMessage ( ) ) ; } } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; } currentRequest = client . prepareBulk ( ) ; } else if ( logger . isDebugEnabled ( ) ) { logger . debug ( "<STR_LIT>" , actionCount , bulkSize , force ) ; } } } } </s>
<s> package org . elasticsearch . river . redis ; import org . elasticsearch . common . inject . AbstractModule ; import org . elasticsearch . river . River ; public class RedisRiverModule extends AbstractModule { @ Override protected void configure ( ) { bind ( River . class ) . to ( RedisRiver . class ) . asEagerSingleton ( ) ; } } </s>
<s> package org . elasticsearch . plugin . river . redis ; import org . elasticsearch . common . inject . Inject ; import org . elasticsearch . plugins . AbstractPlugin ; import org . elasticsearch . river . RiversModule ; import org . elasticsearch . river . redis . RedisRiverModule ; public class RedisRiverPlugin extends AbstractPlugin { @ Inject public RedisRiverPlugin ( ) { } @ Override public String name ( ) { return "<STR_LIT>" ; } @ Override public String description ( ) { return "<STR_LIT>" ; } public void onModule ( RiversModule module ) { module . registerRiver ( "<STR_LIT>" , RedisRiverModule . class ) ; } } </s>
<s> package com . fuze . Roll ; import java . io . File ; import java . io . FileOutputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . PrintWriter ; import java . text . SimpleDateFormat ; import java . util . Calendar ; import java . util . Properties ; import java . util . Random ; import java . util . logging . Logger ; import org . bukkit . command . Command ; import org . bukkit . command . CommandSender ; import org . bukkit . entity . Player ; import org . bukkit . plugin . java . JavaPlugin ; import org . bukkit . util . config . Configuration ; public class Roll extends JavaPlugin { private Logger log = Logger . getLogger ( "<STR_LIT>" ) ; public Configuration config ; static String mainDirectory = "<STR_LIT>" ; static File logfile = new File ( mainDirectory + File . separator + "<STR_LIT>" ) ; static Properties prop = new Properties ( ) ; Random rnd = new Random ( ) ; public String pVer = "<STR_LIT>" ; public String pName = "<STR_LIT>" ; public int default_max = <NUM_LIT:100> ; public int max = <NUM_LIT> ; public String msg_to_player = "<STR_LIT>" ; public String msg_to_all = "<STR_LIT>" ; public String numbers_format = "<STR_LIT>" ; public String msg_error_first_bigger = "<STR_LIT>" ; public String msg_error_equal = "<STR_LIT>" ; public String msg_error_negative = "<STR_LIT>" ; public String msg_error_max = "<STR_LIT>" ; public String msg_error_no_perms = "<STR_LIT>" ; public boolean allow_negative = false ; public boolean allow_equal = false ; public boolean msg_broadcast = true ; public boolean broadcast_numbers = true ; public static boolean msg_log = true ; @ Override public void onDisable ( ) { out ( "<STR_LIT:[>" + pName + "<STR_LIT>" + pVer + "<STR_LIT:]>" + "<STR_LIT>" ) ; } @ Override public void onEnable ( ) { out ( "<STR_LIT:[>" + pName + "<STR_LIT>" + pVer + "<STR_LIT:]>" + "<STR_LIT>" ) ; config = getConfiguration ( ) ; if ( ! ( new File ( getDataFolder ( ) , "<STR_LIT>" ) ) . exists ( ) ) { defaultConfig ( ) ; } loadConfig ( ) ; if ( ! logfile . exists ( ) ) { try { logfile . createNewFile ( ) ; FileOutputStream out = new FileOutputStream ( logfile ) ; prop . store ( out , null ) ; out . flush ( ) ; out . close ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; log . info ( "<STR_LIT>" ) ; } } } public boolean onCommand ( CommandSender sender , Command command , String commandLabel , String [ ] args ) { String commandName = command . getName ( ) . toLowerCase ( ) ; Player player = ( Player ) sender ; int roll = <NUM_LIT:0> ; if ( commandName . equalsIgnoreCase ( "<STR_LIT>" ) ) { if ( ! canRoll ( player ) ) { player . sendMessage ( parse ( msg_error_no_perms , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } if ( args . length == <NUM_LIT:0> ) { roll = rndNumber ( default_max ) ; player . sendMessage ( parse ( msg_to_player , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; broadcast ( player , parse ( msg_to_all , player , roll , toString ( roll ) , "<STR_LIT>" ) ) ; out ( parseToConsole ( msg_to_all , player , roll , toString ( roll ) , "<STR_LIT>" ) ) ; write ( "<STR_LIT:[>" + date ( "<STR_LIT>" ) + "<STR_LIT>" + player . getName ( ) + "<STR_LIT>" + roll + "<STR_LIT>" ) ; } else if ( args . length == <NUM_LIT:1> ) { if ( toInt ( args [ <NUM_LIT:0> ] ) > max && ! noLimit ( player ) ) { player . sendMessage ( parse ( msg_error_max , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } if ( toInt ( args [ <NUM_LIT:0> ] ) < <NUM_LIT:0> && ! allow_negative ) { player . sendMessage ( parse ( msg_error_negative , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } roll = rndNumber ( toInt ( args [ <NUM_LIT:0> ] ) ) ; player . sendMessage ( parse ( msg_to_player , player , roll , args [ <NUM_LIT:0> ] , "<STR_LIT>" ) ) ; broadcast ( player , parse ( msg_to_all , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; out ( parseToConsole ( msg_to_all , player , roll , args [ <NUM_LIT:0> ] , "<STR_LIT>" ) ) ; write ( "<STR_LIT:[>" + date ( "<STR_LIT>" ) + "<STR_LIT>" + player . getName ( ) + "<STR_LIT>" + roll + "<STR_LIT>" + toInt ( args [ <NUM_LIT:0> ] ) + "<STR_LIT:'>" ) ; } else if ( args . length == <NUM_LIT:2> ) { if ( toInt ( args [ <NUM_LIT:0> ] ) > toInt ( args [ <NUM_LIT:1> ] ) ) { player . sendMessage ( parse ( msg_error_first_bigger , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } if ( toInt ( args [ <NUM_LIT:0> ] ) > max && ! noLimit ( player ) ) { player . sendMessage ( parse ( msg_error_max , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } if ( toInt ( args [ <NUM_LIT:1> ] ) > max && ! noLimit ( player ) ) { player . sendMessage ( parse ( msg_error_max , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } if ( toInt ( args [ <NUM_LIT:0> ] ) == toInt ( args [ <NUM_LIT:1> ] ) && ! allow_equal && ! noLimit ( player ) ) { player . sendMessage ( parse ( msg_error_equal , player , roll , "<STR_LIT>" , "<STR_LIT>" ) ) ; return true ; } roll = rndNumber ( toInt ( args [ <NUM_LIT:1> ] ) - toInt ( args [ <NUM_LIT:0> ] ) + <NUM_LIT:1> ) + toInt ( args [ <NUM_LIT:0> ] ) ; player . sendMessage ( parse ( msg_to_player , player , roll , args [ <NUM_LIT:0> ] , args [ <NUM_LIT:1> ] ) ) ; broadcast ( player , parse ( msg_to_all , player , roll , args [ <NUM_LIT:0> ] , args [ <NUM_LIT:1> ] ) ) ; out ( parseToConsole ( msg_to_all , player , roll , args [ <NUM_LIT:0> ] , args [ <NUM_LIT:1> ] ) ) ; write ( "<STR_LIT:[>" + date ( "<STR_LIT>" ) + "<STR_LIT>" + player . getName ( ) + "<STR_LIT>" + roll + "<STR_LIT>" + toInt ( args [ <NUM_LIT:0> ] ) + "<STR_LIT:U+0020>" + toInt ( args [ <NUM_LIT:1> ] ) + "<STR_LIT:'>" ) ; } } return true ; } public void broadcast ( Player player , String text ) { if ( ! msg_broadcast ) { return ; } for ( Player p : getServer ( ) . getOnlinePlayers ( ) ) { if ( ! ( p . getName ( ) == player . getName ( ) ) ) { p . sendMessage ( text ) ; } } } public String parse ( String text , Player player , int roll , String first , String second ) { String out = "<STR_LIT>" ; out = text . replaceAll ( "<STR_LIT>" , "<STR_LIT>" + roll ) ; out = out . replaceAll ( "<STR_LIT>" , player . getDisplayName ( ) ) ; out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" + max ) ; if ( first == "<STR_LIT>" && second != "<STR_LIT>" ) { out = out . replaceAll ( "<STR_LIT>" , parseNumber ( <NUM_LIT:1> , first ) ) ; } else if ( second == "<STR_LIT>" && first != "<STR_LIT>" ) { out = out . replaceAll ( "<STR_LIT>" , parseNumber ( <NUM_LIT:2> , second ) ) ; } else if ( second == "<STR_LIT>" && first == "<STR_LIT>" ) { out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; } else if ( first != "<STR_LIT>" && second != "<STR_LIT>" ) { out = out . replaceAll ( "<STR_LIT>" , parseNumbers ( first , second ) ) ; } out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; return out ; } public String parseToConsole ( String text , Player player , int roll , String first , String second ) { String out = "<STR_LIT>" ; out = text . replaceAll ( "<STR_LIT>" , "<STR_LIT>" + roll ) ; out = out . replaceAll ( "<STR_LIT>" , player . getDisplayName ( ) ) ; out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" + max ) ; if ( first != "<STR_LIT>" && second != "<STR_LIT>" ) out = out . replaceAll ( "<STR_LIT>" , parseNumbers ( first , second ) ) ; out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; return out ; } public String parseNumbers ( String first , String second ) { String out = "<STR_LIT>" ; out = out . replaceAll ( "<STR_LIT>" , first ) ; out = out . replaceAll ( "<STR_LIT>" , second ) ; return out ; } public String parseNumber ( int num , String number ) { String out = "<STR_LIT>" ; if ( num == <NUM_LIT:1> ) { out = out . replaceAll ( "<STR_LIT>" , number ) ; out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; } else if ( num == <NUM_LIT:2> ) { out = out . replaceAll ( "<STR_LIT>" , number ) ; out = out . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; } else { out = "<STR_LIT>" ; } return out ; } public int toInt ( String string ) { return Integer . parseInt ( string ) ; } public int rndNumber ( int max ) { return rnd . nextInt ( max ) ; } private void loadConfig ( ) { config . load ( ) ; default_max = config . getInt ( "<STR_LIT>" , default_max ) ; max = config . getInt ( "<STR_LIT>" , max ) ; msg_to_player = config . getString ( "<STR_LIT>" , msg_to_player ) ; msg_to_all = config . getString ( "<STR_LIT>" , msg_to_all ) ; msg_to_all = config . getString ( "<STR_LIT>" , numbers_format ) ; msg_error_first_bigger = config . getString ( "<STR_LIT>" , msg_error_first_bigger ) ; msg_error_equal = config . getString ( "<STR_LIT>" , msg_error_equal ) ; msg_error_max = config . getString ( "<STR_LIT>" , msg_error_max ) ; msg_error_negative = config . getString ( "<STR_LIT>" , msg_error_negative ) ; msg_error_no_perms = config . getString ( "<STR_LIT>" , msg_error_no_perms ) ; msg_broadcast = config . getBoolean ( "<STR_LIT>" , msg_broadcast ) ; msg_log = config . getBoolean ( "<STR_LIT>" , msg_log ) ; allow_negative = config . getBoolean ( "<STR_LIT>" , allow_negative ) ; allow_equal = config . getBoolean ( "<STR_LIT>" , allow_equal ) ; } private void defaultConfig ( ) { config . setProperty ( "<STR_LIT>" , default_max ) ; config . setProperty ( "<STR_LIT>" , max ) ; config . setProperty ( "<STR_LIT>" , msg_to_player ) ; config . setProperty ( "<STR_LIT>" , msg_to_all ) ; config . setProperty ( "<STR_LIT>" , numbers_format ) ; config . setProperty ( "<STR_LIT>" , msg_error_first_bigger ) ; config . setProperty ( "<STR_LIT>" , msg_error_equal ) ; config . setProperty ( "<STR_LIT>" , msg_error_max ) ; config . setProperty ( "<STR_LIT>" , msg_error_negative ) ; config . setProperty ( "<STR_LIT>" , msg_error_no_perms ) ; config . setProperty ( "<STR_LIT>" , msg_broadcast ) ; config . setProperty ( "<STR_LIT>" , msg_log ) ; config . setProperty ( "<STR_LIT>" , allow_negative ) ; config . setProperty ( "<STR_LIT>" , allow_equal ) ; config . save ( ) ; } public static void write ( String warning ) { if ( ! msg_log ) { return ; } PrintWriter outputStream = null ; try { try { outputStream = new PrintWriter ( new FileWriter ( logfile , true ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } outputStream . println ( warning ) ; } finally { if ( outputStream != null ) { outputStream . close ( ) ; } } } public static String date ( String dateFormat ) { Calendar cal = Calendar . getInstance ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( dateFormat ) ; return sdf . format ( cal . getTime ( ) ) ; } public void out ( String msg ) { log . info ( msg ) ; } public boolean canRoll ( Player p ) { return p . hasPermission ( "<STR_LIT>" ) ; } public boolean noLimit ( Player p ) { return p . hasPermission ( "<STR_LIT>" ) ; } public String toString ( int i ) { return Integer . toString ( i ) ; } } </s>
<s> package org . smallbean . interview ; import java . io . BufferedInputStream ; import java . io . DataInputStream ; import java . io . File ; import java . io . FileInputStream ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . content . Context ; import android . content . Intent ; import android . content . res . TypedArray ; import android . graphics . Bitmap ; import android . graphics . BitmapFactory ; import android . media . AudioFormat ; import android . media . AudioManager ; import android . media . AudioTrack ; import android . os . AsyncTask ; import android . os . Bundle ; import android . util . Log ; import android . view . View ; import android . view . ViewGroup ; import android . widget . AdapterView ; import android . widget . BaseAdapter ; import android . widget . ImageView ; import android . widget . AdapterView . OnItemClickListener ; public class Audio extends Activity { private Data data = Data . getInstance ( ) ; private String [ ] audioFilePaths ; boolean isPlaying = false ; PlayAudio playTask ; File recordingFile ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . audio ) ; android . widget . Gallery audio_gallery = ( android . widget . Gallery ) findViewById ( R . id . audio_gallery ) ; audio_gallery . setAdapter ( new AudioAdapter ( this ) ) ; audio_gallery . setOnItemClickListener ( new OnItemClickListener ( ) { public void onItemClick ( AdapterView < ? > parent , View v , int position , long id ) { recordingFile = new File ( audioFilePaths [ position ] ) ; playTask = new PlayAudio ( ) ; playTask . execute ( ) ; } } ) ; } public void recordAudio ( View view ) { Intent intent = new Intent ( this , AudioRecorder . class ) ; startActivityForResult ( intent , <NUM_LIT:0> ) ; } public class AudioAdapter extends BaseAdapter { int mGalleryItemBackground ; private Context mContext ; private void getAudioPaths ( ) { String [ ] audioFiles = data . GetAudioURLs ( ) ; audioFilePaths = new String [ audioFiles . length ] ; for ( int i = <NUM_LIT:0> ; i < audioFiles . length ; i ++ ) { audioFilePaths [ i ] = audioFiles [ i ] ; } } public AudioAdapter ( Context c ) { getAudioPaths ( ) ; mContext = c ; TypedArray a = obtainStyledAttributes ( R . styleable . Gallery ) ; mGalleryItemBackground = a . getResourceId ( R . styleable . Gallery_android_galleryItemBackground , <NUM_LIT:0> ) ; a . recycle ( ) ; } public int getCount ( ) { return audioFilePaths . length ; } public Object getItem ( int position ) { return position ; } public long getItemId ( int position ) { return position ; } @ Override public View getView ( int position , View convertView , ViewGroup parent ) { ImageView musicNote = new ImageView ( mContext ) ; Bitmap mBitmap = BitmapFactory . decodeResource ( getResources ( ) , R . drawable . sub_audio_wotext ) ; musicNote . setLayoutParams ( new android . widget . Gallery . LayoutParams ( <NUM_LIT> , <NUM_LIT> ) ) ; musicNote . setBackgroundResource ( mGalleryItemBackground ) ; musicNote . setImageBitmap ( mBitmap ) ; return musicNote ; } } private class PlayAudio extends AsyncTask < Void , Integer , Void > { private int frequency = <NUM_LIT> ; private int channelConfiguration = AudioFormat . CHANNEL_CONFIGURATION_MONO ; private int audioEncoding = AudioFormat . ENCODING_PCM_16BIT ; @ Override protected Void doInBackground ( Void ... params ) { isPlaying = true ; int bufferSize = AudioTrack . getMinBufferSize ( frequency , channelConfiguration , audioEncoding ) ; short [ ] audiodata = new short [ bufferSize / <NUM_LIT:4> ] ; try { DataInputStream dis = new DataInputStream ( new BufferedInputStream ( new FileInputStream ( recordingFile ) ) ) ; AudioTrack audioTrack = new AudioTrack ( AudioManager . STREAM_MUSIC , frequency , channelConfiguration , audioEncoding , bufferSize , AudioTrack . MODE_STREAM ) ; audioTrack . play ( ) ; while ( isPlaying && dis . available ( ) > <NUM_LIT:0> ) { int i = <NUM_LIT:0> ; while ( dis . available ( ) > <NUM_LIT:0> && i < audiodata . length ) { audiodata [ i ] = dis . readShort ( ) ; i ++ ; } audioTrack . write ( audiodata , <NUM_LIT:0> , audiodata . length ) ; } dis . close ( ) ; } catch ( Throwable t ) { Log . e ( "<STR_LIT>" , "<STR_LIT>" ) ; } return null ; } } } </s>
<s> package org . smallbean . interview ; import java . io . IOException ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . content . Context ; import android . content . pm . ActivityInfo ; import android . os . Bundle ; import android . util . Log ; import android . view . SurfaceHolder ; import android . view . SurfaceView ; import android . view . Window ; import android . view . WindowManager ; import android . media . MediaRecorder ; import android . view . View ; import android . view . SurfaceHolder . Callback ; import android . view . View . OnClickListener ; import android . widget . Toast ; public class VideoCapture extends Activity implements OnClickListener , Callback { private String imageFilePath ; private boolean recording = false ; private MediaRecorder recorder ; private SurfaceHolder holder ; private Data data = Data . getInstance ( ) ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; requestWindowFeature ( Window . FEATURE_NO_TITLE ) ; getWindow ( ) . setFlags ( WindowManager . LayoutParams . FLAG_FULLSCREEN , WindowManager . LayoutParams . FLAG_FULLSCREEN ) ; setRequestedOrientation ( ActivityInfo . SCREEN_ORIENTATION_LANDSCAPE ) ; setContentView ( R . layout . cameraview ) ; imageFilePath = data . GetNewVideoURL ( ) ; Log . d ( "<STR_LIT>" , imageFilePath ) ; initRecorder ( ) ; SurfaceView cameraView = ( SurfaceView ) findViewById ( R . id . surface ) ; holder = cameraView . getHolder ( ) ; holder . addCallback ( this ) ; holder . setType ( SurfaceHolder . SURFACE_TYPE_PUSH_BUFFERS ) ; cameraView . setClickable ( true ) ; cameraView . setOnClickListener ( this ) ; } private void initRecorder ( ) { recorder = new MediaRecorder ( ) ; recorder . setAudioSource ( MediaRecorder . AudioSource . DEFAULT ) ; recorder . setVideoSource ( MediaRecorder . VideoSource . DEFAULT ) ; recorder . setOutputFormat ( MediaRecorder . OutputFormat . MPEG_4 ) ; recorder . setAudioEncoder ( MediaRecorder . AudioEncoder . DEFAULT ) ; recorder . setVideoEncoder ( MediaRecorder . VideoEncoder . DEFAULT ) ; recorder . setOutputFile ( imageFilePath ) ; recorder . setMaxDuration ( <NUM_LIT> ) ; recorder . setMaxFileSize ( <NUM_LIT> ) ; } @ Override public void onClick ( View v ) { if ( recording ) { recorder . stop ( ) ; showToast ( this , "<STR_LIT>" ) ; recording = false ; finish ( ) ; } else { recording = true ; recorder . start ( ) ; showToast ( this , "<STR_LIT>" ) ; } } @ Override public void surfaceChanged ( SurfaceHolder holder , int format , int width , int height ) { } private void prepareRecorder ( ) { recorder . setPreviewDisplay ( holder . getSurface ( ) ) ; try { recorder . prepare ( ) ; } catch ( IllegalStateException e ) { e . printStackTrace ( ) ; finish ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; finish ( ) ; } } @ Override public void surfaceCreated ( SurfaceHolder holder ) { prepareRecorder ( ) ; } @ Override public void surfaceDestroyed ( SurfaceHolder holder ) { if ( recording ) { recorder . stop ( ) ; recording = false ; } recorder . release ( ) ; finish ( ) ; } public void captureVideo ( View view ) { showToast ( this , imageFilePath ) ; } private void showToast ( Context mContext , String text ) { Toast . makeText ( mContext , text , Toast . LENGTH_SHORT ) . show ( ) ; } } </s>
<s> package org . smallbean . interview ; import java . util . HashMap ; import java . util . Map ; import android . graphics . drawable . Drawable ; import android . os . Handler ; import android . os . Message ; import android . widget . ImageView ; public class DrawableManager { private final Map < String , Drawable > drawableMap ; public DrawableManager ( ) { drawableMap = new HashMap < String , Drawable > ( ) ; } public Drawable fetchDrawable ( String urlString ) { if ( drawableMap . containsKey ( urlString ) ) { return drawableMap . get ( urlString ) ; } Drawable drawable = Drawable . createFromPath ( urlString ) ; drawableMap . put ( urlString , drawable ) ; return drawable ; } public void fetchDrawableOnThread ( final String urlString , final ImageView imageView ) { if ( drawableMap . containsKey ( urlString ) ) { imageView . setImageDrawable ( drawableMap . get ( urlString ) ) ; } final Handler handler = new Handler ( ) { @ Override public void handleMessage ( Message message ) { imageView . setImageDrawable ( ( Drawable ) message . obj ) ; } } ; Thread thread = new Thread ( ) { @ Override public void run ( ) { Drawable drawable = fetchDrawable ( urlString ) ; Message message = handler . obtainMessage ( <NUM_LIT:1> , drawable ) ; handler . sendMessage ( message ) ; } } ; thread . start ( ) ; } } </s>
<s> package org . smallbean . interview ; import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . DataInputStream ; import java . io . DataOutputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . text . SimpleDateFormat ; import java . util . Date ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . content . Context ; import android . content . Intent ; import android . media . AudioFormat ; import android . media . AudioManager ; import android . media . AudioRecord ; import android . media . AudioTrack ; import android . media . MediaRecorder ; import android . net . Uri ; import android . os . AsyncTask ; import android . os . Bundle ; import android . util . Log ; import android . view . View ; import android . view . View . OnClickListener ; import android . widget . Button ; import android . widget . TextView ; import android . widget . Toast ; public class AudioRecorder extends Activity implements OnClickListener { private static final int CAMERA_RESULT = <NUM_LIT:1> ; RecordAudio recordTask ; PlayAudio playTask ; Button startRecordingButton ; Button startPlaybackButton , stopPlaybackButton ; TextView durationText ; private Data data = Data . getInstance ( ) ; File recordingFile ; boolean isRecording = false ; boolean isPlaying = false ; int frequency = <NUM_LIT> ; int channelConfiguration = AudioFormat . CHANNEL_CONFIGURATION_MONO ; int audioEncoding = AudioFormat . ENCODING_PCM_16BIT ; long startRecordTime ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . audio_recorder ) ; durationText = ( TextView ) this . findViewById ( R . id . DurationTextView ) ; startRecordingButton = ( Button ) this . findViewById ( R . id . StartRecordingButton ) ; startPlaybackButton = ( Button ) this . findViewById ( R . id . StartPlaybackButton ) ; stopPlaybackButton = ( Button ) this . findViewById ( R . id . StopPlaybackButton ) ; startRecordingButton . setOnClickListener ( this ) ; startPlaybackButton . setOnClickListener ( this ) ; stopPlaybackButton . setOnClickListener ( this ) ; startPlaybackButton . setEnabled ( false ) ; stopPlaybackButton . setEnabled ( false ) ; String audioFilename = data . GetNewAudioURL ( ) ; recordingFile = new File ( audioFilename ) ; showToast ( this , audioFilename ) ; startRecordTime = System . currentTimeMillis ( ) ; System . out . println ( "<STR_LIT>" + startRecordTime ) ; record ( ) ; } public void onClick ( View v ) { if ( v == startRecordingButton ) { record ( ) ; } else if ( v == startPlaybackButton ) { play ( ) ; } else if ( v == stopPlaybackButton ) { stopPlaying ( ) ; } } public void play ( ) { startPlaybackButton . setEnabled ( true ) ; playTask = new PlayAudio ( ) ; playTask . execute ( ) ; stopPlaybackButton . setEnabled ( true ) ; } public void stopPlaying ( ) { isPlaying = false ; stopPlaybackButton . setEnabled ( false ) ; startPlaybackButton . setEnabled ( true ) ; } public void record ( ) { startRecordingButton . setEnabled ( false ) ; recordTask = new RecordAudio ( ) ; recordTask . execute ( ) ; } public void stopRecording ( ) { isRecording = false ; } public void stopRecording ( View view ) { this . stopRecording ( ) ; } public void takePhoto ( View view ) { this . takePhoto ( ) ; } public void takePhoto ( ) { String photoFilename = data . GetNewPhotoURL ( ) ; showToast ( this , photoFilename ) ; Uri imageFileUri = Uri . fromFile ( new File ( photoFilename ) ) ; Intent intent = new Intent ( android . provider . MediaStore . ACTION_IMAGE_CAPTURE ) ; intent . putExtra ( android . provider . MediaStore . EXTRA_OUTPUT , imageFileUri ) ; startActivityForResult ( intent , AudioRecorder . CAMERA_RESULT ) ; } private void showToast ( Context mContext , String text ) { Toast . makeText ( mContext , text , Toast . LENGTH_SHORT ) . show ( ) ; } protected void onActivityResult ( int requestCode , int resultCode , Intent image ) { super . onActivityResult ( requestCode , resultCode , image ) ; if ( requestCode == AudioRecorder . CAMERA_RESULT ) { } } private class PlayAudio extends AsyncTask < Void , Integer , Void > { @ Override protected Void doInBackground ( Void ... params ) { isPlaying = true ; int bufferSize = AudioTrack . getMinBufferSize ( frequency , channelConfiguration , audioEncoding ) ; short [ ] audiodata = new short [ bufferSize / <NUM_LIT:4> ] ; try { DataInputStream dis = new DataInputStream ( new BufferedInputStream ( new FileInputStream ( recordingFile ) ) ) ; AudioTrack audioTrack = new AudioTrack ( AudioManager . STREAM_MUSIC , frequency , channelConfiguration , audioEncoding , bufferSize , AudioTrack . MODE_STREAM ) ; audioTrack . play ( ) ; while ( isPlaying && dis . available ( ) > <NUM_LIT:0> ) { int i = <NUM_LIT:0> ; while ( dis . available ( ) > <NUM_LIT:0> && i < audiodata . length ) { audiodata [ i ] = dis . readShort ( ) ; i ++ ; } audioTrack . write ( audiodata , <NUM_LIT:0> , audiodata . length ) ; } dis . close ( ) ; startPlaybackButton . setEnabled ( false ) ; stopPlaybackButton . setEnabled ( true ) ; } catch ( Throwable t ) { Log . e ( "<STR_LIT>" , "<STR_LIT>" ) ; } return null ; } } private class RecordAudio extends AsyncTask < Void , Integer , Void > { @ Override protected Void doInBackground ( Void ... params ) { isRecording = true ; try { DataOutputStream dos = new DataOutputStream ( new BufferedOutputStream ( new FileOutputStream ( recordingFile ) ) ) ; int bufferSize = AudioRecord . getMinBufferSize ( frequency , channelConfiguration , audioEncoding ) ; AudioRecord audioRecord = new AudioRecord ( MediaRecorder . AudioSource . MIC , frequency , channelConfiguration , audioEncoding , bufferSize ) ; short [ ] buffer = new short [ bufferSize ] ; audioRecord . startRecording ( ) ; int r = <NUM_LIT:0> ; while ( isRecording ) { int bufferReadResult = audioRecord . read ( buffer , <NUM_LIT:0> , bufferSize ) ; for ( int i = <NUM_LIT:0> ; i < bufferReadResult ; i ++ ) { dos . writeShort ( buffer [ i ] ) ; } publishProgress ( new Integer ( r ) ) ; r ++ ; } audioRecord . stop ( ) ; dos . close ( ) ; } catch ( Throwable t ) { Log . e ( "<STR_LIT>" , "<STR_LIT>" ) ; } return null ; } protected void onProgressUpdate ( Integer ... progress ) { long duration = System . currentTimeMillis ( ) - startRecordTime ; SimpleDateFormat df = new SimpleDateFormat ( "<STR_LIT>" ) ; durationText . setText ( "<STR_LIT>" + df . format ( new Date ( duration ) ) ) ; } protected void onPostExecute ( Void result ) { startRecordingButton . setEnabled ( true ) ; startPlaybackButton . setEnabled ( true ) ; } } } </s>
<s> package org . smallbean . interview . utilities ; import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . File ; import java . io . FileReader ; import java . io . FileWriter ; import java . io . IOException ; import java . text . SimpleDateFormat ; import java . util . Calendar ; import java . util . Date ; import java . util . UUID ; import android . os . Environment ; public class Data { private static Data instance = null ; private static String subject = null ; private String root ( ) { String appPath = Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + "<STR_LIT>" ; File appDir = new File ( appPath ) ; if ( ! appDir . exists ( ) || ! appDir . isDirectory ( ) ) { createFolder ( appPath ) ; } return appPath ; } private String subjectPath ( ) { return root ( ) + "<STR_LIT:/>" + Data . subject ; } private String imageFolderPath ( ) { return subjectPath ( ) + "<STR_LIT>" ; } private String videoFolderPath ( ) { return subjectPath ( ) + "<STR_LIT>" ; } private String audioFolderPath ( ) { return subjectPath ( ) + "<STR_LIT>" ; } private String noteFilePath ( ) { return subjectPath ( ) + "<STR_LIT>" ; } protected Data ( ) { } public static Data getInstance ( ) { if ( instance == null ) { instance = new Data ( ) ; } return instance ; } public void SetSubject ( String subject ) { Data . subject = subject ; } public String [ ] GetSubjects ( ) { File files = new File ( root ( ) ) ; return files . list ( ) ; } public void AddSubject ( String subject ) { Data . subject = subject ; createFolder ( subjectPath ( ) ) ; createFolder ( imageFolderPath ( ) ) ; createFolder ( videoFolderPath ( ) ) ; createFolder ( audioFolderPath ( ) ) ; } public void DeleteSubject ( ) { deleteFolder ( subjectPath ( ) ) ; } public void SetNote ( String note ) { File f = new File ( noteFilePath ( ) ) ; try { if ( ! f . exists ( ) ) { f . createNewFile ( ) ; } FileWriter gpxwriter = new FileWriter ( f ) ; BufferedWriter out = new BufferedWriter ( gpxwriter ) ; out . write ( note ) ; out . close ( ) ; } catch ( IOException e ) { } } public String GetNote ( ) { String note = "<STR_LIT>" ; File f = new File ( noteFilePath ( ) ) ; try { BufferedReader r = new BufferedReader ( new FileReader ( f ) ) ; StringBuilder total = new StringBuilder ( ) ; String line ; while ( ( line = r . readLine ( ) ) != null ) { total . append ( line ) ; } note = total . toString ( ) ; } catch ( Exception e ) { } return note ; } public String GetNewPhotoURL ( ) { return imageFolderPath ( ) + "<STR_LIT>" + GetNewTimeAndUuid ( ) + "<STR_LIT>" ; } public String GetNewAudioURL ( ) { return audioFolderPath ( ) + "<STR_LIT>" + GetNewTimeAndUuid ( ) + "<STR_LIT>" ; } public String GetNewVideoURL ( ) { return videoFolderPath ( ) + "<STR_LIT>" + GetNewTimeAndUuid ( ) + "<STR_LIT>" ; } public String [ ] GetPhotoURLs ( ) { return GetListOfFilesInPath ( imageFolderPath ( ) ) ; } public String [ ] GetAudioURLs ( ) { return GetListOfFilesInPath ( audioFolderPath ( ) ) ; } public String [ ] GetVideoURLs ( ) { return GetListOfFilesInPath ( videoFolderPath ( ) ) ; } public void DeletePhoto ( String photoUrl ) { deleteFile ( photoUrl ) ; } public void DeleteAudio ( String audioUrl ) { deleteFile ( audioUrl ) ; } public void DeleteVideo ( String videoUrl ) { deleteFile ( videoUrl ) ; } private void createFolder ( String folderPath ) { ( new File ( folderPath ) ) . mkdir ( ) ; } private void deleteFolder ( String folderPath ) { File file = new File ( folderPath ) ; if ( file . isDirectory ( ) && file . list ( ) . length > <NUM_LIT:0> ) { deleteDirectory ( file ) ; } else { file . delete ( ) ; } } private boolean deleteDirectory ( File path ) { if ( path . exists ( ) ) { File [ ] files = path . listFiles ( ) ; for ( int i = <NUM_LIT:0> ; i < files . length ; i ++ ) { if ( files [ i ] . isDirectory ( ) ) { deleteDirectory ( files [ i ] ) ; } else { files [ i ] . delete ( ) ; } } } return ( path . delete ( ) ) ; } private void deleteFile ( String filePath ) { File fileToDelete = new File ( filePath ) ; fileToDelete . delete ( ) ; } private String GetNewTimeAndUuid ( ) { UUID uuid = UUID . randomUUID ( ) ; Calendar cal = Calendar . getInstance ( ) ; Date date = cal . getTime ( ) ; SimpleDateFormat df = new SimpleDateFormat ( "<STR_LIT>" ) ; String dateTimeString = df . format ( date ) + "<STR_LIT:_>" + uuid . toString ( ) ; return dateTimeString ; } private String [ ] GetListOfFilesInPath ( String path ) { File folder = new File ( path ) ; String [ ] files = folder . list ( ) ; for ( int i = <NUM_LIT:0> ; i < files . length ; i ++ ) { files [ i ] = path + "<STR_LIT:/>" + files [ i ] ; } return files ; } } </s>
<s> package org . smallbean . interview ; import java . io . File ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . content . ActivityNotFoundException ; import android . content . Context ; import android . content . Intent ; import android . content . res . TypedArray ; import android . graphics . Bitmap ; import android . graphics . BitmapFactory ; import android . net . Uri ; import android . os . Bundle ; import android . view . View ; import android . view . ViewGroup ; import android . widget . AdapterView ; import android . widget . BaseAdapter ; import android . widget . ImageView ; import android . widget . AdapterView . OnItemClickListener ; public class VideoGallery extends Activity { private Data data = Data . getInstance ( ) ; private String [ ] videoFilePaths ; File videoFile ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . video ) ; android . widget . Gallery video_gallery = ( android . widget . Gallery ) findViewById ( R . id . video_gallery ) ; video_gallery . setAdapter ( new VideoAdapter ( this ) ) ; video_gallery . setOnItemClickListener ( new OnItemClickListener ( ) { public void onItemClick ( AdapterView < ? > parent , View v , int position , long id ) { String videoPath = videoFilePaths [ position ] ; Intent intent = new Intent ( android . content . Intent . ACTION_VIEW ) ; Uri data = Uri . parse ( videoPath ) ; intent . setDataAndType ( data , "<STR_LIT>" ) ; try { startActivity ( intent ) ; } catch ( ActivityNotFoundException e ) { e . printStackTrace ( ) ; } } } ) ; } public void recordVideo ( View view ) { Intent intent = new Intent ( this , VideoCapture . class ) ; startActivityForResult ( intent , <NUM_LIT:0> ) ; } public class VideoAdapter extends BaseAdapter { int mGalleryItemBackground ; private Context mContext ; private void getVideoPaths ( ) { String [ ] videoFiles = data . GetVideoURLs ( ) ; videoFilePaths = new String [ videoFiles . length ] ; for ( int i = <NUM_LIT:0> ; i < videoFiles . length ; i ++ ) { videoFilePaths [ i ] = videoFiles [ i ] ; } } public VideoAdapter ( Context c ) { getVideoPaths ( ) ; mContext = c ; TypedArray a = obtainStyledAttributes ( R . styleable . Gallery ) ; mGalleryItemBackground = a . getResourceId ( R . styleable . Gallery_android_galleryItemBackground , <NUM_LIT:0> ) ; a . recycle ( ) ; } public int getCount ( ) { return videoFilePaths . length ; } public Object getItem ( int position ) { return position ; } public long getItemId ( int position ) { return position ; } @ Override public View getView ( int position , View convertView , ViewGroup parent ) { ImageView videoThumbNail = new ImageView ( mContext ) ; Bitmap mBitmap = BitmapFactory . decodeResource ( getResources ( ) , R . drawable . sub_vid_wotext ) ; videoThumbNail . setLayoutParams ( new android . widget . Gallery . LayoutParams ( <NUM_LIT> , <NUM_LIT> ) ) ; videoThumbNail . setBackgroundResource ( mGalleryItemBackground ) ; videoThumbNail . setImageBitmap ( mBitmap ) ; return videoThumbNail ; } } } </s>
<s> package org . smallbean . interview ; import java . io . File ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . content . Context ; import android . content . Intent ; import android . content . res . TypedArray ; import android . graphics . Bitmap ; import android . graphics . BitmapFactory ; import android . graphics . drawable . BitmapDrawable ; import android . net . Uri ; import android . os . Bundle ; import android . view . View ; import android . view . ViewGroup ; import android . widget . AdapterView ; import android . widget . BaseAdapter ; import android . widget . ImageView ; import android . widget . Toast ; import android . widget . AdapterView . OnItemClickListener ; public class CameraSurface extends Activity { private int CAMERA_RESULT = <NUM_LIT:1> ; private Data data = Data . getInstance ( ) ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . camera ) ; android . widget . Gallery camera_gallery = ( android . widget . Gallery ) findViewById ( R . id . photo_gallery ) ; camera_gallery . setAdapter ( new ImageAdapter ( this ) ) ; camera_gallery . setOnItemClickListener ( new OnItemClickListener ( ) { public void onItemClick ( AdapterView < ? > parent , View v , int position , long id ) { Toast . makeText ( CameraSurface . this , "<STR_LIT>" + position , Toast . LENGTH_SHORT ) . show ( ) ; } } ) ; } public void goHome ( View view ) { } public void finish ( View view ) { this . finish ( ) ; } public void takePhoto ( View view ) { Uri imageFileUri = Uri . fromFile ( new File ( data . GetNewPhotoURL ( ) ) ) ; Intent intent = new Intent ( android . provider . MediaStore . ACTION_IMAGE_CAPTURE ) ; intent . putExtra ( android . provider . MediaStore . EXTRA_OUTPUT , imageFileUri ) ; startActivityForResult ( intent , this . CAMERA_RESULT ) ; } protected void onActivityResult ( int requestCode , int resultCode , Intent image ) { super . onActivityResult ( requestCode , resultCode , image ) ; if ( requestCode == this . CAMERA_RESULT ) { android . widget . Gallery camera_gallery = ( android . widget . Gallery ) findViewById ( R . id . photo_gallery ) ; camera_gallery . setAdapter ( new ImageAdapter ( this ) ) ; camera_gallery . setOnItemClickListener ( new OnItemClickListener ( ) { public void onItemClick ( AdapterView < ? > parent , View v , int position , long id ) { Toast . makeText ( CameraSurface . this , "<STR_LIT>" + position , Toast . LENGTH_SHORT ) . show ( ) ; } } ) ; } } public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground ; private String [ ] imagePaths ; private Context mContext ; public ImageAdapter ( Context c ) { imagePaths = data . GetPhotoURLs ( ) ; mContext = c ; TypedArray a = obtainStyledAttributes ( R . styleable . Gallery ) ; mGalleryItemBackground = a . getResourceId ( R . styleable . Gallery_android_galleryItemBackground , <NUM_LIT:0> ) ; a . recycle ( ) ; } public int getCount ( ) { return imagePaths . length ; } public Object getItem ( int position ) { return position ; } public long getItemId ( int position ) { return position ; } @ Override public View getView ( int position , View convertView , ViewGroup parent ) { ImageView i = new ImageView ( mContext ) ; i . setImageDrawable ( downSampleImage ( imagePaths [ position ] ) ) ; i . setLayoutParams ( new android . widget . Gallery . LayoutParams ( <NUM_LIT> , <NUM_LIT> ) ) ; i . setScaleType ( ImageView . ScaleType . FIT_XY ) ; i . setBackgroundResource ( mGalleryItemBackground ) ; return i ; } private BitmapDrawable downSampleImage ( String imgPath ) { BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inSampleSize = <NUM_LIT:2> ; Bitmap bmp = BitmapFactory . decodeFile ( imgPath , options ) ; BitmapDrawable rbmd = new BitmapDrawable ( bmp ) ; return rbmd ; } } } </s>
<s> package org . smallbean . interview ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . content . Intent ; import android . os . Bundle ; import android . view . View ; import android . widget . AdapterView ; import android . widget . AdapterView . OnItemClickListener ; import android . widget . ArrayAdapter ; import android . widget . EditText ; import android . widget . ListView ; import android . widget . TextView ; import android . widget . ViewFlipper ; public class Interview extends Activity { private static final int TAKE_PHOTO = <NUM_LIT:0> ; private static final int RECORD_AUDIO = <NUM_LIT:1> ; private static final int RECORD_VIDEO = <NUM_LIT:2> ; private static final int SHOW_GALLERY = <NUM_LIT:3> ; private static final int TAKE_NOTE = <NUM_LIT:4> ; private static final int SUBJECT_DASHBOARD_VIEW = <NUM_LIT:0> ; private static final int SUBJECT_CREATE_VIEW = <NUM_LIT:1> ; private static final int SUBJECT_LIST_VIEW = <NUM_LIT:2> ; private static final int SUBJECT_DETAILS_VIEW = <NUM_LIT:3> ; private ViewFlipper flipper ; private ListView subjectListView ; private Data data = Data . getInstance ( ) ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . dashboard ) ; this . flipper = ( ViewFlipper ) findViewById ( R . id . subject_views ) ; this . subjectListView = ( ListView ) findViewById ( R . id . subject_list_view ) ; this . populateListView ( this . subjectListView ) ; subjectListView . setOnItemClickListener ( new OnItemClickListener ( ) { public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { String subjectName = ( String ) ( ( TextView ) view ) . getText ( ) ; data . SetSubject ( subjectName ) ; TextView subjectview = ( TextView ) findViewById ( R . id . subjectTitle ) ; subjectview . setText ( subjectName ) ; flipper . setDisplayedChild ( Interview . SUBJECT_DETAILS_VIEW ) ; } } ) ; } private void populateListView ( ListView subjectListView ) { String [ ] subjects = this . data . GetSubjects ( ) ; if ( subjects == null ) return ; ArrayAdapter < String > subjectListAdapter = new ArrayAdapter < String > ( this , R . layout . subject_list_item_view , subjects ) ; subjectListView . setAdapter ( subjectListAdapter ) ; } public void createSubject ( View view ) { EditText newSubjectField = ( EditText ) findViewById ( R . id . subject_create_name ) ; String currentSubjectName = newSubjectField . getText ( ) . toString ( ) ; data . AddSubject ( currentSubjectName ) ; TextView subjectview = ( TextView ) findViewById ( R . id . subjectTitle ) ; subjectview . setText ( currentSubjectName ) ; data . SetSubject ( currentSubjectName ) ; this . populateListView ( this . subjectListView ) ; flipper . setDisplayedChild ( Interview . SUBJECT_DETAILS_VIEW ) ; } public void newSubject ( View view ) { flipper . setDisplayedChild ( Interview . SUBJECT_CREATE_VIEW ) ; } public void listSubjects ( View view ) { flipper . setDisplayedChild ( Interview . SUBJECT_LIST_VIEW ) ; } public void takePhoto ( View view ) { Intent intent = new Intent ( this , CameraSurface . class ) ; startActivityForResult ( intent , TAKE_PHOTO ) ; } public void takeNote ( View view ) { Intent intent = new Intent ( this , Note . class ) ; startActivityForResult ( intent , TAKE_NOTE ) ; } public void recordAudio ( View view ) { Intent intent = new Intent ( this , Audio . class ) ; startActivityForResult ( intent , RECORD_AUDIO ) ; } public void recordVideo ( View view ) { Intent intent = new Intent ( this , VideoGallery . class ) ; startActivityForResult ( intent , RECORD_VIDEO ) ; } public void finish ( View view ) { flipper . setDisplayedChild ( Interview . SUBJECT_LIST_VIEW ) ; } public void goHome ( View view ) { flipper . setDisplayedChild ( Interview . SUBJECT_DASHBOARD_VIEW ) ; } @ Override protected void onActivityResult ( int requestCode , int resultCode , Intent intent ) { super . onActivityResult ( requestCode , resultCode , intent ) ; switch ( requestCode ) { case TAKE_PHOTO : break ; case RECORD_AUDIO : break ; case RECORD_VIDEO : break ; } } } </s>
<s> package org . smallbean . interview ; import org . smallbean . interview . utilities . Data ; import android . app . Activity ; import android . os . Bundle ; import android . view . View ; import android . widget . Button ; import android . widget . EditText ; import android . widget . Toast ; public class Note extends Activity { private Data data = Data . getInstance ( ) ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . notes ) ; EditText note = ( EditText ) findViewById ( R . id . note_text ) ; note . setText ( data . GetNote ( ) , EditText . BufferType . EDITABLE ) ; Button saveNoteButton = ( Button ) findViewById ( R . id . save ) ; saveNoteButton . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View view ) { EditText note = ( EditText ) findViewById ( R . id . note_text ) ; data . SetNote ( note . getText ( ) . toString ( ) ) ; Toast . makeText ( view . getContext ( ) , "<STR_LIT>" , Toast . LENGTH_SHORT ) . show ( ) ; } } ) ; } } </s>
<s> import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Set ; public class Solution { public static void main ( String [ ] args ) { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = null ; int numTests = <NUM_LIT:0> ; try { line = stdin . readLine ( ) ; numTests = Integer . parseInt ( line ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } for ( int i = <NUM_LIT:0> ; i < numTests ; i ++ ) { try { line = stdin . readLine ( ) ; int maxN = Integer . parseInt ( line ) ; line = stdin . readLine ( ) ; String numberStrs [ ] = line . split ( "<STR_LIT:U+0020>" ) ; int numbers [ ] = new int [ numberStrs . length ] ; for ( int j = <NUM_LIT:0> ; j < numberStrs . length ; j ++ ) { numbers [ j ] = Integer . parseInt ( numberStrs [ j ] ) ; } if ( doesAliceToPlayWin ( numbers , maxN ) ) { System . out . println ( "<STR_LIT>" ) ; } else { System . out . println ( "<STR_LIT>" ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } public static boolean doesAliceToPlayWin ( int [ ] numbers , int maxN ) { return aliceWins ( numbers ) ; } private static boolean aliceWins ( int [ ] numbers ) { if ( numbers . length == _cacheLine ) { return isWinningPermutation ( numbers ) ; } if ( isSorted ( numbers ) ) { return false ; } int l = numbers . length ; int [ ] newNums = new int [ l - <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:0> ; i < l ; i ++ ) { copyNums ( newNums , numbers , i ) ; if ( ! bobWins ( newNums ) ) { return true ; } } return false ; } private static boolean isWinningPermutation ( int [ ] numbers ) { int [ ] sNums = numbers . clone ( ) ; Arrays . sort ( sNums ) ; for ( int i = <NUM_LIT:0> ; i < numbers . length ; i ++ ) { numbers [ i ] = Arrays . binarySearch ( sNums , numbers [ i ] ) + <NUM_LIT:1> ; } return winningCache . contains ( stringify ( numbers ) ) ; } private static String stringify ( int [ ] numbers ) { StringBuilder sb = new StringBuilder ( ) ; for ( int y : numbers ) { sb . append ( y ) ; } return sb . toString ( ) ; } private static boolean bobWins ( int [ ] numbers ) { if ( ( numbers . length == _cacheLine ) || ( numbers . length == ( _cacheLine + <NUM_LIT:1> ) ) || ( numbers . length == ( _cacheLine + <NUM_LIT:2> ) ) ) { return isWinningPermutation ( numbers ) ; } if ( isSorted ( numbers ) ) { return false ; } int l = numbers . length ; int [ ] newNums = new int [ l - <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:0> ; i < l ; i ++ ) { copyNums ( newNums , numbers , i ) ; if ( ! aliceWins ( newNums ) ) { return true ; } } return false ; } private static void copyNums ( int [ ] newNums , int [ ] numbers , int i ) { int curr = <NUM_LIT:0> ; for ( int k = <NUM_LIT:0> ; k < i ; k ++ ) { newNums [ curr ] = numbers [ k ] ; curr += <NUM_LIT:1> ; } for ( int k = i + <NUM_LIT:1> ; k < numbers . length ; k ++ ) { newNums [ curr ] = numbers [ k ] ; curr += <NUM_LIT:1> ; } } private static boolean isSorted ( int [ ] numbers ) { for ( int i = <NUM_LIT:0> ; i < numbers . length - <NUM_LIT:1> ; i ++ ) { if ( numbers [ i ] > numbers [ i + <NUM_LIT:1> ] ) { return false ; } } return true ; } private static int _cacheLine = <NUM_LIT:5> ; @ SuppressWarnings ( "<STR_LIT:serial>" ) private static Set < String > winningCache = new HashSet < String > ( ) { { add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; add ( "<STR_LIT>" ) ; } } ; } </s>
<s> package com . facebook . android ; public final class R { public static final class array { public static final int encryption = <NUM_LIT> ; public static final int encryption_values = <NUM_LIT> ; public static final int messages = <NUM_LIT> ; public static final int messages_values = <NUM_LIT> ; public static final int poly_method = <NUM_LIT> ; public static final int poly_method_values = <NUM_LIT> ; } public static final class attr { } public static final class dimen { public static final int padding_large = <NUM_LIT> ; public static final int padding_medium = <NUM_LIT> ; public static final int padding_small = <NUM_LIT> ; } public static final class drawable { public static final int black = <NUM_LIT> ; public static final int close = <NUM_LIT> ; public static final int facebook_icon = <NUM_LIT> ; public static final int happy = <NUM_LIT> ; public static final int ic_action_search = <NUM_LIT> ; public static final int ic_launcher = <NUM_LIT> ; public static final int query = <NUM_LIT> ; public static final int sad = <NUM_LIT> ; public static final int waiting = <NUM_LIT> ; public static final int white = <NUM_LIT> ; } public static final class id { public static final int bit_strength = <NUM_LIT> ; public static final int bt_query = <NUM_LIT> ; public static final int certainty = <NUM_LIT> ; public static final int enc_test = <NUM_LIT> ; public static final int fb_chat = <NUM_LIT> ; public static final int gen_message_butt = <NUM_LIT> ; public static final int length = <NUM_LIT> ; public static final int ll = <NUM_LIT> ; public static final int mainListView = <NUM_LIT> ; public static final int message = <NUM_LIT> ; public static final int names = <NUM_LIT> ; public static final int other_user = <NUM_LIT> ; public static final int output = <NUM_LIT> ; public static final int query = <NUM_LIT> ; public static final int rec = <NUM_LIT> ; public static final int rowTextView = <NUM_LIT> ; public static final int send_message_butt = <NUM_LIT> ; public static final int settings = <NUM_LIT> ; public static final int test_encryption = <NUM_LIT> ; public static final int test_message = <NUM_LIT> ; public static final int text_view = <NUM_LIT> ; public static final int waiting = <NUM_LIT> ; } public static final class layout { public static final int activity_main = <NUM_LIT> ; public static final int activity_message_test = <NUM_LIT> ; public static final int activity_names = <NUM_LIT> ; public static final int activity_processed_queries = <NUM_LIT> ; public static final int activity_test = <NUM_LIT> ; public static final int activity_wait = <NUM_LIT> ; public static final int simplerow = <NUM_LIT> ; public static final int smallfont = <NUM_LIT> ; } public static final class menu { public static final int activity_main = <NUM_LIT> ; } public static final class string { public static final int app_name = <NUM_LIT> ; public static final int bit_strength = <NUM_LIT> ; public static final int butt_query = <NUM_LIT> ; public static final int certainty = <NUM_LIT> ; public static final int hello = <NUM_LIT> ; public static final int hello_world = <NUM_LIT> ; public static final int menu_settings = <NUM_LIT> ; public static final int mess = <NUM_LIT> ; public static final int message = <NUM_LIT> ; public static final int names = <NUM_LIT> ; public static final int other_user_hint = <NUM_LIT> ; public static final int query = <NUM_LIT> ; public static final int request = <NUM_LIT> ; public static final int s10 = <NUM_LIT> ; public static final int settings = <NUM_LIT> ; public static final int test = <NUM_LIT> ; public static final int test_enc = <NUM_LIT> ; public static final int test_waiting = <NUM_LIT> ; public static final int title_activity_main = <NUM_LIT> ; public static final int upload = <NUM_LIT> ; public static final int wait = <NUM_LIT> ; public static final int waiting = <NUM_LIT> ; } public static final class style { public static final int AppTheme = <NUM_LIT> ; public static final int preferences = <NUM_LIT> ; } public static final class xml { public static final int preferences = <NUM_LIT> ; } } </s>
<s> package net . ednovak . nearby ; public final class R { public static final class array { public static final int encryption = <NUM_LIT> ; public static final int encryption_values = <NUM_LIT> ; public static final int messages = <NUM_LIT> ; public static final int messages_values = <NUM_LIT> ; public static final int poly_method = <NUM_LIT> ; public static final int poly_method_values = <NUM_LIT> ; } public static final class attr { } public static final class dimen { public static final int padding_large = <NUM_LIT> ; public static final int padding_medium = <NUM_LIT> ; public static final int padding_small = <NUM_LIT> ; } public static final class drawable { public static final int black = <NUM_LIT> ; public static final int close = <NUM_LIT> ; public static final int facebook_icon = <NUM_LIT> ; public static final int happy = <NUM_LIT> ; public static final int ic_action_search = <NUM_LIT> ; public static final int ic_launcher = <NUM_LIT> ; public static final int query = <NUM_LIT> ; public static final int sad = <NUM_LIT> ; public static final int waiting = <NUM_LIT> ; public static final int white = <NUM_LIT> ; } public static final class id { public static final int bit_strength = <NUM_LIT> ; public static final int bt_query = <NUM_LIT> ; public static final int certainty = <NUM_LIT> ; public static final int enc_test = <NUM_LIT> ; public static final int fb_chat = <NUM_LIT> ; public static final int gen_message_butt = <NUM_LIT> ; public static final int length = <NUM_LIT> ; public static final int ll = <NUM_LIT> ; public static final int mainListView = <NUM_LIT> ; public static final int message = <NUM_LIT> ; public static final int names = <NUM_LIT> ; public static final int other_user = <NUM_LIT> ; public static final int output = <NUM_LIT> ; public static final int query = <NUM_LIT> ; public static final int rec = <NUM_LIT> ; public static final int rowTextView = <NUM_LIT> ; public static final int send_message_butt = <NUM_LIT> ; public static final int settings = <NUM_LIT> ; public static final int test_encryption = <NUM_LIT> ; public static final int test_message = <NUM_LIT> ; public static final int text_view = <NUM_LIT> ; public static final int waiting = <NUM_LIT> ; } public static final class layout { public static final int activity_main = <NUM_LIT> ; public static final int activity_message_test = <NUM_LIT> ; public static final int activity_names = <NUM_LIT> ; public static final int activity_processed_queries = <NUM_LIT> ; public static final int activity_test = <NUM_LIT> ; public static final int activity_wait = <NUM_LIT> ; public static final int simplerow = <NUM_LIT> ; public static final int smallfont = <NUM_LIT> ; } public static final class menu { public static final int activity_main = <NUM_LIT> ; } public static final class string { public static final int app_name = <NUM_LIT> ; public static final int bit_strength = <NUM_LIT> ; public static final int butt_query = <NUM_LIT> ; public static final int certainty = <NUM_LIT> ; public static final int hello = <NUM_LIT> ; public static final int hello_world = <NUM_LIT> ; public static final int menu_settings = <NUM_LIT> ; public static final int mess = <NUM_LIT> ; public static final int message = <NUM_LIT> ; public static final int names = <NUM_LIT> ; public static final int other_user_hint = <NUM_LIT> ; public static final int query = <NUM_LIT> ; public static final int request = <NUM_LIT> ; public static final int s10 = <NUM_LIT> ; public static final int settings = <NUM_LIT> ; public static final int test = <NUM_LIT> ; public static final int test_enc = <NUM_LIT> ; public static final int test_waiting = <NUM_LIT> ; public static final int title_activity_main = <NUM_LIT> ; public static final int upload = <NUM_LIT> ; public static final int wait = <NUM_LIT> ; public static final int waiting = <NUM_LIT> ; } public static final class style { public static final int AppTheme = <NUM_LIT> ; public static final int preferences = <NUM_LIT> ; } public static final class xml { public static final int preferences = <NUM_LIT> ; } } </s>
<s> package net . ednovak . nearby ; public final class BuildConfig { public final static boolean DEBUG = true ; } </s>
<s> package net . ednovak . nearby ; public class tree { public int value ; public char [ ] path ; public String special ; public tree left ; public tree right ; private tree parent ; public String treeType ; public int height ; public String type ; private int magic ; public tree ( int newValue , char [ ] newPath , tree newLeft , tree newRight , int nHeight , String nType ) { value = newValue ; path = newPath ; special = null ; left = newLeft ; right = newRight ; height = nHeight ; type = nType ; if ( type . equals ( "<STR_LIT>" ) ) { magic = <NUM_LIT> ; } else if ( type . equals ( "<STR_LIT>" ) ) { magic = <NUM_LIT> ; } } public void setType ( String type ) { if ( type . equals ( "<STR_LIT>" ) ) { magic = <NUM_LIT> ; } else if ( type . equals ( "<STR_LIT>" ) ) { magic = <NUM_LIT> ; } } public tree rightLeaf ( ) { tree cur = this ; while ( cur . right != null ) { cur = cur . right ; } if ( cur . value > magic ) { return null ; } return cur ; } public tree leftLeaf ( ) { tree cur = this ; while ( cur . left != null ) { cur = cur . left ; } if ( cur . value > magic ) { return null ; } return cur ; } public tree createParent ( ) { tree parent ; if ( path . length == <NUM_LIT:0> ) { path = new char [ <NUM_LIT:1> ] ; path [ <NUM_LIT:0> ] = '<CHAR_LIT:0>' ; } char [ ] nPath = new char [ path . length - <NUM_LIT:1> ] ; for ( int j = <NUM_LIT:0> ; j < nPath . length ; j ++ ) { nPath [ j ] = path [ j ] ; } if ( this . upRightward ( ) ) { int nValue = value + magic ; parent = new tree ( nValue , nPath , this , null , height + <NUM_LIT:1> , type ) ; } else { int nValue = value + ( magic - ( int ) ( Math . pow ( <NUM_LIT> , ( double ) ( height ) ) ) ) ; parent = new tree ( nValue , nPath , null , this , height + <NUM_LIT:1> , type ) ; } return parent ; } public tree getParent ( ) { return parent ; } public void setParent ( tree t ) { parent = t ; } @ Override public String toString ( ) { String s = "<STR_LIT>" + value + "<STR_LIT>" + new String ( path ) ; if ( special != null ) { s += "<STR_LIT>" + special ; } if ( left != null ) { s += "<STR_LIT>" + left . value ; } if ( right != null ) { s += "<STR_LIT>" + right . value ; } if ( parent != null ) { s += "<STR_LIT>" + parent . value ; } return s ; } public int count ( ) { int sum = <NUM_LIT:0> ; treeQueue top = new treeQueue ( ) ; treeQueue bottom = new treeQueue ( ) ; top . push ( this ) ; while ( top . length != <NUM_LIT:0> ) { sum = sum + top . length ; for ( int i = <NUM_LIT:0> ; i < top . length ; i ++ ) { tree cur = top . peek ( i ) . left ; if ( cur != null ) { bottom . push ( cur ) ; } cur = top . peek ( i ) . right ; if ( cur != null ) { bottom . push ( cur ) ; } } top = bottom ; bottom = new treeQueue ( ) ; } return sum ; } public void setNullChild ( tree t ) { if ( left == null ) { left = t ; } else if ( right == null ) { right = t ; } } public boolean upRightward ( ) { return path [ path . length - <NUM_LIT:1> ] == '<CHAR_LIT:0>' ; } } </s>
<s> package net . ednovak . nearby ; import android . app . Activity ; import android . content . BroadcastReceiver ; import android . content . ComponentName ; import android . content . Context ; import android . content . Intent ; import android . content . IntentFilter ; import android . content . ServiceConnection ; import android . content . SharedPreferences ; import android . location . Location ; import android . location . LocationManager ; import android . os . Bundle ; import android . os . IBinder ; import android . preference . PreferenceManager ; import android . util . Log ; import android . view . Menu ; import android . view . MenuInflater ; import android . view . MenuItem ; import android . view . View ; import android . widget . EditText ; import android . widget . Toast ; import android . widget . ToggleButton ; public class MainActivity extends Activity { public final static String EXTRA_MESSAGE = "<STR_LIT>" ; private lListener myListener = new lListener ( ) ; private LocationManager lManager ; private logInReceiver rec ; private ToggleButton chatButton ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_main ) ; lManager = ( LocationManager ) this . getSystemService ( Context . LOCATION_SERVICE ) ; lManager . requestLocationUpdates ( LocationManager . GPS_PROVIDER , <NUM_LIT:1000> , <NUM_LIT> , myListener ) ; try { lManager . requestLocationUpdates ( LocationManager . NETWORK_PROVIDER , <NUM_LIT:1000> , <NUM_LIT> , myListener ) ; } catch ( Exception e ) { } chatButton = ( ToggleButton ) findViewById ( R . id . fb_chat ) ; } protected void onActivityResult ( int requestCode , int resultCode , Intent intent ) { switch ( requestCode ) { case <NUM_LIT:1> : if ( resultCode == RESULT_OK ) { String name = intent . getStringExtra ( "<STR_LIT>" ) ; EditText rec = ( EditText ) findViewById ( R . id . other_user ) ; rec . setText ( name ) ; break ; } } } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { MenuInflater inflater = getMenuInflater ( ) ; inflater . inflate ( R . menu . activity_main , menu ) ; return true ; } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" + item . toString ( ) ) ; switch ( item . getItemId ( ) ) { case R . id . settings : startActivity ( new Intent ( this , settings . class ) ) ; return true ; case R . id . names : if ( xmppService . in ) { startActivityForResult ( new Intent ( this , names . class ) , <NUM_LIT:1> ) ; return true ; } else { Toast . makeText ( this , "<STR_LIT>" , Toast . LENGTH_SHORT ) . show ( ) ; return false ; } case R . id . test_encryption : startActivity ( new Intent ( this , paillierTest . class ) ) ; return true ; case R . id . test_message : if ( xmppService . in ) { startActivity ( new Intent ( this , messageTest . class ) ) ; return true ; } else { Toast . makeText ( this , "<STR_LIT>" , Toast . LENGTH_SHORT ) . show ( ) ; return false ; } default : return super . onOptionsItemSelected ( item ) ; } } @ Override public void onResume ( ) { super . onResume ( ) ; if ( rec == null ) { IntentFilter logInFilter ; logInFilter = new IntentFilter ( xmppService . LOGIN_UPDATE ) ; rec = new logInReceiver ( ) ; registerReceiver ( rec , logInFilter ) ; } } @ Override public void onDestroy ( ) { super . onDestroy ( ) ; if ( xmppService . in ) { unbindService ( mConnection ) ; } try { unregisterReceiver ( rec ) ; } catch ( IllegalArgumentException e ) { } } public void query ( View view ) { Intent intent = new Intent ( this , displayMessageAct . class ) ; shareSingleton share = shareSingleton . getInstance ( ) ; share . start = System . currentTimeMillis ( ) ; EditText otherUser = ( EditText ) findViewById ( R . id . other_user ) ; String rec = otherUser . getText ( ) . toString ( ) ; share . rec = rec ; Context context = getApplicationContext ( ) ; SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( this ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + prefs . contains ( "<STR_LIT>" ) ) ; boolean it = prefs . getBoolean ( "<STR_LIT>" , false ) ; if ( it ) { myListener . plugFake ( context ) ; } if ( rec . length ( ) != <NUM_LIT:0> && rec != null ) { if ( ! myListener . listening ( ) ) { lManager . removeUpdates ( myListener ) ; protocol p = new protocol ( ) ; Location l = p . locSimple ( this ) ; share . lon = l . getLongitude ( ) ; share . lat = l . getLatitude ( ) ; intent . putExtra ( "<STR_LIT>" , rec ) ; share . start = System . currentTimeMillis ( ) ; startActivity ( intent ) ; } else { Toast . makeText ( context , "<STR_LIT>" , Toast . LENGTH_SHORT ) . show ( ) ; } } else { Toast . makeText ( context , "<STR_LIT>" , Toast . LENGTH_SHORT ) . show ( ) ; } } private ServiceConnection mConnection = new ServiceConnection ( ) { @ Override public void onServiceConnected ( ComponentName className , IBinder service ) { } @ Override public void onServiceDisconnected ( ComponentName name ) { chatButton . setChecked ( false ) ; } } ; public void fbChatConnect ( View view ) { if ( xmppService . in ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; unbindService ( mConnection ) ; stopService ( new Intent ( this , xmppService . class ) ) ; chatButton . setChecked ( false ) ; } else { chatButton . setChecked ( false ) ; chatButton . setText ( "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; Intent bindIntent = new Intent ( this , xmppService . class ) ; SharedPreferences sp = PreferenceManager . getDefaultSharedPreferences ( this ) ; String user = sp . getString ( "<STR_LIT>" , "<STR_LIT>" ) ; String pass = sp . getString ( "<STR_LIT>" , "<STR_LIT>" ) ; bindIntent . putExtra ( "<STR_LIT:user>" , user ) ; bindIntent . putExtra ( "<STR_LIT>" , pass ) ; bindService ( bindIntent , mConnection , Context . BIND_AUTO_CREATE ) ; } } public class logInReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { boolean light = intent . getBooleanExtra ( "<STR_LIT>" , false ) ; chatButton . setChecked ( light ) ; } } } </s>
<s> package net . ednovak . nearby ; import android . os . Bundle ; import android . preference . PreferenceActivity ; public class settings extends PreferenceActivity { public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; addPreferencesFromResource ( R . xml . preferences ) ; } } </s>
<s> package net . ednovak . nearby ; import java . util . ArrayList ; import java . util . Collection ; import org . jivesoftware . smack . Roster ; import org . jivesoftware . smack . RosterEntry ; import android . app . Activity ; import android . content . ComponentName ; import android . content . Context ; import android . content . Intent ; import android . content . ServiceConnection ; import android . content . SharedPreferences ; import android . os . Bundle ; import android . os . IBinder ; import android . preference . PreferenceManager ; import android . util . Log ; import android . view . View ; import android . widget . AdapterView ; import android . widget . AdapterView . OnItemClickListener ; import android . widget . ArrayAdapter ; import android . widget . ListView ; import android . widget . TextView ; public class names extends Activity { private ServiceConnection mConnection = new ServiceConnection ( ) { @ Override public void onServiceConnected ( ComponentName className , IBinder service ) { fillList ( xmppService . getRoster ( ) ) ; } @ Override public void onServiceDisconnected ( ComponentName name ) { } } ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_names ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; Intent bindIntent = new Intent ( this , xmppService . class ) ; SharedPreferences sp = PreferenceManager . getDefaultSharedPreferences ( this ) ; String user = sp . getString ( "<STR_LIT>" , "<STR_LIT>" ) ; String pass = sp . getString ( "<STR_LIT>" , "<STR_LIT>" ) ; bindIntent . putExtra ( "<STR_LIT:user>" , user ) ; bindIntent . putExtra ( "<STR_LIT>" , pass ) ; bindService ( bindIntent , mConnection , Context . BIND_AUTO_CREATE ) ; } public void onDestroy ( ) { super . onDestroy ( ) ; unbindService ( mConnection ) ; } public void fillList ( Roster roster ) { ListView main = ( ListView ) findViewById ( R . id . mainListView ) ; Collection < RosterEntry > entries = roster . getEntries ( ) ; ArrayList < String > entriesList = new ArrayList < String > ( ) ; for ( RosterEntry entry : entries ) { entriesList . add ( entry . getName ( ) ) ; } ArrayAdapter < String > listAdapter = new ArrayAdapter < String > ( this , R . layout . simplerow , entriesList ) ; main . setAdapter ( listAdapter ) ; main . setOnItemClickListener ( new OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { String s = ( ( TextView ) view ) . getText ( ) . toString ( ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + s ) ; Intent rIntent = new Intent ( ) ; rIntent . putExtra ( "<STR_LIT>" , s ) ; setResult ( RESULT_OK , rIntent ) ; finish ( ) ; } } ) ; } } </s>
<s> package net . ednovak . nearby ; import java . math . BigInteger ; import java . util . Arrays ; import java . util . Collections ; import java . util . Random ; import android . app . Notification ; import android . app . NotificationManager ; import android . app . PendingIntent ; import android . content . Context ; import android . content . Intent ; import android . content . SharedPreferences ; import android . location . Location ; import android . location . LocationManager ; import android . preference . PreferenceManager ; import android . util . Log ; public class protocol { tree user ; public protocol ( ) { } public BigInteger homoAdd ( BigInteger em1 , BigInteger em2 , BigInteger n ) { return ( em1 . multiply ( em2 ) ) . mod ( n . multiply ( n ) ) ; } public BigInteger homoMult ( BigInteger em1 , BigInteger m2 , BigInteger n ) { return em1 . modPow ( m2 , n . multiply ( n ) ) ; } public BigInteger homoExpo ( BigInteger em1 , BigInteger m1 , BigInteger m2 , BigInteger n ) { BigInteger cur = homoMult ( em1 , m1 , n ) ; int intM2 = m2 . intValue ( ) - <NUM_LIT:2> ; while ( intM2 > <NUM_LIT:0> ) { cur = homoMult ( cur , m1 , n ) ; intM2 -- ; } return cur ; } public BigInteger homoEval ( BigInteger b , BigInteger [ ] poly , BigInteger n ) { BigInteger [ ] terms = new BigInteger [ poly . length ] ; for ( int i = <NUM_LIT:0> ; i < poly . length ; i ++ ) { BigInteger tmp = b . pow ( i ) ; terms [ i ] = homoMult ( poly [ i ] , tmp , n ) ; } BigInteger sum = new BigInteger ( String . valueOf ( terms [ <NUM_LIT:0> ] ) ) ; for ( int i = <NUM_LIT:1> ; i < terms . length ; i ++ ) { sum = homoAdd ( sum , terms [ i ] , n ) ; } return sum ; } public treeQueue genLeaves ( int left , int right , int x , String type ) { System . out . println ( "<STR_LIT>" ) ; treeQueue leaves = new treeQueue ( ) ; int cur = left ; while ( cur <= right ) { String mapString = new StringBuffer ( Integer . toBinaryString ( cur ) ) . toString ( ) ; leaves . push ( new tree ( cur , mapString . toCharArray ( ) , null , null , <NUM_LIT:0> , type ) ) ; if ( cur == x ) { leaves . peek ( - <NUM_LIT:1> ) . special = "<STR_LIT>" ; user = leaves . peek ( - <NUM_LIT:1> ) ; } cur ++ ; } return leaves ; } public int latitudeToLeaf ( double latitude ) { if ( latitude < - <NUM_LIT> || latitude > <NUM_LIT> ) { System . out . println ( "<STR_LIT>" + latitude ) ; System . exit ( <NUM_LIT> ) ; } latitude = latitude + <NUM_LIT> ; return ( int ) Math . round ( ( latitude / <NUM_LIT> ) ) ; } public int longitudeToLeaf ( double longitude ) { if ( longitude < - <NUM_LIT> || longitude > <NUM_LIT> ) { System . out . println ( "<STR_LIT>" + longitude ) ; System . exit ( <NUM_LIT> ) ; } longitude = longitude + <NUM_LIT> ; return ( int ) Math . round ( ( longitude / <NUM_LIT> ) ) ; } public double findLat ( double orig_lon_1 , double orig_lat_1 , int distance ) { double d = ( double ) distance / <NUM_LIT:1000> ; double dist = d / <NUM_LIT> ; double brng = <NUM_LIT:0> * ( Math . PI / <NUM_LIT> ) ; double lat1 = orig_lat_1 * ( Math . PI / <NUM_LIT> ) ; double lat2 = Math . asin ( Math . sin ( lat1 ) * Math . cos ( dist ) + Math . cos ( lat1 ) * Math . sin ( dist ) * Math . cos ( brng ) ) ; lat2 = lat2 * ( <NUM_LIT> / Math . PI ) ; return lat2 ; } public double findLong ( double orig_lon_1 , double orig_lat_1 , int distance ) { double d = ( double ) distance / <NUM_LIT:1000> ; double dist = d / <NUM_LIT> ; double brng = <NUM_LIT> * ( Math . PI / <NUM_LIT> ) ; double lat1 = orig_lat_1 * ( Math . PI / <NUM_LIT> ) ; double lon1 = orig_lon_1 * ( Math . PI / <NUM_LIT> ) ; double lat2 = Math . asin ( Math . sin ( lat1 ) * Math . cos ( dist ) + Math . cos ( lat1 ) * Math . sin ( dist ) * Math . cos ( brng ) ) ; double lon2 = lon1 + Math . atan2 ( Math . sin ( brng ) * Math . sin ( dist ) * Math . cos ( lat1 ) , Math . cos ( dist ) - Math . sin ( lat1 ) * Math . sin ( lat2 ) ) ; lon2 = ( lon2 + <NUM_LIT:3> * Math . PI ) % ( <NUM_LIT:2> * Math . PI ) - Math . PI ; lon2 = lon2 * ( <NUM_LIT> / Math . PI ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + lon2 ) ; return lon2 ; } public int policyToWidth ( int policy ) { return policy / <NUM_LIT:10> ; } private BigInteger [ ] multPolys ( BigInteger [ ] a , BigInteger [ ] b ) { int cLength = ( a . length - <NUM_LIT:1> ) + ( b . length - <NUM_LIT:1> ) + <NUM_LIT:1> ; BigInteger [ ] c = new BigInteger [ cLength ] ; BigInteger [ ] newA = new BigInteger [ cLength ] ; for ( int i = <NUM_LIT:0> ; i < newA . length ; i ++ ) { if ( i < a . length ) { newA [ i ] = a [ i ] ; } else { newA [ i ] = new BigInteger ( "<STR_LIT:0>" ) ; } } BigInteger [ ] newB = new BigInteger [ cLength ] ; for ( int i = <NUM_LIT:0> ; i < newB . length ; i ++ ) { if ( i < b . length ) { newB [ i ] = b [ i ] ; } else { newB [ i ] = new BigInteger ( "<STR_LIT:0>" ) ; } } for ( int n = <NUM_LIT:0> ; n < c . length ; n ++ ) { BigInteger tmp = new BigInteger ( "<STR_LIT:0>" ) ; for ( int k = <NUM_LIT:0> ; k <= n ; k ++ ) { tmp = tmp . add ( newA [ k ] . multiply ( newB [ n - k ] ) ) ; } c [ n ] = tmp ; } return c ; } private treeQueue buildRow ( treeQueue bottom ) { treeQueue newRow = new treeQueue ( ) ; for ( int i = <NUM_LIT:0> ; i < bottom . length ; i ++ ) { tree cur = bottom . peek ( i ) ; tree parent = cur . createParent ( ) ; newRow . push ( parent ) ; cur . setParent ( parent ) ; if ( cur . upRightward ( ) ) { parent . left = cur ; if ( i + <NUM_LIT:1> < bottom . length ) { parent . right = bottom . peek ( i + <NUM_LIT:1> ) ; bottom . peek ( i + <NUM_LIT:1> ) . setParent ( parent ) ; } i = i + <NUM_LIT:1> ; } else { parent . right = cur ; if ( i - <NUM_LIT:1> >= <NUM_LIT:0> ) { parent . left = bottom . peek ( i - <NUM_LIT:1> ) ; bottom . peek ( i - <NUM_LIT:1> ) . setParent ( parent ) ; } } } return newRow ; } public tree buildUp ( treeQueue leaves ) { treeQueue top = new treeQueue ( ) ; treeQueue bottom = leaves ; while ( top . length != <NUM_LIT:1> ) { top = buildRow ( bottom ) ; bottom = top ; } return top . peek ( <NUM_LIT:0> ) ; } public treeQueue findPath ( tree leaf , int height ) { treeQueue answer = new treeQueue ( ) ; tree cur = leaf ; while ( cur . height < height ) { answer . push ( cur ) ; cur = cur . createParent ( ) ; } return answer ; } public treeQueue findWall ( tree leftEnd , tree rightEnd , tree root ) { treeQueue answer = new treeQueue ( ) ; treeQueue bottom = new treeQueue ( ) ; treeQueue top = new treeQueue ( ) ; top . push ( root ) ; while ( top . length != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < top . length ; i ++ ) { tree cur = top . peek ( i ) ; if ( cur . leftLeaf ( ) == null || cur . rightLeaf ( ) == null ) { if ( cur . left != null ) { bottom . push ( cur . left ) ; } if ( cur . right != null ) { bottom . push ( cur . right ) ; } } else { answer . push ( cur ) ; } } top = bottom ; bottom = new treeQueue ( ) ; } return answer ; } private BigInteger [ ] [ ] genPolysFromRoots ( treeQueue trees ) { BigInteger result [ ] [ ] = new BigInteger [ trees . length ] [ <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < trees . length ; i ++ ) { BigInteger [ ] tmp = new BigInteger [ <NUM_LIT:2> ] ; tmp [ <NUM_LIT:0> ] = new BigInteger ( String . valueOf ( trees . peek ( i ) . value * - <NUM_LIT:1> ) ) ; tmp [ <NUM_LIT:1> ] = new BigInteger ( "<STR_LIT:1>" ) ; result [ i ] = tmp ; } for ( int i = <NUM_LIT:0> ; i < result . length ; i ++ ) { for ( int j = <NUM_LIT:0> ; j < result [ i ] . length ; j ++ ) { } } return result ; } public BigInteger [ ] makeCoefficientsTwo ( treeQueue repSet ) { BigInteger polys [ ] [ ] = genPolysFromRoots ( repSet ) ; BigInteger [ ] cur = multPolys ( polys [ <NUM_LIT:0> ] , polys [ <NUM_LIT:1> ] ) ; for ( int i = <NUM_LIT:2> ; i < polys . length ; i ++ ) { cur = multPolys ( cur , polys [ i ] ) ; } return cur ; } public BigInteger [ ] makeCoefficientsOne ( treeQueue repSet ) { BigInteger [ ] answer = new BigInteger [ repSet . length ] ; for ( int i = <NUM_LIT:0> ; i < repSet . length ; i ++ ) { answer [ i ] = new BigInteger ( String . valueOf ( repSet . peek ( i ) . value * - <NUM_LIT:1> ) ) ; } return answer ; } public BigInteger [ ] makeCoefficients ( treeQueue repSet , int method ) { if ( method == <NUM_LIT:1> ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; return makeCoefficientsOne ( repSet ) ; } else if ( method == <NUM_LIT:2> ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; return makeCoefficientsTwo ( repSet ) ; } else { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; return null ; } } public BigInteger [ ] computation ( treeQueue coveringSet , BigInteger [ ] encCoe , int bits , BigInteger g , BigInteger n , int method ) { BigInteger [ ] results = null ; Random rand = new Random ( ) ; Paillier paillierE = new Paillier ( false ) ; paillierE . loadPublicKey ( g , n ) ; if ( method == <NUM_LIT:1> ) { results = new BigInteger [ encCoe . length * coveringSet . length ] ; int k = <NUM_LIT:0> ; for ( int j = <NUM_LIT:0> ; j < coveringSet . length ; j ++ ) { int tmp = coveringSet . peek ( j ) . value ; BigInteger bob = new BigInteger ( String . valueOf ( tmp ) ) ; bob = paillierE . Encryption ( bob ) ; for ( int i = <NUM_LIT:0> ; i < encCoe . length ; i ++ ) { BigInteger alice = encCoe [ i ] ; BigInteger c = bob . multiply ( alice ) . mod ( paillierE . nsquare ) ; results [ k ] = c ; BigInteger r = new BigInteger ( String . valueOf ( rand . nextInt ( <NUM_LIT> ) ) ) ; results [ k ] = homoMult ( results [ k ] , r , n ) ; k ++ ; } } } else if ( method == <NUM_LIT:2> ) { results = new BigInteger [ coveringSet . length ] ; for ( int i = <NUM_LIT:0> ; i < coveringSet . length ; i ++ ) { BigInteger b = new BigInteger ( String . valueOf ( coveringSet . peek ( i ) . value ) ) ; results [ i ] = homoEval ( b , encCoe , n ) ; BigInteger r = new BigInteger ( String . valueOf ( rand . nextInt ( <NUM_LIT> ) ) ) ; results [ i ] = homoMult ( results [ i ] , r , n ) ; } } Collections . shuffle ( Arrays . asList ( results ) ) ; return results ; } public Paillier getKey ( int bits ) { shareSingleton share = shareSingleton . getInstance ( ) ; if ( share . pKey == null ) { share . pKey = new Paillier ( bits , <NUM_LIT> ) ; } return share . pKey ; } public BigInteger [ ] encryptArray ( BigInteger [ ] clear , Context context ) { SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( context ) ; int bits = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; Paillier p = getKey ( bits ) ; BigInteger [ ] priv = p . privateKey ( ) ; BigInteger [ ] encCoe = new BigInteger [ clear . length ] ; for ( int i = <NUM_LIT:0> ; i < encCoe . length ; i ++ ) { encCoe [ i ] = p . Encryption ( clear [ i ] ) ; } return encCoe ; } public int [ ] makeSpan ( int stage , Location loc , int policy ) { double edge = <NUM_LIT:0.0> ; int edgeLeafNumber = <NUM_LIT:0> ; int userLeafNumber = <NUM_LIT:0> ; if ( stage == <NUM_LIT:2> || stage == <NUM_LIT:3> ) { edge = findLong ( loc . getLongitude ( ) , loc . getLatitude ( ) , policy ) ; edgeLeafNumber = longitudeToLeaf ( edge ) ; userLeafNumber = longitudeToLeaf ( loc . getLongitude ( ) ) ; } else if ( stage == <NUM_LIT:5> || stage == <NUM_LIT:6> ) { edge = findLat ( loc . getLongitude ( ) , loc . getLatitude ( ) , policy ) ; edgeLeafNumber = latitudeToLeaf ( edge ) ; userLeafNumber = latitudeToLeaf ( loc . getLatitude ( ) ) ; } int spanLength = ( Math . abs ( edgeLeafNumber - userLeafNumber ) * <NUM_LIT:2> ) + <NUM_LIT:1> ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + spanLength ) ; int left = userLeafNumber - ( spanLength / <NUM_LIT:2> ) ; int right = userLeafNumber + ( spanLength / <NUM_LIT:2> ) ; Log . d ( "<STR_LIT>" + stage , "<STR_LIT>" + left + "<STR_LIT:U+0020toU+0020>" + right + "<STR_LIT>" + spanLength + "<STR_LIT>" + userLeafNumber ) ; return new int [ ] { left , userLeafNumber , right } ; } public boolean check ( String [ ] tokens , Context context , int bits ) { Paillier paillierD = getKey ( bits ) ; long start = System . currentTimeMillis ( ) ; boolean found = false ; for ( int i = <NUM_LIT:0> ; i < tokens . length ; i ++ ) { BigInteger val = new BigInteger ( tokens [ i ] , <NUM_LIT:32> ) ; String clear = paillierD . Decryption ( val ) . toString ( ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + clear ) ; if ( clear . equals ( "<STR_LIT:0>" ) ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; found = true ; break ; } } long end = System . currentTimeMillis ( ) ; long total_checkTime = end - start ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + total_checkTime + "<STR_LIT>" ) ; return found ; } public String sendFBMessage ( String rec , String message , Context context ) { Random gen = new Random ( ) ; String session_id = String . format ( "<STR_LIT>" , gen . nextInt ( <NUM_LIT> ) ) ; xmppService . sendMessage ( rec , message , <NUM_LIT:1> , session_id , context ) ; return session_id ; } public void sendFBMessage ( String rec , String message , int stage , String session , Context context ) { xmppService . sendMessage ( rec , message , stage , session , context ) ; } public Location locSimple ( Context context ) { LocationManager lManager = ( LocationManager ) context . getSystemService ( Context . LOCATION_SERVICE ) ; Location lastKnownLocation = lManager . getLastKnownLocation ( LocationManager . GPS_PROVIDER ) ; if ( lastKnownLocation == null ) { lastKnownLocation = lManager . getLastKnownLocation ( LocationManager . NETWORK_PROVIDER ) ; } SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( context ) ; if ( prefs . getBoolean ( "<STR_LIT>" , false ) ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; Double fake_lat = Double . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; Double fake_lon = Double . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + fake_lat + "<STR_LIT>" + fake_lon ) ; lastKnownLocation = new Location ( "<STR_LIT>" ) ; lastKnownLocation . setLatitude ( fake_lat ) ; lastKnownLocation . setLongitude ( fake_lon ) ; lastKnownLocation . setTime ( System . currentTimeMillis ( ) ) ; } if ( lastKnownLocation == null ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } return lastKnownLocation ; } public void notification ( String ticker , String title , String content , Context context , Intent notificationIntent ) { NotificationManager mNM = ( NotificationManager ) context . getSystemService ( Context . NOTIFICATION_SERVICE ) ; Notification notification = new Notification ( R . drawable . ic_launcher , ticker , System . currentTimeMillis ( ) ) ; PendingIntent contentIntent = PendingIntent . getActivity ( context , <NUM_LIT:0> , notificationIntent , PendingIntent . FLAG_UPDATE_CURRENT ) ; notification . setLatestEventInfo ( context , title , content , contentIntent ) ; mNM . notify ( <NUM_LIT:1> , notification ) ; } public int getPathLength ( int policy ) { double top = Math . log ( ( double ) policy * <NUM_LIT> / <NUM_LIT> ) ; double real = top / Math . log ( <NUM_LIT:2> ) ; return Math . min ( <NUM_LIT:15> , ( int ) Math . round ( real ) + <NUM_LIT:1> ) ; } } </s>
<s> package net . ednovak . nearby ; public class buffer { public String session ; public String message = "<STR_LIT>" ; public long start ; public String sender ; public buffer ( String nSender , long nStart , String nSession ) { sender = nSender ; start = nStart ; session = nSession ; } public void append ( String m ) { message = message + m ; } } </s>
<s> package net . ednovak . nearby ; public class messageQueue { private String [ ] arr = new String [ <NUM_LIT:2> ] ; private int end = <NUM_LIT:0> ; public int length = end ; public void push ( String newMessage ) { if ( end == arr . length - <NUM_LIT:1> ) { String [ ] tmp = new String [ arr . length * <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < arr . length ; i ++ ) { tmp [ i ] = arr [ i ] ; } arr = tmp ; } arr [ end ] = newMessage ; end ++ ; length = end ; } public String peek ( int spot ) { if ( spot >= end ) { System . out . println ( "<STR_LIT>" + spot ) ; System . exit ( <NUM_LIT> ) ; } if ( spot == - <NUM_LIT:1> ) { return arr [ end - <NUM_LIT:1> ] ; } return arr [ spot ] ; } public int length ( ) { return end ; } } </s>
<s> package net . ednovak . nearby ; import java . math . BigInteger ; import java . util . ArrayList ; import org . jivesoftware . smack . Chat ; import org . jivesoftware . smack . MessageListener ; import org . jivesoftware . smack . packet . Message ; import android . content . Context ; import android . content . Intent ; import android . content . SharedPreferences ; import android . location . Location ; import android . preference . PreferenceManager ; import android . util . Log ; public class nearbyListener implements MessageListener { private Context context ; private ArrayList < buffer > buffs = new ArrayList < buffer > ( ) ; public nearbyListener ( Context nContext ) { context = nContext ; } @ Override public void processMessage ( Chat chat , Message message ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; buffer buff = parseIncoming ( message ) ; if ( buff != null ) { protocol p = new protocol ( ) ; SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( context ) ; long end = System . currentTimeMillis ( ) ; long total_recTime = end - buff . start ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + total_recTime + "<STR_LIT>" ) ; String sender = buff . sender ; String [ ] parts = buff . message . split ( "<STR_LIT::>" ) ; int stage = Integer . valueOf ( parts [ <NUM_LIT:0> ] ) ; shareSingleton share ; switch ( stage ) { case <NUM_LIT:1> : if ( parts [ <NUM_LIT:2> ] . equals ( "<STR_LIT>" ) ) { int bits = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; int policy = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; int method = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT:1>" ) ) ; Log . d ( "<STR_LIT:test>" , "<STR_LIT>" + method + "<STR_LIT>" + policy + "<STR_LIT>" + bits ) ; int [ ] span = new int [ <NUM_LIT:3> ] ; span = p . makeSpan ( <NUM_LIT:2> , p . locSimple ( context ) , policy ) ; treeQueue leaves = p . genLeaves ( span [ <NUM_LIT:0> ] , span [ <NUM_LIT:2> ] , span [ <NUM_LIT:1> ] , "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + leaves . length ) ; tree root = p . buildUp ( leaves ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + root . count ( ) + "<STR_LIT>" ) ; treeQueue wall = p . findWall ( leaves . peek ( <NUM_LIT:0> ) , leaves . peek ( - <NUM_LIT:1> ) , root ) ; BigInteger [ ] coefficients = p . makeCoefficients ( wall , method ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + coefficients . length ) ; BigInteger [ ] encCoe = p . encryptArray ( coefficients , context ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + Character . MAX_RADIX ) ; StringBuffer txt = new StringBuffer ( ) ; txt . append ( encCoe [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; for ( int i = <NUM_LIT:1> ; i < encCoe . length ; i ++ ) { txt . append ( "<STR_LIT::>" + encCoe [ i ] . toString ( <NUM_LIT:32> ) ) ; } BigInteger [ ] key = p . getKey ( <NUM_LIT> ) . publicKey ( ) ; txt . append ( "<STR_LIT::>" + policy ) ; txt . append ( "<STR_LIT::>" + bits ) ; txt . append ( "<STR_LIT::>" + key [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; txt . append ( "<STR_LIT::>" + key [ <NUM_LIT:1> ] . toString ( <NUM_LIT:32> ) ) ; txt . append ( "<STR_LIT::>" + method ) ; p . sendFBMessage ( sender , txt . toString ( ) , <NUM_LIT:3> , buff . session , context ) ; break ; } case <NUM_LIT:3> : int policy = Integer . valueOf ( parts [ parts . length - <NUM_LIT:5> ] ) ; int bits = Integer . valueOf ( parts [ parts . length - <NUM_LIT:4> ] ) ; BigInteger g = new BigInteger ( parts [ parts . length - <NUM_LIT:3> ] , <NUM_LIT:32> ) ; BigInteger n = new BigInteger ( parts [ parts . length - <NUM_LIT:2> ] , <NUM_LIT:32> ) ; int method = Integer . valueOf ( parts [ parts . length - <NUM_LIT:1> ] ) ; int [ ] span = p . makeSpan ( <NUM_LIT:3> , p . locSimple ( context ) , <NUM_LIT> ) ; String mapString = new StringBuffer ( Integer . toBinaryString ( span [ <NUM_LIT:1> ] ) ) . toString ( ) ; tree alice = new tree ( span [ <NUM_LIT:1> ] , mapString . toCharArray ( ) , null , null , <NUM_LIT:0> , "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + alice . value ) ; long pathStart = System . currentTimeMillis ( ) ; treeQueue path = p . findPath ( alice , p . getPathLength ( policy ) ) ; long pathEnd = System . currentTimeMillis ( ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + ( pathEnd - pathStart ) ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + path . length ) ; BigInteger [ ] encCoe = new BigInteger [ parts . length - <NUM_LIT:7> ] ; for ( int i = <NUM_LIT:0> ; i < encCoe . length ; i ++ ) { encCoe [ i ] = new BigInteger ( parts [ i + <NUM_LIT:2> ] , <NUM_LIT:32> ) ; } Log . d ( "<STR_LIT:test>" , "<STR_LIT>" ) ; long compStart = System . currentTimeMillis ( ) ; BigInteger [ ] results = p . computation ( path , encCoe , bits , g , n , method ) ; long compEnd = System . currentTimeMillis ( ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + ( compEnd - compStart ) ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + results . length ) ; StringBuffer txt = new StringBuffer ( ) ; txt . append ( results [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; for ( int i = <NUM_LIT:1> ; i < results . length ; i ++ ) { txt . append ( "<STR_LIT::>" + results [ i ] . toString ( <NUM_LIT:32> ) ) ; } p . sendFBMessage ( sender , txt . toString ( ) , <NUM_LIT:4> , buff . session , context ) ; break ; case <NUM_LIT:4> : Log . d ( "<STR_LIT:test>" , "<STR_LIT>" ) ; String [ ] cValues = new String [ parts . length - <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < cValues . length ; i ++ ) { cValues [ i ] = parts [ i + <NUM_LIT:2> ] ; } bits = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; share = shareSingleton . getInstance ( ) ; share . foundLon = p . check ( cValues , context , bits ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + share . foundLon ) ; bits = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; policy = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; method = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT:1>" ) ) ; span = p . makeSpan ( <NUM_LIT:5> , p . locSimple ( context ) , policy ) ; treeQueue leaves = p . genLeaves ( span [ <NUM_LIT:0> ] , span [ <NUM_LIT:2> ] , span [ <NUM_LIT:1> ] , "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + span [ <NUM_LIT:1> ] ) ; tree root = p . buildUp ( leaves ) ; treeQueue wall = p . findWall ( leaves . peek ( <NUM_LIT:0> ) , leaves . peek ( - <NUM_LIT:1> ) , root ) ; BigInteger [ ] coefficients = p . makeCoefficients ( wall , method ) ; encCoe = p . encryptArray ( coefficients , context ) ; txt = new StringBuffer ( ) ; txt . append ( encCoe [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; for ( int i = <NUM_LIT:1> ; i < encCoe . length ; i ++ ) { txt . append ( "<STR_LIT::>" + encCoe [ i ] . toString ( <NUM_LIT:32> ) ) ; } BigInteger [ ] key = p . getKey ( <NUM_LIT> ) . publicKey ( ) ; txt . append ( "<STR_LIT::>" + policy ) ; txt . append ( "<STR_LIT::>" + bits ) ; txt . append ( "<STR_LIT::>" + key [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; txt . append ( "<STR_LIT::>" + key [ <NUM_LIT:1> ] . toString ( <NUM_LIT:32> ) ) ; txt . append ( "<STR_LIT::>" + method ) ; p . sendFBMessage ( sender , txt . toString ( ) , <NUM_LIT:6> , buff . session , context ) ; break ; case <NUM_LIT:6> : policy = Integer . valueOf ( parts [ parts . length - <NUM_LIT:5> ] ) ; bits = Integer . valueOf ( parts [ parts . length - <NUM_LIT:4> ] ) ; g = new BigInteger ( parts [ parts . length - <NUM_LIT:3> ] , <NUM_LIT:32> ) ; n = new BigInteger ( parts [ parts . length - <NUM_LIT:2> ] , <NUM_LIT:32> ) ; method = Integer . valueOf ( parts [ parts . length - <NUM_LIT:1> ] ) ; span = p . makeSpan ( <NUM_LIT:6> , p . locSimple ( context ) , <NUM_LIT> ) ; mapString = new StringBuffer ( Integer . toBinaryString ( span [ <NUM_LIT:1> ] ) ) . toString ( ) ; alice = new tree ( span [ <NUM_LIT:1> ] , mapString . toCharArray ( ) , null , null , <NUM_LIT:0> , "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + alice . value ) ; path = p . findPath ( alice , p . getPathLength ( policy ) ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + path . length ) ; encCoe = new BigInteger [ parts . length - <NUM_LIT:7> ] ; for ( int i = <NUM_LIT:0> ; i < encCoe . length ; i ++ ) { encCoe [ i ] = new BigInteger ( parts [ i + <NUM_LIT:2> ] , <NUM_LIT:32> ) ; } Log . d ( "<STR_LIT:test>" , "<STR_LIT>" ) ; results = p . computation ( path , encCoe , bits , g , n , method ) ; txt = new StringBuffer ( ) ; txt . append ( results [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; for ( int i = <NUM_LIT:1> ; i < results . length ; i ++ ) { txt . append ( "<STR_LIT::>" + results [ i ] . toString ( <NUM_LIT:32> ) ) ; } share = shareSingleton . getInstance ( ) ; share . pKey = null ; Paillier last = p . getKey ( <NUM_LIT> ) ; BigInteger [ ] pub = last . publicKey ( ) ; txt . append ( "<STR_LIT::>" + pub [ <NUM_LIT:0> ] . toString ( <NUM_LIT:32> ) ) ; txt . append ( "<STR_LIT::>" + pub [ <NUM_LIT:1> ] . toString ( <NUM_LIT:32> ) ) ; p . sendFBMessage ( sender , txt . toString ( ) , <NUM_LIT:7> , buff . session , context ) ; break ; case <NUM_LIT:7> : Log . d ( "<STR_LIT:test>" , "<STR_LIT>" ) ; cValues = new String [ parts . length - <NUM_LIT:4> ] ; for ( int i = <NUM_LIT:0> ; i < cValues . length ; i ++ ) { cValues [ i ] = parts [ i + <NUM_LIT:2> ] ; } bits = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; boolean latResult = p . check ( cValues , context , bits ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + latResult ) ; share = shareSingleton . getInstance ( ) ; share . pKey = null ; boolean near = latResult && share . foundLon ; String contentTitle = sender + "<STR_LIT>" ; String contentText ; Location l = p . locSimple ( context ) ; if ( near ) { contentText = "<STR_LIT>" ; } else { contentText = "<STR_LIT>" ; l . setLatitude ( <NUM_LIT:0.0> ) ; l . setLongitude ( <NUM_LIT:0.0> ) ; } Intent intent = new Intent ( context , MainActivity . class ) ; p . notification ( "<STR_LIT>" , contentTitle , contentText , context , intent ) ; g = new BigInteger ( parts [ parts . length - <NUM_LIT:2> ] , <NUM_LIT:32> ) ; n = new BigInteger ( parts [ parts . length - <NUM_LIT:1> ] , <NUM_LIT:32> ) ; last = p . getKey ( <NUM_LIT> ) ; last . loadPublicKey ( g , n ) ; double [ ] orig = { l . getLatitude ( ) , l . getLongitude ( ) } ; String [ ] sendingLocation = new String [ <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < orig . length ; i ++ ) { orig [ i ] = orig [ i ] * <NUM_LIT> ; orig [ i ] = Math . abs ( orig [ i ] ) ; sendingLocation [ i ] = last . Encryption ( new BigInteger ( String . valueOf ( ( int ) orig [ i ] ) ) ) . toString ( <NUM_LIT:32> ) ; } share . pKey = null ; txt = new StringBuffer ( ) ; txt . append ( sendingLocation [ <NUM_LIT:0> ] ) ; txt . append ( "<STR_LIT::>" + sendingLocation [ <NUM_LIT:1> ] ) ; String sign = "<STR_LIT:+>" ; if ( l . getLatitude ( ) < <NUM_LIT:0> ) { sign = "<STR_LIT:->" ; } txt . append ( "<STR_LIT::>" + sign ) ; sign = "<STR_LIT:+>" ; if ( l . getLongitude ( ) < <NUM_LIT:0> ) { sign = "<STR_LIT:->" ; } txt . append ( "<STR_LIT::>" + sign ) ; p . sendFBMessage ( sender , txt . toString ( ) , <NUM_LIT:8> , buff . session , context ) ; break ; case <NUM_LIT:8> : last = p . getKey ( <NUM_LIT> ) ; double lat = last . Decryption ( new BigInteger ( parts [ <NUM_LIT:2> ] , <NUM_LIT:32> ) ) . doubleValue ( ) ; double lon = last . Decryption ( new BigInteger ( parts [ <NUM_LIT:3> ] , <NUM_LIT:32> ) ) . doubleValue ( ) ; share = shareSingleton . getInstance ( ) ; share . pKey = null ; String latString = parts [ <NUM_LIT:4> ] + ( lat / <NUM_LIT> ) ; String lonString = parts [ <NUM_LIT:5> ] + ( lon / <NUM_LIT> ) ; long totalEnd = System . currentTimeMillis ( ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + latString + "<STR_LIT::>" + lonString ) ; share = shareSingleton . getInstance ( ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + ( totalEnd - share . start ) ) ; Intent i = new Intent ( context , processedQueries . class ) ; i . setFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; i . putExtra ( "<STR_LIT>" , latString ) ; i . putExtra ( "<STR_LIT>" , lonString ) ; i . putExtra ( "<STR_LIT:name>" , sender ) ; context . startActivity ( i ) ; } } } private buffer searchBuff ( String session ) { for ( buffer b : buffs ) { if ( b . session . equals ( session ) ) { return b ; } } return null ; } private void clearBuff ( buffer b ) { for ( int i = <NUM_LIT:0> ; i < buffs . size ( ) ; i ++ ) { if ( buffs . get ( i ) == b ) { buffs . remove ( i ) ; } } b . message = b . message . substring ( <NUM_LIT:0> , b . message . length ( ) - <NUM_LIT:2> ) ; } private buffer parseIncoming ( Message packet ) { boolean lastPacket = false ; if ( packet . getBody ( ) . substring ( <NUM_LIT:0> , <NUM_LIT:2> ) . equals ( "<STR_LIT>" ) ) { String [ ] parts = packet . getBody ( ) . split ( "<STR_LIT::>" ) ; String session = parts [ <NUM_LIT:1> ] ; buffer buff ; buff = searchBuff ( session ) ; if ( buff == null ) { String sender = xmppService . getRoster ( ) . getEntry ( packet . getFrom ( ) . toString ( ) ) . getName ( ) ; buff = new buffer ( sender , System . currentTimeMillis ( ) , session ) ; buffs . add ( buff ) ; buff . append ( packet . getBody ( ) . substring ( <NUM_LIT:2> , <NUM_LIT:10> ) ) ; } String tmpMess = packet . getBody ( ) . substring ( <NUM_LIT:10> ) ; buff . append ( tmpMess ) ; lastPacket = packet . getBody ( ) . substring ( packet . getBody ( ) . length ( ) - <NUM_LIT:2> ) . equals ( "<STR_LIT>" ) ; if ( lastPacket ) { clearBuff ( buff ) ; return buff ; } } return null ; } } </s>
<s> package net . ednovak . nearby ; import java . math . BigInteger ; import java . util . Random ; public class Paillier { private BigInteger p , q , lambda ; public BigInteger n ; public BigInteger nsquare ; public BigInteger g ; private int bitLength ; public Paillier ( int bitLengthVal , int certainty ) { KeyGeneration ( bitLengthVal , certainty ) ; } public Paillier ( ) { KeyGeneration ( <NUM_LIT:32> , <NUM_LIT:16> ) ; } public Paillier ( boolean genKey ) { if ( genKey ) { KeyGeneration ( <NUM_LIT> , <NUM_LIT> ) ; } else { } } public void loadPublicKey ( BigInteger newG , BigInteger newN ) { g = newG ; n = newN ; nsquare = newN . multiply ( newN ) ; } public void loadPrivateKey ( BigInteger newG , BigInteger newLambda , BigInteger newN ) { g = newG ; lambda = newLambda ; n = newN ; nsquare = newN . multiply ( newN ) ; } public void KeyGeneration ( int bitLengthVal , int certainty ) { bitLength = bitLengthVal ; p = new BigInteger ( bitLength / <NUM_LIT:2> , certainty , new Random ( ) ) ; q = new BigInteger ( bitLength / <NUM_LIT:2> , certainty , new Random ( ) ) ; n = p . multiply ( q ) ; nsquare = n . multiply ( n ) ; g = new BigInteger ( "<STR_LIT:2>" ) ; lambda = p . subtract ( BigInteger . ONE ) . multiply ( q . subtract ( BigInteger . ONE ) ) . divide ( p . subtract ( BigInteger . ONE ) . gcd ( q . subtract ( BigInteger . ONE ) ) ) ; if ( g . modPow ( lambda , nsquare ) . subtract ( BigInteger . ONE ) . divide ( n ) . gcd ( n ) . intValue ( ) != <NUM_LIT:1> ) { System . out . println ( "<STR_LIT>" ) ; System . exit ( <NUM_LIT:1> ) ; } } public BigInteger Encryption ( BigInteger m , BigInteger r ) { return g . modPow ( m , nsquare ) . multiply ( r . modPow ( n , nsquare ) ) . mod ( nsquare ) ; } public BigInteger Encryption ( BigInteger m ) { BigInteger r = new BigInteger ( bitLength , new Random ( ) ) ; return g . modPow ( m , nsquare ) . multiply ( r . modPow ( n , nsquare ) ) . mod ( nsquare ) ; } public BigInteger Decryption ( BigInteger c ) { BigInteger u = g . modPow ( lambda , nsquare ) . subtract ( BigInteger . ONE ) . divide ( n ) . modInverse ( n ) ; return c . modPow ( lambda , nsquare ) . subtract ( BigInteger . ONE ) . divide ( n ) . multiply ( u ) . mod ( n ) ; } public BigInteger [ ] privateKey ( ) { BigInteger [ ] k = { g , lambda , n } ; return k ; } public BigInteger [ ] publicKey ( ) { BigInteger [ ] k = { g , n } ; return k ; } public static void main ( String [ ] str ) { Paillier paillier = new Paillier ( ) ; BigInteger m1 = new BigInteger ( "<STR_LIT>" ) ; BigInteger m2 = new BigInteger ( "<STR_LIT>" ) ; BigInteger em1 = paillier . Encryption ( m1 ) ; BigInteger em2 = paillier . Encryption ( m2 ) ; System . out . println ( em1 ) ; System . out . println ( em2 ) ; System . out . println ( paillier . Decryption ( em1 ) . toString ( ) ) ; System . out . println ( paillier . Decryption ( em2 ) . toString ( ) ) ; BigInteger product_em1em2 = em1 . multiply ( em2 ) . mod ( paillier . nsquare ) ; BigInteger sum_m1m2 = m1 . add ( m2 ) . mod ( paillier . n ) ; System . out . println ( "<STR_LIT>" + sum_m1m2 . toString ( ) ) ; System . out . println ( "<STR_LIT>" + paillier . Decryption ( product_em1em2 ) . toString ( ) ) ; BigInteger expo_em1m2 = em1 . modPow ( m2 , paillier . nsquare ) ; BigInteger prod_m1m2 = m1 . multiply ( m2 ) . mod ( paillier . n ) ; System . out . println ( "<STR_LIT>" + prod_m1m2 . toString ( ) ) ; System . out . println ( "<STR_LIT>" + paillier . Decryption ( expo_em1m2 ) . toString ( ) ) ; } } </s>
<s> package net . ednovak . nearby ; import android . app . Activity ; import android . content . Intent ; import android . os . Bundle ; import java . util . Random ; public class displayMessageAct extends Activity { @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_wait ) ; shareSingleton share = shareSingleton . getInstance ( ) ; protocol p = new protocol ( ) ; Intent intent = getIntent ( ) ; String rec = intent . getStringExtra ( "<STR_LIT>" ) ; String session = p . sendFBMessage ( rec , "<STR_LIT>" , this ) ; } } </s>
<s> package net . ednovak . nearby ; import java . util . Random ; import android . app . Activity ; import android . os . Bundle ; import android . view . View ; import android . widget . EditText ; public class messageTest extends Activity { @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_message_test ) ; } public void genMessage ( View view ) { EditText lengthEditText = ( EditText ) findViewById ( R . id . length ) ; int length = Integer . valueOf ( lengthEditText . getText ( ) . toString ( ) ) ; Random rng = new Random ( ) ; String characters = "<STR_LIT>" ; char [ ] message = new char [ length ] ; for ( int i = <NUM_LIT:0> ; i < message . length ; i ++ ) { message [ i ] = characters . charAt ( rng . nextInt ( characters . length ( ) ) ) ; } EditText messageEditText = ( EditText ) findViewById ( R . id . message ) ; messageEditText . setText ( new String ( message ) ) ; } public void sendMessage ( View view ) { EditText messageEditText = ( EditText ) findViewById ( R . id . message ) ; String message = messageEditText . getText ( ) . toString ( ) ; EditText recEditText = ( EditText ) findViewById ( R . id . rec ) ; String rec = recEditText . getText ( ) . toString ( ) ; protocol p = new protocol ( ) ; p . sendFBMessage ( rec , message , this ) ; } } </s>
<s> package net . ednovak . nearby ; import android . content . Context ; import android . content . SharedPreferences ; import android . location . Location ; import android . location . LocationListener ; import android . os . Bundle ; import android . preference . PreferenceManager ; import android . util . Log ; public class lListener implements LocationListener { public double lon = - <NUM_LIT> ; public double lat = - <NUM_LIT> ; public lListener ( ) { } public void plugFake ( Context context ) { SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( context ) ; if ( prefs . getBoolean ( "<STR_LIT>" , false ) ) { Double fake_lat = Double . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; Double fake_lon = Double . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; lat = fake_lat ; lon = fake_lon ; } } @ Override public void onLocationChanged ( Location location ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" + location ) ; if ( location . hasAccuracy ( ) ) { if ( location . getAccuracy ( ) < <NUM_LIT:1.0> ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; updateCurrent ( location ) ; } } else { updateCurrent ( location ) ; } } private void updateCurrent ( Location loc ) { lon = loc . getLongitude ( ) ; lat = loc . getLatitude ( ) ; shareSingleton share = shareSingleton . getInstance ( ) ; share . lon = loc . getLongitude ( ) ; share . lat = loc . getLatitude ( ) ; } public boolean listening ( ) { if ( lat == - <NUM_LIT> || lon == - <NUM_LIT> ) { return true ; } else { return false ; } } @ Override public void onStatusChanged ( String provider , int status , Bundle extra ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } @ Override public void onProviderEnabled ( String provider ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } @ Override public void onProviderDisabled ( String provider ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } } </s>
<s> package net . ednovak . nearby ; import java . math . BigInteger ; import android . app . Activity ; import android . os . Bundle ; import android . view . View ; import android . widget . EditText ; import android . widget . TextView ; public class paillierTest extends Activity { @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_test ) ; } public void encryptionTest ( View view ) { EditText et1 = ( EditText ) findViewById ( R . id . bit_strength ) ; EditText et2 = ( EditText ) findViewById ( R . id . certainty ) ; EditText et3 = ( EditText ) findViewById ( R . id . message ) ; int bitStrength = Integer . valueOf ( et1 . getText ( ) . toString ( ) ) ; int certainty = Integer . valueOf ( et2 . getText ( ) . toString ( ) ) ; BigInteger message = new BigInteger ( et3 . getText ( ) . toString ( ) ) ; TextView tv = ( TextView ) findViewById ( R . id . output ) ; tv . setText ( "<STR_LIT>" ) ; long start = System . currentTimeMillis ( ) ; tv . append ( "<STR_LIT>" + et1 . getText ( ) . toString ( ) + "<STR_LIT>" ) ; long keyStart = System . currentTimeMillis ( ) ; Paillier paillier = new Paillier ( bitStrength , certainty ) ; long keyEnd = System . currentTimeMillis ( ) ; tv . append ( "<STR_LIT>" + message . toString ( ) + "<STR_LIT>" ) ; long encStart = System . currentTimeMillis ( ) ; BigInteger enc = paillier . Encryption ( message ) ; long encEnd = System . currentTimeMillis ( ) ; tv . append ( "<STR_LIT>" + enc . toString ( <NUM_LIT:16> ) , <NUM_LIT:0> , <NUM_LIT:30> ) ; tv . append ( "<STR_LIT>" ) ; tv . append ( "<STR_LIT>" ) ; long decStart = System . currentTimeMillis ( ) ; BigInteger clear = paillier . Decryption ( enc ) ; long decEnd = System . currentTimeMillis ( ) ; tv . append ( "<STR_LIT>" + clear + "<STR_LIT:n>" ) ; long end = System . currentTimeMillis ( ) ; long totalKey = keyEnd - keyStart ; long totalEnc = encEnd - encStart ; long totalDec = decEnd - decStart ; long totalTime = end - start ; tv . append ( "<STR_LIT>" ) ; tv . append ( "<STR_LIT>" + totalKey + "<STR_LIT>" ) ; tv . append ( "<STR_LIT>" + totalEnc + "<STR_LIT>" ) ; tv . append ( "<STR_LIT>" + totalDec + "<STR_LIT>" ) ; tv . append ( "<STR_LIT>" + totalTime + "<STR_LIT>" ) ; } } </s>
<s> package net . ednovak . nearby ; import java . math . BigInteger ; public class shareSingleton { private static shareSingleton instance = null ; public double lon ; public double lat ; public String rec ; public xmppService serv ; public int bits ; public int method ; public long start ; int session ; public Paillier pKey ; public boolean foundLon ; public boolean longitude = false ; public BigInteger [ ] last ; protected shareSingleton ( ) { } public static shareSingleton getInstance ( ) { if ( instance == null ) { instance = new shareSingleton ( ) ; } return instance ; } } </s>
<s> package net . ednovak . nearby ; import java . util . ArrayList ; import android . app . ListActivity ; import android . content . ActivityNotFoundException ; import android . content . Intent ; import android . net . Uri ; import android . os . Bundle ; import android . util . Log ; import android . view . View ; import android . widget . AdapterView ; import android . widget . AdapterView . OnItemClickListener ; import android . widget . AdapterView . OnItemLongClickListener ; import android . widget . ArrayAdapter ; import android . widget . ListView ; import android . widget . TextView ; import android . widget . Toast ; public class processedQueries extends ListActivity { private static ArrayList < String > data = new ArrayList < String > ( ) ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_processed_queries ) ; Intent i = getIntent ( ) ; String lat = i . getStringExtra ( "<STR_LIT>" ) ; String lon = i . getStringExtra ( "<STR_LIT>" ) ; String name = i . getStringExtra ( "<STR_LIT:name>" ) ; ListView list = ( ListView ) findViewById ( android . R . id . list ) ; data . add ( <NUM_LIT:0> , name + "<STR_LIT::U+0020>" + lat + "<STR_LIT:U+002CU+0020>" + lon ) ; ArrayAdapter < String > AA = new ArrayAdapter < String > ( this , R . layout . smallfont , data ) ; list . setAdapter ( AA ) ; list . setOnItemClickListener ( new OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > parent , View v , int pos , long id ) { String s = ( ( TextView ) v ) . getText ( ) . toString ( ) ; s = s . split ( "<STR_LIT::>" ) [ <NUM_LIT:1> ] ; String url = "<STR_LIT>" + s ; Intent i = new Intent ( Intent . ACTION_VIEW ) ; i . setData ( Uri . parse ( url ) ) ; startActivity ( i ) ; } } ) ; list . setOnItemLongClickListener ( new OnItemLongClickListener ( ) { @ Override public boolean onItemLongClick ( AdapterView < ? > parent , View v , int pos , long id ) { String s = ( ( TextView ) v ) . getText ( ) . toString ( ) ; s = s . split ( "<STR_LIT::>" ) [ <NUM_LIT:1> ] ; String url = "<STR_LIT>" + s ; Intent i = new Intent ( Intent . ACTION_VIEW ) ; i . setData ( Uri . parse ( url ) ) ; try { startActivity ( i ) ; } catch ( ActivityNotFoundException e ) { Toast . makeText ( getApplicationContext ( ) , "<STR_LIT>" , Toast . LENGTH_SHORT ) . show ( ) ; } return true ; } } ) ; } } </s>
<s> package net . ednovak . nearby ; import android . util . Log ; public class treeQueue { private tree [ ] arr = new tree [ <NUM_LIT:2> ] ; private int end = <NUM_LIT:0> ; public int length = end ; public treeQueue union ( treeQueue other ) { treeQueue tmp = new treeQueue ( ) ; for ( int i = <NUM_LIT:0> ; i < arr . length ; i ++ ) { tmp . push ( arr [ i ] ) ; } for ( int i = <NUM_LIT:0> ; i < other . length ; i ++ ) { tmp . push ( other . peek ( i ) ) ; } return tmp ; } public void push ( tree newTree ) { if ( end == arr . length - <NUM_LIT:1> ) { tree [ ] tmp = new tree [ arr . length * <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < arr . length ; i ++ ) { tmp [ i ] = arr [ i ] ; } arr = tmp ; } arr [ end ] = newTree ; end ++ ; length = end ; } public tree peek ( int spot ) { if ( spot >= end ) { System . out . println ( "<STR_LIT>" + spot ) ; System . exit ( <NUM_LIT> ) ; } if ( spot == - <NUM_LIT:1> ) { return arr [ end - <NUM_LIT:1> ] ; } return arr [ spot ] ; } public int length ( ) { return end ; } public tree findUserLeaf ( ) { tree user = null ; for ( tree t : arr ) { if ( t . special != null ) { if ( user != null ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } user = t ; } } return user ; } public int uniquePush ( tree nTree ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( arr [ i ] . value == nTree . value ) { return - <NUM_LIT:1> ; } } Log . d ( "<STR_LIT>" , "<STR_LIT>" + nTree . value ) ; this . push ( nTree ) ; return <NUM_LIT:0> ; } public tree find ( int value ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( arr [ i ] . value == value ) { return arr [ i ] ; } } return new tree ( <NUM_LIT:0> , new char [ <NUM_LIT:0> ] , null , null , <NUM_LIT:0> , "<STR_LIT>" ) ; } } </s>
<s> package net . ednovak . nearby ; import java . util . ArrayList ; import java . util . Collection ; import java . util . List ; import org . jivesoftware . smack . Chat ; import org . jivesoftware . smack . ChatManager ; import org . jivesoftware . smack . ChatManagerListener ; import org . jivesoftware . smack . Connection ; import org . jivesoftware . smack . ConnectionConfiguration ; import org . jivesoftware . smack . Roster ; import org . jivesoftware . smack . RosterEntry ; import org . jivesoftware . smack . XMPPConnection ; import org . jivesoftware . smack . XMPPException ; import android . app . Service ; import android . content . Context ; import android . content . Intent ; import android . content . SharedPreferences ; import android . os . Binder ; import android . os . IBinder ; import android . preference . PreferenceManager ; import android . util . Log ; public class xmppService extends Service { public static final String LOGIN_UPDATE = "<STR_LIT>" ; public static Connection conn ; public static Boolean in = false ; IBinder xmppBinder = new LocalBinder ( ) ; @ Override public void onCreate ( ) { super . onCreate ( ) ; } @ Override public void onDestroy ( ) { super . onDestroy ( ) ; if ( conn != null ) { conn . disconnect ( ) ; conn = null ; in = false ; } } @ Override public int onStartCommand ( Intent intent , int flags , int startID ) { String user = intent . getStringExtra ( "<STR_LIT:user>" ) ; String pass = intent . getStringExtra ( "<STR_LIT>" ) ; Runnable r = new xmppThread ( user , pass , getApplicationContext ( ) ) ; new Thread ( r ) . start ( ) ; return START_REDELIVER_INTENT ; } private static List < String > make_packets ( String msg , int stage , String session , int chunk ) { List < String > packets = new ArrayList < String > ( ) ; int cur = <NUM_LIT:0> ; int end = <NUM_LIT:0> ; int total = <NUM_LIT:0> ; while ( end < msg . length ( ) ) { total += <NUM_LIT:1> ; end = Math . min ( msg . length ( ) , cur + chunk ) ; packets . add ( "<STR_LIT>" + stage + "<STR_LIT::>" + session + "<STR_LIT::>" + msg . substring ( cur , end ) ) ; cur = end ; } packets . set ( packets . size ( ) - <NUM_LIT:1> , packets . get ( packets . size ( ) - <NUM_LIT:1> ) + "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + total ) ; return packets ; } private static void real_send ( Chat chat , String msg , int stage , String session , int chunk ) { List < String > parts = make_packets ( msg , stage , session , chunk ) ; for ( int i = <NUM_LIT:0> ; i < parts . size ( ) ; i ++ ) { try { chat . sendMessage ( parts . get ( i ) ) ; } catch ( XMPPException e ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" + e . toString ( ) ) ; } } Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } public static void sendMessage ( String rec , String msg , int stage , String session , final Context context ) { Collection < RosterEntry > entries = getRoster ( ) . getEntries ( ) ; if ( entries != null ) { for ( RosterEntry entry : entries ) { if ( entry . getName ( ) . equals ( rec ) ) { Chat newChat = conn . getChatManager ( ) . createChat ( entry . getUser ( ) , null ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + entry . getName ( ) ) ; SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( context ) ; int chunk = Integer . valueOf ( prefs . getString ( "<STR_LIT>" , "<STR_LIT>" ) ) ; real_send ( newChat , msg , stage , session , chunk ) ; } } } else { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; } } @ Override public IBinder onBind ( Intent intent ) { if ( conn == null ) { String user = intent . getStringExtra ( "<STR_LIT:user>" ) ; String pass = intent . getStringExtra ( "<STR_LIT>" ) ; Runnable r = new xmppThread ( user , pass , this ) ; new Thread ( r ) . start ( ) ; } return xmppBinder ; } public class LocalBinder extends Binder { xmppService getService ( ) { return xmppService . this ; } } public static Roster getRoster ( ) { return conn . getRoster ( ) ; } private void announceLogin ( boolean in ) { Intent intent = new Intent ( LOGIN_UPDATE ) ; intent . putExtra ( "<STR_LIT>" , in ) ; sendBroadcast ( intent ) ; } public class xmppThread implements Runnable { private String username ; private String password ; private Context context ; public xmppThread ( String nUsername , String nPassword , Context nContext ) { username = nUsername ; password = nPassword ; context = nContext ; } public void run ( ) { Connection connection = null ; try { ConnectionConfiguration config = new ConnectionConfiguration ( "<STR_LIT>" , <NUM_LIT> ) ; config . setSecurityMode ( ConnectionConfiguration . SecurityMode . disabled ) ; connection = new XMPPConnection ( config ) ; connection . connect ( ) ; connection . login ( username , password ) ; Log . d ( "<STR_LIT>" , "<STR_LIT>" + username ) ; in = true ; conn = connection ; announceLogin ( in ) ; } catch ( XMPPException e ) { Log . d ( "<STR_LIT>" , "<STR_LIT>" ) ; Log . d ( "<STR_LIT>" , e . toString ( ) ) ; } ChatManager cManager = connection . getChatManager ( ) ; cManager . addChatListener ( new ChatManagerListener ( ) { public void chatCreated ( Chat chat , boolean createdLocally ) { if ( ! createdLocally || createdLocally ) { chat . addMessageListener ( new nearbyListener ( context ) ) ; } } } ) ; } } } </s>
<s> package net . ednovak . nearby ; import android . app . Activity ; import android . content . Intent ; import android . os . Bundle ; import android . widget . ImageView ; import android . widget . TextView ; public class answerAct extends Activity { @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_wait ) ; Intent intent = getIntent ( ) ; String text = intent . getStringExtra ( "<STR_LIT>" ) ; boolean answer = intent . getBooleanExtra ( "<STR_LIT>" , false ) ; TextView tv = ( TextView ) findViewById ( R . id . text_view ) ; tv . setText ( text ) ; ImageView iv = ( ImageView ) findViewById ( R . id . waiting ) ; if ( answer ) { iv . setImageResource ( R . drawable . happy ) ; } else { iv . setImageResource ( R . drawable . sad ) ; } } } </s>
<s> package com . actionbarsherlock . internal ; import static org . hamcrest . CoreMatchers . equalTo ; import static org . junit . Assert . assertThat ; import static com . actionbarsherlock . internal . ActionBarSherlockCompat . cleanActivityName ; import com . xtremelabs . robolectric . RobolectricTestRunner ; import org . junit . Test ; import org . junit . runner . RunWith ; @ RunWith ( RobolectricTestRunner . class ) public class ManifestParsingTest { @ Test public void testFullyQualifiedClassName ( ) { String expected = "<STR_LIT>" ; String actual = cleanActivityName ( "<STR_LIT>" , "<STR_LIT>" ) ; assertThat ( expected , equalTo ( actual ) ) ; } @ Test public void testFullyQualifiedClassNameSamePackage ( ) { String expected = "<STR_LIT>" ; String actual = cleanActivityName ( "<STR_LIT>" , "<STR_LIT>" ) ; assertThat ( expected , equalTo ( actual ) ) ; } @ Test public void testUnqualifiedClassName ( ) { String expected = "<STR_LIT>" ; String actual = cleanActivityName ( "<STR_LIT>" , "<STR_LIT>" ) ; assertThat ( expected , equalTo ( actual ) ) ; } @ Test public void testRelativeClassName ( ) { String expected = "<STR_LIT>" ; String actual = cleanActivityName ( "<STR_LIT>" , "<STR_LIT>" ) ; assertThat ( expected , equalTo ( actual ) ) ; } } </s>
<s> package com . actionbarsherlock . view ; import android . content . ComponentName ; import android . content . Intent ; import android . view . KeyEvent ; public interface Menu { static final int USER_MASK = <NUM_LIT> ; static final int USER_SHIFT = <NUM_LIT:0> ; static final int CATEGORY_MASK = <NUM_LIT> ; static final int CATEGORY_SHIFT = <NUM_LIT:16> ; static final int NONE = <NUM_LIT:0> ; static final int FIRST = <NUM_LIT:1> ; static final int CATEGORY_CONTAINER = <NUM_LIT> ; static final int CATEGORY_SYSTEM = <NUM_LIT> ; static final int CATEGORY_SECONDARY = <NUM_LIT> ; static final int CATEGORY_ALTERNATIVE = <NUM_LIT> ; static final int FLAG_APPEND_TO_GROUP = <NUM_LIT> ; static final int FLAG_PERFORM_NO_CLOSE = <NUM_LIT> ; static final int FLAG_ALWAYS_PERFORM_CLOSE = <NUM_LIT> ; public MenuItem add ( CharSequence title ) ; public MenuItem add ( int titleRes ) ; public MenuItem add ( int groupId , int itemId , int order , CharSequence title ) ; public MenuItem add ( int groupId , int itemId , int order , int titleRes ) ; SubMenu addSubMenu ( final CharSequence title ) ; SubMenu addSubMenu ( final int titleRes ) ; SubMenu addSubMenu ( final int groupId , final int itemId , int order , final CharSequence title ) ; SubMenu addSubMenu ( int groupId , int itemId , int order , int titleRes ) ; public int addIntentOptions ( int groupId , int itemId , int order , ComponentName caller , Intent [ ] specifics , Intent intent , int flags , MenuItem [ ] outSpecificItems ) ; public void removeItem ( int id ) ; public void removeGroup ( int groupId ) ; public void clear ( ) ; public void setGroupCheckable ( int group , boolean checkable , boolean exclusive ) ; public void setGroupVisible ( int group , boolean visible ) ; public void setGroupEnabled ( int group , boolean enabled ) ; public boolean hasVisibleItems ( ) ; public MenuItem findItem ( int id ) ; public int size ( ) ; public MenuItem getItem ( int index ) ; public void close ( ) ; public boolean performShortcut ( int keyCode , KeyEvent event , int flags ) ; boolean isShortcutKey ( int keyCode , KeyEvent event ) ; public boolean performIdentifierAction ( int id , int flags ) ; public void setQwertyMode ( boolean isQwerty ) ; } </s>
<s> package com . actionbarsherlock . view ; import android . graphics . drawable . Drawable ; import android . view . View ; public interface SubMenu extends Menu { public SubMenu setHeaderTitle ( int titleRes ) ; public SubMenu setHeaderTitle ( CharSequence title ) ; public SubMenu setHeaderIcon ( int iconRes ) ; public SubMenu setHeaderIcon ( Drawable icon ) ; public SubMenu setHeaderView ( View view ) ; public void clearHeader ( ) ; public SubMenu setIcon ( int iconRes ) ; public SubMenu setIcon ( Drawable icon ) ; public MenuItem getItem ( ) ; } </s>
<s> package com . actionbarsherlock . view ; import android . view . View ; public abstract class ActionMode { private Object mTag ; public void setTag ( Object tag ) { mTag = tag ; } public Object getTag ( ) { return mTag ; } public abstract void setTitle ( CharSequence title ) ; public abstract void setTitle ( int resId ) ; public abstract void setSubtitle ( CharSequence subtitle ) ; public abstract void setSubtitle ( int resId ) ; public abstract void setCustomView ( View view ) ; public abstract void invalidate ( ) ; public abstract void finish ( ) ; public abstract Menu getMenu ( ) ; public abstract CharSequence getTitle ( ) ; public abstract CharSequence getSubtitle ( ) ; public abstract View getCustomView ( ) ; public abstract MenuInflater getMenuInflater ( ) ; public boolean isUiFocusable ( ) { return true ; } public interface Callback { public boolean onCreateActionMode ( ActionMode mode , Menu menu ) ; public boolean onPrepareActionMode ( ActionMode mode , Menu menu ) ; public boolean onActionItemClicked ( ActionMode mode , MenuItem item ) ; public void onDestroyActionMode ( ActionMode mode ) ; } } </s>
<s> package com . actionbarsherlock . view ; import android . content . Context ; public abstract class Window extends android . view . Window { public static final long FEATURE_ACTION_BAR = android . view . Window . FEATURE_ACTION_BAR ; public static final long FEATURE_ACTION_BAR_OVERLAY = android . view . Window . FEATURE_ACTION_BAR_OVERLAY ; public static final long FEATURE_ACTION_MODE_OVERLAY = android . view . Window . FEATURE_ACTION_MODE_OVERLAY ; public static final long FEATURE_NO_TITLE = android . view . Window . FEATURE_NO_TITLE ; public static final long FEATURE_PROGRESS = android . view . Window . FEATURE_PROGRESS ; public static final long FEATURE_INDETERMINATE_PROGRESS = android . view . Window . FEATURE_INDETERMINATE_PROGRESS ; private Window ( Context context ) { super ( context ) ; } public interface Callback { public boolean onMenuItemSelected ( int featureId , MenuItem item ) ; } } </s>
<s> package com . actionbarsherlock . view ; import android . content . Context ; import android . view . View ; public abstract class ActionProvider { private SubUiVisibilityListener mSubUiVisibilityListener ; public ActionProvider ( Context context ) { } public abstract View onCreateActionView ( ) ; public boolean onPerformDefaultAction ( ) { return false ; } public boolean hasSubMenu ( ) { return false ; } public void onPrepareSubMenu ( SubMenu subMenu ) { } public void subUiVisibilityChanged ( boolean isVisible ) { if ( mSubUiVisibilityListener != null ) { mSubUiVisibilityListener . onSubUiVisibilityChanged ( isVisible ) ; } } public void setSubUiVisibilityListener ( SubUiVisibilityListener listener ) { mSubUiVisibilityListener = listener ; } public interface SubUiVisibilityListener { public void onSubUiVisibilityChanged ( boolean isVisible ) ; } } </s>
<s> package com . actionbarsherlock . view ; import java . io . IOException ; import java . lang . reflect . Constructor ; import java . lang . reflect . Method ; import org . xmlpull . v1 . XmlPullParser ; import org . xmlpull . v1 . XmlPullParserException ; import android . content . Context ; import android . content . res . TypedArray ; import android . content . res . XmlResourceParser ; import android . util . AttributeSet ; import android . util . Log ; import android . util . TypedValue ; import android . util . Xml ; import android . view . InflateException ; import android . view . View ; import com . actionbarsherlock . R ; import com . actionbarsherlock . internal . view . menu . MenuItemImpl ; public class MenuInflater { private static final String LOG_TAG = "<STR_LIT>" ; private static final String XML_MENU = "<STR_LIT>" ; private static final String XML_GROUP = "<STR_LIT>" ; private static final String XML_ITEM = "<STR_LIT>" ; private static final int NO_ID = <NUM_LIT:0> ; private static final Class < ? > [ ] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class [ ] { Context . class } ; private static final Class < ? > [ ] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE ; private final Object [ ] mActionViewConstructorArguments ; private final Object [ ] mActionProviderConstructorArguments ; private Context mContext ; public MenuInflater ( Context context ) { mContext = context ; mActionViewConstructorArguments = new Object [ ] { context } ; mActionProviderConstructorArguments = mActionViewConstructorArguments ; } public void inflate ( int menuRes , Menu menu ) { XmlResourceParser parser = null ; try { parser = mContext . getResources ( ) . getLayout ( menuRes ) ; AttributeSet attrs = Xml . asAttributeSet ( parser ) ; parseMenu ( parser , attrs , menu ) ; } catch ( XmlPullParserException e ) { throw new InflateException ( "<STR_LIT>" , e ) ; } catch ( IOException e ) { throw new InflateException ( "<STR_LIT>" , e ) ; } finally { if ( parser != null ) parser . close ( ) ; } } private void parseMenu ( XmlPullParser parser , AttributeSet attrs , Menu menu ) throws XmlPullParserException , IOException { MenuState menuState = new MenuState ( menu ) ; int eventType = parser . getEventType ( ) ; String tagName ; boolean lookingForEndOfUnknownTag = false ; String unknownTagName = null ; do { if ( eventType == XmlPullParser . START_TAG ) { tagName = parser . getName ( ) ; if ( tagName . equals ( XML_MENU ) ) { eventType = parser . next ( ) ; break ; } throw new RuntimeException ( "<STR_LIT>" + tagName ) ; } eventType = parser . next ( ) ; } while ( eventType != XmlPullParser . END_DOCUMENT ) ; boolean reachedEndOfMenu = false ; while ( ! reachedEndOfMenu ) { switch ( eventType ) { case XmlPullParser . START_TAG : if ( lookingForEndOfUnknownTag ) { break ; } tagName = parser . getName ( ) ; if ( tagName . equals ( XML_GROUP ) ) { menuState . readGroup ( attrs ) ; } else if ( tagName . equals ( XML_ITEM ) ) { menuState . readItem ( attrs ) ; } else if ( tagName . equals ( XML_MENU ) ) { SubMenu subMenu = menuState . addSubMenuItem ( ) ; parseMenu ( parser , attrs , subMenu ) ; } else { lookingForEndOfUnknownTag = true ; unknownTagName = tagName ; } break ; case XmlPullParser . END_TAG : tagName = parser . getName ( ) ; if ( lookingForEndOfUnknownTag && tagName . equals ( unknownTagName ) ) { lookingForEndOfUnknownTag = false ; unknownTagName = null ; } else if ( tagName . equals ( XML_GROUP ) ) { menuState . resetGroup ( ) ; } else if ( tagName . equals ( XML_ITEM ) ) { if ( ! menuState . hasAddedItem ( ) ) { if ( menuState . itemActionProvider != null && menuState . itemActionProvider . hasSubMenu ( ) ) { menuState . addSubMenuItem ( ) ; } else { menuState . addItem ( ) ; } } } else if ( tagName . equals ( XML_MENU ) ) { reachedEndOfMenu = true ; } break ; case XmlPullParser . END_DOCUMENT : throw new RuntimeException ( "<STR_LIT>" ) ; } eventType = parser . next ( ) ; } } private static class InflatedOnMenuItemClickListener implements MenuItem . OnMenuItemClickListener { private static final Class < ? > [ ] PARAM_TYPES = new Class [ ] { MenuItem . class } ; private Context mContext ; private Method mMethod ; public InflatedOnMenuItemClickListener ( Context context , String methodName ) { mContext = context ; Class < ? > c = context . getClass ( ) ; try { mMethod = c . getMethod ( methodName , PARAM_TYPES ) ; } catch ( Exception e ) { InflateException ex = new InflateException ( "<STR_LIT>" + methodName + "<STR_LIT>" + c . getName ( ) ) ; ex . initCause ( e ) ; throw ex ; } } public boolean onMenuItemClick ( MenuItem item ) { try { if ( mMethod . getReturnType ( ) == Boolean . TYPE ) { return ( Boolean ) mMethod . invoke ( mContext , item ) ; } else { mMethod . invoke ( mContext , item ) ; return true ; } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } private class MenuState { private Menu menu ; private int groupId ; private int groupCategory ; private int groupOrder ; private int groupCheckable ; private boolean groupVisible ; private boolean groupEnabled ; private boolean itemAdded ; private int itemId ; private int itemCategoryOrder ; private CharSequence itemTitle ; private CharSequence itemTitleCondensed ; private int itemIconResId ; private char itemAlphabeticShortcut ; private char itemNumericShortcut ; private int itemCheckable ; private boolean itemChecked ; private boolean itemVisible ; private boolean itemEnabled ; private int itemShowAsAction ; private int itemActionViewLayout ; private String itemActionViewClassName ; private String itemActionProviderClassName ; private String itemListenerMethodName ; private ActionProvider itemActionProvider ; private static final int defaultGroupId = NO_ID ; private static final int defaultItemId = NO_ID ; private static final int defaultItemCategory = <NUM_LIT:0> ; private static final int defaultItemOrder = <NUM_LIT:0> ; private static final int defaultItemCheckable = <NUM_LIT:0> ; private static final boolean defaultItemChecked = false ; private static final boolean defaultItemVisible = true ; private static final boolean defaultItemEnabled = true ; public MenuState ( final Menu menu ) { this . menu = menu ; resetGroup ( ) ; } public void resetGroup ( ) { groupId = defaultGroupId ; groupCategory = defaultItemCategory ; groupOrder = defaultItemOrder ; groupCheckable = defaultItemCheckable ; groupVisible = defaultItemVisible ; groupEnabled = defaultItemEnabled ; } public void readGroup ( AttributeSet attrs ) { TypedArray a = mContext . obtainStyledAttributes ( attrs , R . styleable . SherlockMenuGroup ) ; groupId = a . getResourceId ( R . styleable . SherlockMenuGroup_android_id , defaultGroupId ) ; groupCategory = a . getInt ( R . styleable . SherlockMenuGroup_android_menuCategory , defaultItemCategory ) ; groupOrder = a . getInt ( R . styleable . SherlockMenuGroup_android_orderInCategory , defaultItemOrder ) ; groupCheckable = a . getInt ( R . styleable . SherlockMenuGroup_android_checkableBehavior , defaultItemCheckable ) ; groupVisible = a . getBoolean ( R . styleable . SherlockMenuGroup_android_visible , defaultItemVisible ) ; groupEnabled = a . getBoolean ( R . styleable . SherlockMenuGroup_android_enabled , defaultItemEnabled ) ; a . recycle ( ) ; } public void readItem ( AttributeSet attrs ) { TypedArray a = mContext . obtainStyledAttributes ( attrs , R . styleable . SherlockMenuItem ) ; itemId = a . getResourceId ( R . styleable . SherlockMenuItem_android_id , defaultItemId ) ; final int category = a . getInt ( R . styleable . SherlockMenuItem_android_menuCategory , groupCategory ) ; final int order = a . getInt ( R . styleable . SherlockMenuItem_android_orderInCategory , groupOrder ) ; itemCategoryOrder = ( category & Menu . CATEGORY_MASK ) | ( order & Menu . USER_MASK ) ; itemTitle = a . getText ( R . styleable . SherlockMenuItem_android_title ) ; itemTitleCondensed = a . getText ( R . styleable . SherlockMenuItem_android_titleCondensed ) ; itemIconResId = a . getResourceId ( R . styleable . SherlockMenuItem_android_icon , <NUM_LIT:0> ) ; itemAlphabeticShortcut = getShortcut ( a . getString ( R . styleable . SherlockMenuItem_android_alphabeticShortcut ) ) ; itemNumericShortcut = getShortcut ( a . getString ( R . styleable . SherlockMenuItem_android_numericShortcut ) ) ; if ( a . hasValue ( R . styleable . SherlockMenuItem_android_checkable ) ) { itemCheckable = a . getBoolean ( R . styleable . SherlockMenuItem_android_checkable , false ) ? <NUM_LIT:1> : <NUM_LIT:0> ; } else { itemCheckable = groupCheckable ; } itemChecked = a . getBoolean ( R . styleable . SherlockMenuItem_android_checked , defaultItemChecked ) ; itemVisible = a . getBoolean ( R . styleable . SherlockMenuItem_android_visible , groupVisible ) ; itemEnabled = a . getBoolean ( R . styleable . SherlockMenuItem_android_enabled , groupEnabled ) ; TypedValue value = new TypedValue ( ) ; a . getValue ( R . styleable . SherlockMenuItem_android_showAsAction , value ) ; itemShowAsAction = value . type == TypedValue . TYPE_INT_HEX ? value . data : - <NUM_LIT:1> ; itemListenerMethodName = a . getString ( R . styleable . SherlockMenuItem_android_onClick ) ; itemActionViewLayout = a . getResourceId ( R . styleable . SherlockMenuItem_android_actionLayout , <NUM_LIT:0> ) ; itemActionViewClassName = a . getString ( R . styleable . SherlockMenuItem_android_actionViewClass ) ; itemActionProviderClassName = a . getString ( R . styleable . SherlockMenuItem_android_actionProviderClass ) ; final boolean hasActionProvider = itemActionProviderClassName != null ; if ( hasActionProvider && itemActionViewLayout == <NUM_LIT:0> && itemActionViewClassName == null ) { itemActionProvider = newInstance ( itemActionProviderClassName , ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE , mActionProviderConstructorArguments ) ; } else { if ( hasActionProvider ) { Log . w ( LOG_TAG , "<STR_LIT>" + "<STR_LIT>" ) ; } itemActionProvider = null ; } a . recycle ( ) ; itemAdded = false ; } private char getShortcut ( String shortcutString ) { if ( shortcutString == null ) { return <NUM_LIT:0> ; } else { return shortcutString . charAt ( <NUM_LIT:0> ) ; } } private void setItem ( MenuItem item ) { item . setChecked ( itemChecked ) . setVisible ( itemVisible ) . setEnabled ( itemEnabled ) . setCheckable ( itemCheckable >= <NUM_LIT:1> ) . setTitleCondensed ( itemTitleCondensed ) . setIcon ( itemIconResId ) . setAlphabeticShortcut ( itemAlphabeticShortcut ) . setNumericShortcut ( itemNumericShortcut ) ; if ( itemShowAsAction >= <NUM_LIT:0> ) { item . setShowAsAction ( itemShowAsAction ) ; } if ( itemListenerMethodName != null ) { if ( mContext . isRestricted ( ) ) { throw new IllegalStateException ( "<STR_LIT>" + "<STR_LIT>" ) ; } item . setOnMenuItemClickListener ( new InflatedOnMenuItemClickListener ( mContext , itemListenerMethodName ) ) ; } if ( itemCheckable >= <NUM_LIT:2> ) { if ( item instanceof MenuItemImpl ) { MenuItemImpl impl = ( MenuItemImpl ) item ; impl . setExclusiveCheckable ( true ) ; } else { menu . setGroupCheckable ( groupId , true , true ) ; } } boolean actionViewSpecified = false ; if ( itemActionViewClassName != null ) { View actionView = ( View ) newInstance ( itemActionViewClassName , ACTION_VIEW_CONSTRUCTOR_SIGNATURE , mActionViewConstructorArguments ) ; item . setActionView ( actionView ) ; actionViewSpecified = true ; } if ( itemActionViewLayout > <NUM_LIT:0> ) { if ( ! actionViewSpecified ) { item . setActionView ( itemActionViewLayout ) ; actionViewSpecified = true ; } else { Log . w ( LOG_TAG , "<STR_LIT>" + "<STR_LIT>" ) ; } } if ( itemActionProvider != null ) { item . setActionProvider ( itemActionProvider ) ; } } public void addItem ( ) { itemAdded = true ; setItem ( menu . add ( groupId , itemId , itemCategoryOrder , itemTitle ) ) ; } public SubMenu addSubMenuItem ( ) { itemAdded = true ; SubMenu subMenu = menu . addSubMenu ( groupId , itemId , itemCategoryOrder , itemTitle ) ; setItem ( subMenu . getItem ( ) ) ; return subMenu ; } public boolean hasAddedItem ( ) { return itemAdded ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) private < T > T newInstance ( String className , Class < ? > [ ] constructorSignature , Object [ ] arguments ) { try { Class < ? > clazz = mContext . getClassLoader ( ) . loadClass ( className ) ; Constructor < ? > constructor = clazz . getConstructor ( constructorSignature ) ; return ( T ) constructor . newInstance ( arguments ) ; } catch ( Exception e ) { Log . w ( LOG_TAG , "<STR_LIT>" + className , e ) ; } return null ; } } } </s>
<s> package com . actionbarsherlock . view ; import android . content . Intent ; import android . graphics . drawable . Drawable ; import android . view . ContextMenu . ContextMenuInfo ; import android . view . View ; public interface MenuItem { public static final int SHOW_AS_ACTION_NEVER = android . view . MenuItem . SHOW_AS_ACTION_NEVER ; public static final int SHOW_AS_ACTION_IF_ROOM = android . view . MenuItem . SHOW_AS_ACTION_IF_ROOM ; public static final int SHOW_AS_ACTION_ALWAYS = android . view . MenuItem . SHOW_AS_ACTION_ALWAYS ; public static final int SHOW_AS_ACTION_WITH_TEXT = android . view . MenuItem . SHOW_AS_ACTION_WITH_TEXT ; public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = android . view . MenuItem . SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW ; public interface OnMenuItemClickListener { public boolean onMenuItemClick ( MenuItem item ) ; } public interface OnActionExpandListener { public boolean onMenuItemActionExpand ( MenuItem item ) ; public boolean onMenuItemActionCollapse ( MenuItem item ) ; } public int getItemId ( ) ; public int getGroupId ( ) ; public int getOrder ( ) ; public MenuItem setTitle ( CharSequence title ) ; public MenuItem setTitle ( int title ) ; public CharSequence getTitle ( ) ; public MenuItem setTitleCondensed ( CharSequence title ) ; public CharSequence getTitleCondensed ( ) ; public MenuItem setIcon ( Drawable icon ) ; public MenuItem setIcon ( int iconRes ) ; public Drawable getIcon ( ) ; public MenuItem setIntent ( Intent intent ) ; public Intent getIntent ( ) ; public MenuItem setShortcut ( char numericChar , char alphaChar ) ; public MenuItem setNumericShortcut ( char numericChar ) ; public char getNumericShortcut ( ) ; public MenuItem setAlphabeticShortcut ( char alphaChar ) ; public char getAlphabeticShortcut ( ) ; public MenuItem setCheckable ( boolean checkable ) ; public boolean isCheckable ( ) ; public MenuItem setChecked ( boolean checked ) ; public boolean isChecked ( ) ; public MenuItem setVisible ( boolean visible ) ; public boolean isVisible ( ) ; public MenuItem setEnabled ( boolean enabled ) ; public boolean isEnabled ( ) ; public boolean hasSubMenu ( ) ; public SubMenu getSubMenu ( ) ; public MenuItem setOnMenuItemClickListener ( MenuItem . OnMenuItemClickListener menuItemClickListener ) ; public ContextMenuInfo getMenuInfo ( ) ; public void setShowAsAction ( int actionEnum ) ; public MenuItem setShowAsActionFlags ( int actionEnum ) ; public MenuItem setActionView ( View view ) ; public MenuItem setActionView ( int resId ) ; public View getActionView ( ) ; public MenuItem setActionProvider ( ActionProvider actionProvider ) ; public ActionProvider getActionProvider ( ) ; public boolean expandActionView ( ) ; public boolean collapseActionView ( ) ; public boolean isActionViewExpanded ( ) ; public MenuItem setOnActionExpandListener ( OnActionExpandListener listener ) ; } </s>
<s> package com . actionbarsherlock . view ; public interface CollapsibleActionView { public void onActionViewExpanded ( ) ; public void onActionViewCollapsed ( ) ; } </s>
<s> package com . actionbarsherlock . internal . widget ; import org . xmlpull . v1 . XmlPullParser ; import android . app . Activity ; import android . content . Context ; import android . content . pm . ApplicationInfo ; import android . content . pm . PackageManager ; import android . content . pm . PackageManager . NameNotFoundException ; import android . content . res . AssetManager ; import android . content . res . Configuration ; import android . content . res . TypedArray ; import android . content . res . XmlResourceParser ; import android . graphics . drawable . Drawable ; import android . os . Build ; import android . os . Parcel ; import android . os . Parcelable ; import android . text . TextUtils ; import android . util . AttributeSet ; import android . util . Log ; import android . view . Gravity ; import android . view . LayoutInflater ; import android . view . MotionEvent ; import android . view . View ; import android . view . ViewGroup ; import android . view . ViewParent ; import android . view . accessibility . AccessibilityEvent ; import android . widget . FrameLayout ; import android . widget . ImageView ; import android . widget . LinearLayout ; import android . widget . SpinnerAdapter ; import android . widget . TextView ; import com . actionbarsherlock . R ; import com . actionbarsherlock . app . ActionBar ; import com . actionbarsherlock . app . ActionBar . OnNavigationListener ; import com . actionbarsherlock . internal . ActionBarSherlockCompat ; import com . actionbarsherlock . internal . view . menu . ActionMenuItem ; import com . actionbarsherlock . internal . view . menu . ActionMenuPresenter ; import com . actionbarsherlock . internal . view . menu . ActionMenuView ; import com . actionbarsherlock . internal . view . menu . MenuBuilder ; import com . actionbarsherlock . internal . view . menu . MenuItemImpl ; import com . actionbarsherlock . internal . view . menu . MenuPresenter ; import com . actionbarsherlock . internal . view . menu . MenuView ; import com . actionbarsherlock . internal . view . menu . SubMenuBuilder ; import com . actionbarsherlock . view . CollapsibleActionView ; import com . actionbarsherlock . view . Menu ; import com . actionbarsherlock . view . MenuItem ; import com . actionbarsherlock . view . Window ; import static com . actionbarsherlock . internal . ResourcesCompat . getResources_getBoolean ; public class ActionBarView extends AbsActionBarView { private static final String TAG = "<STR_LIT>" ; private static final boolean DEBUG = false ; public static final int DISPLAY_DEFAULT = <NUM_LIT:0> ; private static final int DISPLAY_RELAYOUT_MASK = ActionBar . DISPLAY_SHOW_HOME | ActionBar . DISPLAY_USE_LOGO | ActionBar . DISPLAY_HOME_AS_UP | ActionBar . DISPLAY_SHOW_CUSTOM | ActionBar . DISPLAY_SHOW_TITLE ; private static final int DEFAULT_CUSTOM_GRAVITY = Gravity . LEFT | Gravity . CENTER_VERTICAL ; private int mNavigationMode ; private int mDisplayOptions = - <NUM_LIT:1> ; private CharSequence mTitle ; private CharSequence mSubtitle ; private Drawable mIcon ; private Drawable mLogo ; private HomeView mHomeLayout ; private HomeView mExpandedHomeLayout ; private LinearLayout mTitleLayout ; private TextView mTitleView ; private TextView mSubtitleView ; private View mTitleUpView ; private IcsSpinner mSpinner ; private IcsLinearLayout mListNavLayout ; private ScrollingTabContainerView mTabScrollView ; private View mCustomNavView ; private IcsProgressBar mProgressView ; private IcsProgressBar mIndeterminateProgressView ; private int mProgressBarPadding ; private int mItemPadding ; private int mTitleStyleRes ; private int mSubtitleStyleRes ; private int mProgressStyle ; private int mIndeterminateProgressStyle ; private boolean mUserTitle ; private boolean mIncludeTabs ; private boolean mIsCollapsable ; private boolean mIsCollapsed ; private MenuBuilder mOptionsMenu ; private ActionBarContextView mContextView ; private ActionMenuItem mLogoNavItem ; private SpinnerAdapter mSpinnerAdapter ; private OnNavigationListener mCallback ; private ExpandedActionViewMenuPresenter mExpandedMenuPresenter ; View mExpandedActionView ; Window . Callback mWindowCallback ; @ SuppressWarnings ( "<STR_LIT:rawtypes>" ) private final IcsAdapterView . OnItemSelectedListener mNavItemSelectedListener = new IcsAdapterView . OnItemSelectedListener ( ) { public void onItemSelected ( IcsAdapterView parent , View view , int position , long id ) { if ( mCallback != null ) { mCallback . onNavigationItemSelected ( position , id ) ; } } public void onNothingSelected ( IcsAdapterView parent ) { } } ; private final OnClickListener mExpandedActionViewUpListener = new OnClickListener ( ) { @ Override public void onClick ( View v ) { final MenuItemImpl item = mExpandedMenuPresenter . mCurrentExpandedItem ; if ( item != null ) { item . collapseActionView ( ) ; } } } ; private final OnClickListener mUpClickListener = new OnClickListener ( ) { public void onClick ( View v ) { mWindowCallback . onMenuItemSelected ( Window . FEATURE_OPTIONS_PANEL , mLogoNavItem ) ; } } ; public ActionBarView ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; setBackgroundResource ( <NUM_LIT:0> ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . SherlockActionBar , R . attr . actionBarStyle , <NUM_LIT:0> ) ; ApplicationInfo appInfo = context . getApplicationInfo ( ) ; PackageManager pm = context . getPackageManager ( ) ; mNavigationMode = a . getInt ( R . styleable . SherlockActionBar_navigationMode , ActionBar . NAVIGATION_MODE_STANDARD ) ; mTitle = a . getText ( R . styleable . SherlockActionBar_title ) ; mSubtitle = a . getText ( R . styleable . SherlockActionBar_subtitle ) ; mLogo = a . getDrawable ( R . styleable . SherlockActionBar_logo ) ; if ( mLogo == null ) { if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . HONEYCOMB ) { if ( context instanceof Activity ) { final int resId = loadLogoFromManifest ( ( Activity ) context ) ; if ( resId != <NUM_LIT:0> ) { mLogo = context . getResources ( ) . getDrawable ( resId ) ; } } } else { if ( context instanceof Activity ) { try { mLogo = pm . getActivityLogo ( ( ( Activity ) context ) . getComponentName ( ) ) ; } catch ( NameNotFoundException e ) { Log . e ( TAG , "<STR_LIT>" , e ) ; } } if ( mLogo == null ) { mLogo = appInfo . loadLogo ( pm ) ; } } } mIcon = a . getDrawable ( R . styleable . SherlockActionBar_icon ) ; if ( mIcon == null ) { if ( context instanceof Activity ) { try { mIcon = pm . getActivityIcon ( ( ( Activity ) context ) . getComponentName ( ) ) ; } catch ( NameNotFoundException e ) { Log . e ( TAG , "<STR_LIT>" , e ) ; } } if ( mIcon == null ) { mIcon = appInfo . loadIcon ( pm ) ; } } final LayoutInflater inflater = LayoutInflater . from ( context ) ; final int homeResId = a . getResourceId ( R . styleable . SherlockActionBar_homeLayout , R . layout . abs__action_bar_home ) ; mHomeLayout = ( HomeView ) inflater . inflate ( homeResId , this , false ) ; mExpandedHomeLayout = ( HomeView ) inflater . inflate ( homeResId , this , false ) ; mExpandedHomeLayout . setUp ( true ) ; mExpandedHomeLayout . setOnClickListener ( mExpandedActionViewUpListener ) ; mExpandedHomeLayout . setContentDescription ( getResources ( ) . getText ( R . string . abs__action_bar_up_description ) ) ; mTitleStyleRes = a . getResourceId ( R . styleable . SherlockActionBar_titleTextStyle , <NUM_LIT:0> ) ; mSubtitleStyleRes = a . getResourceId ( R . styleable . SherlockActionBar_subtitleTextStyle , <NUM_LIT:0> ) ; mProgressStyle = a . getResourceId ( R . styleable . SherlockActionBar_progressBarStyle , <NUM_LIT:0> ) ; mIndeterminateProgressStyle = a . getResourceId ( R . styleable . SherlockActionBar_indeterminateProgressStyle , <NUM_LIT:0> ) ; mProgressBarPadding = a . getDimensionPixelOffset ( R . styleable . SherlockActionBar_progressBarPadding , <NUM_LIT:0> ) ; mItemPadding = a . getDimensionPixelOffset ( R . styleable . SherlockActionBar_itemPadding , <NUM_LIT:0> ) ; setDisplayOptions ( a . getInt ( R . styleable . SherlockActionBar_displayOptions , DISPLAY_DEFAULT ) ) ; final int customNavId = a . getResourceId ( R . styleable . SherlockActionBar_customNavigationLayout , <NUM_LIT:0> ) ; if ( customNavId != <NUM_LIT:0> ) { mCustomNavView = inflater . inflate ( customNavId , this , false ) ; mNavigationMode = ActionBar . NAVIGATION_MODE_STANDARD ; setDisplayOptions ( mDisplayOptions | ActionBar . DISPLAY_SHOW_CUSTOM ) ; } mContentHeight = a . getLayoutDimension ( R . styleable . SherlockActionBar_height , <NUM_LIT:0> ) ; a . recycle ( ) ; mLogoNavItem = new ActionMenuItem ( context , <NUM_LIT:0> , android . R . id . home , <NUM_LIT:0> , <NUM_LIT:0> , mTitle ) ; mHomeLayout . setOnClickListener ( mUpClickListener ) ; mHomeLayout . setClickable ( true ) ; mHomeLayout . setFocusable ( true ) ; } private static int loadLogoFromManifest ( Activity activity ) { int logo = <NUM_LIT:0> ; try { final String thisPackage = activity . getClass ( ) . getName ( ) ; if ( DEBUG ) Log . i ( TAG , "<STR_LIT>" + thisPackage ) ; final String packageName = activity . getApplicationInfo ( ) . packageName ; final AssetManager am = activity . createPackageContext ( packageName , <NUM_LIT:0> ) . getAssets ( ) ; final XmlResourceParser xml = am . openXmlResourceParser ( "<STR_LIT>" ) ; int eventType = xml . getEventType ( ) ; while ( eventType != XmlPullParser . END_DOCUMENT ) { if ( eventType == XmlPullParser . START_TAG ) { String name = xml . getName ( ) ; if ( "<STR_LIT>" . equals ( name ) ) { if ( DEBUG ) Log . d ( TAG , "<STR_LIT>" ) ; for ( int i = xml . getAttributeCount ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { if ( DEBUG ) Log . d ( TAG , xml . getAttributeName ( i ) + "<STR_LIT::U+0020>" + xml . getAttributeValue ( i ) ) ; if ( "<STR_LIT>" . equals ( xml . getAttributeName ( i ) ) ) { logo = xml . getAttributeResourceValue ( i , <NUM_LIT:0> ) ; break ; } } } else if ( "<STR_LIT>" . equals ( name ) ) { if ( DEBUG ) Log . d ( TAG , "<STR_LIT>" ) ; Integer activityLogo = null ; String activityPackage = null ; boolean isOurActivity = false ; for ( int i = xml . getAttributeCount ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { if ( DEBUG ) Log . d ( TAG , xml . getAttributeName ( i ) + "<STR_LIT::U+0020>" + xml . getAttributeValue ( i ) ) ; String attrName = xml . getAttributeName ( i ) ; if ( "<STR_LIT>" . equals ( attrName ) ) { activityLogo = xml . getAttributeResourceValue ( i , <NUM_LIT:0> ) ; } else if ( "<STR_LIT:name>" . equals ( attrName ) ) { activityPackage = ActionBarSherlockCompat . cleanActivityName ( packageName , xml . getAttributeValue ( i ) ) ; if ( ! thisPackage . equals ( activityPackage ) ) { break ; } isOurActivity = true ; } if ( ( activityLogo != null ) && ( activityPackage != null ) ) { logo = activityLogo . intValue ( ) ; } } if ( isOurActivity ) { break ; } } } eventType = xml . nextToken ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } if ( DEBUG ) Log . i ( TAG , "<STR_LIT>" + Integer . toHexString ( logo ) ) ; return logo ; } @ Override public void onConfigurationChanged ( Configuration newConfig ) { super . onConfigurationChanged ( newConfig ) ; mTitleView = null ; mSubtitleView = null ; mTitleUpView = null ; if ( mTitleLayout != null && mTitleLayout . getParent ( ) == this ) { removeView ( mTitleLayout ) ; } mTitleLayout = null ; if ( ( mDisplayOptions & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> ) { initTitle ( ) ; } if ( mTabScrollView != null && mIncludeTabs ) { ViewGroup . LayoutParams lp = mTabScrollView . getLayoutParams ( ) ; if ( lp != null ) { lp . width = LayoutParams . WRAP_CONTENT ; lp . height = LayoutParams . MATCH_PARENT ; } mTabScrollView . setAllowCollapse ( true ) ; } } public void setWindowCallback ( Window . Callback cb ) { mWindowCallback = cb ; } @ Override public void onDetachedFromWindow ( ) { super . onDetachedFromWindow ( ) ; if ( mActionMenuPresenter != null ) { mActionMenuPresenter . hideOverflowMenu ( ) ; mActionMenuPresenter . hideSubMenus ( ) ; } } @ Override public boolean shouldDelayChildPressedState ( ) { return false ; } public void initProgress ( ) { mProgressView = new IcsProgressBar ( mContext , null , <NUM_LIT:0> , mProgressStyle ) ; mProgressView . setId ( R . id . abs__progress_horizontal ) ; mProgressView . setMax ( <NUM_LIT> ) ; addView ( mProgressView ) ; } public void initIndeterminateProgress ( ) { mIndeterminateProgressView = new IcsProgressBar ( mContext , null , <NUM_LIT:0> , mIndeterminateProgressStyle ) ; mIndeterminateProgressView . setId ( R . id . abs__progress_circular ) ; addView ( mIndeterminateProgressView ) ; } @ Override public void setSplitActionBar ( boolean splitActionBar ) { if ( mSplitActionBar != splitActionBar ) { if ( mMenuView != null ) { final ViewGroup oldParent = ( ViewGroup ) mMenuView . getParent ( ) ; if ( oldParent != null ) { oldParent . removeView ( mMenuView ) ; } if ( splitActionBar ) { if ( mSplitView != null ) { mSplitView . addView ( mMenuView ) ; } } else { addView ( mMenuView ) ; } } if ( mSplitView != null ) { mSplitView . setVisibility ( splitActionBar ? VISIBLE : GONE ) ; } super . setSplitActionBar ( splitActionBar ) ; } } public boolean isSplitActionBar ( ) { return mSplitActionBar ; } public boolean hasEmbeddedTabs ( ) { return mIncludeTabs ; } public void setEmbeddedTabView ( ScrollingTabContainerView tabs ) { if ( mTabScrollView != null ) { removeView ( mTabScrollView ) ; } mTabScrollView = tabs ; mIncludeTabs = tabs != null ; if ( mIncludeTabs && mNavigationMode == ActionBar . NAVIGATION_MODE_TABS ) { addView ( mTabScrollView ) ; ViewGroup . LayoutParams lp = mTabScrollView . getLayoutParams ( ) ; lp . width = LayoutParams . WRAP_CONTENT ; lp . height = LayoutParams . MATCH_PARENT ; tabs . setAllowCollapse ( true ) ; } } public void setCallback ( OnNavigationListener callback ) { mCallback = callback ; } public void setMenu ( Menu menu , MenuPresenter . Callback cb ) { if ( menu == mOptionsMenu ) return ; if ( mOptionsMenu != null ) { mOptionsMenu . removeMenuPresenter ( mActionMenuPresenter ) ; mOptionsMenu . removeMenuPresenter ( mExpandedMenuPresenter ) ; } MenuBuilder builder = ( MenuBuilder ) menu ; mOptionsMenu = builder ; if ( mMenuView != null ) { final ViewGroup oldParent = ( ViewGroup ) mMenuView . getParent ( ) ; if ( oldParent != null ) { oldParent . removeView ( mMenuView ) ; } } if ( mActionMenuPresenter == null ) { mActionMenuPresenter = new ActionMenuPresenter ( mContext ) ; mActionMenuPresenter . setCallback ( cb ) ; mActionMenuPresenter . setId ( R . id . abs__action_menu_presenter ) ; mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter ( ) ; } ActionMenuView menuView ; final LayoutParams layoutParams = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . MATCH_PARENT ) ; if ( ! mSplitActionBar ) { mActionMenuPresenter . setExpandedActionViewsExclusive ( getResources_getBoolean ( getContext ( ) , R . bool . abs__action_bar_expanded_action_views_exclusive ) ) ; configPresenters ( builder ) ; menuView = ( ActionMenuView ) mActionMenuPresenter . getMenuView ( this ) ; final ViewGroup oldParent = ( ViewGroup ) menuView . getParent ( ) ; if ( oldParent != null && oldParent != this ) { oldParent . removeView ( menuView ) ; } addView ( menuView , layoutParams ) ; } else { mActionMenuPresenter . setExpandedActionViewsExclusive ( false ) ; mActionMenuPresenter . setWidthLimit ( getContext ( ) . getResources ( ) . getDisplayMetrics ( ) . widthPixels , true ) ; mActionMenuPresenter . setItemLimit ( Integer . MAX_VALUE ) ; layoutParams . width = LayoutParams . MATCH_PARENT ; configPresenters ( builder ) ; menuView = ( ActionMenuView ) mActionMenuPresenter . getMenuView ( this ) ; if ( mSplitView != null ) { final ViewGroup oldParent = ( ViewGroup ) menuView . getParent ( ) ; if ( oldParent != null && oldParent != mSplitView ) { oldParent . removeView ( menuView ) ; } menuView . setVisibility ( getAnimatedVisibility ( ) ) ; mSplitView . addView ( menuView , layoutParams ) ; } else { menuView . setLayoutParams ( layoutParams ) ; } } mMenuView = menuView ; } private void configPresenters ( MenuBuilder builder ) { if ( builder != null ) { builder . addMenuPresenter ( mActionMenuPresenter ) ; builder . addMenuPresenter ( mExpandedMenuPresenter ) ; } else { mActionMenuPresenter . initForMenu ( mContext , null ) ; mExpandedMenuPresenter . initForMenu ( mContext , null ) ; mActionMenuPresenter . updateMenuView ( true ) ; mExpandedMenuPresenter . updateMenuView ( true ) ; } } public boolean hasExpandedActionView ( ) { return mExpandedMenuPresenter != null && mExpandedMenuPresenter . mCurrentExpandedItem != null ; } public void collapseActionView ( ) { final MenuItemImpl item = mExpandedMenuPresenter == null ? null : mExpandedMenuPresenter . mCurrentExpandedItem ; if ( item != null ) { item . collapseActionView ( ) ; } } public void setCustomNavigationView ( View view ) { final boolean showCustom = ( mDisplayOptions & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> ; if ( mCustomNavView != null && showCustom ) { removeView ( mCustomNavView ) ; } mCustomNavView = view ; if ( mCustomNavView != null && showCustom ) { addView ( mCustomNavView ) ; } } public CharSequence getTitle ( ) { return mTitle ; } public void setTitle ( CharSequence title ) { mUserTitle = true ; setTitleImpl ( title ) ; } public void setWindowTitle ( CharSequence title ) { if ( ! mUserTitle ) { setTitleImpl ( title ) ; } } private void setTitleImpl ( CharSequence title ) { mTitle = title ; if ( mTitleView != null ) { mTitleView . setText ( title ) ; final boolean visible = mExpandedActionView == null && ( mDisplayOptions & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> && ( ! TextUtils . isEmpty ( mTitle ) || ! TextUtils . isEmpty ( mSubtitle ) ) ; mTitleLayout . setVisibility ( visible ? VISIBLE : GONE ) ; } if ( mLogoNavItem != null ) { mLogoNavItem . setTitle ( title ) ; } } public CharSequence getSubtitle ( ) { return mSubtitle ; } public void setSubtitle ( CharSequence subtitle ) { mSubtitle = subtitle ; if ( mSubtitleView != null ) { mSubtitleView . setText ( subtitle ) ; mSubtitleView . setVisibility ( subtitle != null ? VISIBLE : GONE ) ; final boolean visible = mExpandedActionView == null && ( mDisplayOptions & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> && ( ! TextUtils . isEmpty ( mTitle ) || ! TextUtils . isEmpty ( mSubtitle ) ) ; mTitleLayout . setVisibility ( visible ? VISIBLE : GONE ) ; } } public void setHomeButtonEnabled ( boolean enable ) { mHomeLayout . setEnabled ( enable ) ; mHomeLayout . setFocusable ( enable ) ; if ( ! enable ) { mHomeLayout . setContentDescription ( null ) ; } else if ( ( mDisplayOptions & ActionBar . DISPLAY_HOME_AS_UP ) != <NUM_LIT:0> ) { mHomeLayout . setContentDescription ( mContext . getResources ( ) . getText ( R . string . abs__action_bar_up_description ) ) ; } else { mHomeLayout . setContentDescription ( mContext . getResources ( ) . getText ( R . string . abs__action_bar_home_description ) ) ; } } public void setDisplayOptions ( int options ) { final int flagsChanged = mDisplayOptions == - <NUM_LIT:1> ? - <NUM_LIT:1> : options ^ mDisplayOptions ; mDisplayOptions = options ; if ( ( flagsChanged & DISPLAY_RELAYOUT_MASK ) != <NUM_LIT:0> ) { final boolean showHome = ( options & ActionBar . DISPLAY_SHOW_HOME ) != <NUM_LIT:0> ; final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE ; mHomeLayout . setVisibility ( vis ) ; if ( ( flagsChanged & ActionBar . DISPLAY_HOME_AS_UP ) != <NUM_LIT:0> ) { final boolean setUp = ( options & ActionBar . DISPLAY_HOME_AS_UP ) != <NUM_LIT:0> ; mHomeLayout . setUp ( setUp ) ; if ( setUp ) { setHomeButtonEnabled ( true ) ; } } if ( ( flagsChanged & ActionBar . DISPLAY_USE_LOGO ) != <NUM_LIT:0> ) { final boolean logoVis = mLogo != null && ( options & ActionBar . DISPLAY_USE_LOGO ) != <NUM_LIT:0> ; mHomeLayout . setIcon ( logoVis ? mLogo : mIcon ) ; } if ( ( flagsChanged & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> ) { if ( ( options & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> ) { initTitle ( ) ; } else { removeView ( mTitleLayout ) ; } } if ( mTitleLayout != null && ( flagsChanged & ( ActionBar . DISPLAY_HOME_AS_UP | ActionBar . DISPLAY_SHOW_HOME ) ) != <NUM_LIT:0> ) { final boolean homeAsUp = ( mDisplayOptions & ActionBar . DISPLAY_HOME_AS_UP ) != <NUM_LIT:0> ; mTitleUpView . setVisibility ( ! showHome ? ( homeAsUp ? VISIBLE : INVISIBLE ) : GONE ) ; mTitleLayout . setEnabled ( ! showHome && homeAsUp ) ; } if ( ( flagsChanged & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> && mCustomNavView != null ) { if ( ( options & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> ) { addView ( mCustomNavView ) ; } else { removeView ( mCustomNavView ) ; } } requestLayout ( ) ; } else { invalidate ( ) ; } if ( ! mHomeLayout . isEnabled ( ) ) { mHomeLayout . setContentDescription ( null ) ; } else if ( ( options & ActionBar . DISPLAY_HOME_AS_UP ) != <NUM_LIT:0> ) { mHomeLayout . setContentDescription ( mContext . getResources ( ) . getText ( R . string . abs__action_bar_up_description ) ) ; } else { mHomeLayout . setContentDescription ( mContext . getResources ( ) . getText ( R . string . abs__action_bar_home_description ) ) ; } } public void setIcon ( Drawable icon ) { mIcon = icon ; if ( icon != null && ( ( mDisplayOptions & ActionBar . DISPLAY_USE_LOGO ) == <NUM_LIT:0> || mLogo == null ) ) { mHomeLayout . setIcon ( icon ) ; } } public void setIcon ( int resId ) { setIcon ( mContext . getResources ( ) . getDrawable ( resId ) ) ; } public void setLogo ( Drawable logo ) { mLogo = logo ; if ( logo != null && ( mDisplayOptions & ActionBar . DISPLAY_USE_LOGO ) != <NUM_LIT:0> ) { mHomeLayout . setIcon ( logo ) ; } } public void setLogo ( int resId ) { setLogo ( mContext . getResources ( ) . getDrawable ( resId ) ) ; } public void setNavigationMode ( int mode ) { final int oldMode = mNavigationMode ; if ( mode != oldMode ) { switch ( oldMode ) { case ActionBar . NAVIGATION_MODE_LIST : if ( mListNavLayout != null ) { removeView ( mListNavLayout ) ; } break ; case ActionBar . NAVIGATION_MODE_TABS : if ( mTabScrollView != null && mIncludeTabs ) { removeView ( mTabScrollView ) ; } } switch ( mode ) { case ActionBar . NAVIGATION_MODE_LIST : if ( mSpinner == null ) { mSpinner = new IcsSpinner ( mContext , null , R . attr . actionDropDownStyle ) ; mListNavLayout = ( IcsLinearLayout ) LayoutInflater . from ( mContext ) . inflate ( R . layout . abs__action_bar_tab_bar_view , null ) ; LinearLayout . LayoutParams params = new LinearLayout . LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . MATCH_PARENT ) ; params . gravity = Gravity . CENTER ; mListNavLayout . addView ( mSpinner , params ) ; } if ( mSpinner . getAdapter ( ) != mSpinnerAdapter ) { mSpinner . setAdapter ( mSpinnerAdapter ) ; } mSpinner . setOnItemSelectedListener ( mNavItemSelectedListener ) ; addView ( mListNavLayout ) ; break ; case ActionBar . NAVIGATION_MODE_TABS : if ( mTabScrollView != null && mIncludeTabs ) { addView ( mTabScrollView ) ; } break ; } mNavigationMode = mode ; requestLayout ( ) ; } } public void setDropdownAdapter ( SpinnerAdapter adapter ) { mSpinnerAdapter = adapter ; if ( mSpinner != null ) { mSpinner . setAdapter ( adapter ) ; } } public SpinnerAdapter getDropdownAdapter ( ) { return mSpinnerAdapter ; } public void setDropdownSelectedPosition ( int position ) { mSpinner . setSelection ( position ) ; } public int getDropdownSelectedPosition ( ) { return mSpinner . getSelectedItemPosition ( ) ; } public View getCustomNavigationView ( ) { return mCustomNavView ; } public int getNavigationMode ( ) { return mNavigationMode ; } public int getDisplayOptions ( ) { return mDisplayOptions ; } @ Override protected ViewGroup . LayoutParams generateDefaultLayoutParams ( ) { return new ActionBar . LayoutParams ( DEFAULT_CUSTOM_GRAVITY ) ; } @ Override protected void onFinishInflate ( ) { super . onFinishInflate ( ) ; addView ( mHomeLayout ) ; if ( mCustomNavView != null && ( mDisplayOptions & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> ) { final ViewParent parent = mCustomNavView . getParent ( ) ; if ( parent != this ) { if ( parent instanceof ViewGroup ) { ( ( ViewGroup ) parent ) . removeView ( mCustomNavView ) ; } addView ( mCustomNavView ) ; } } } private void initTitle ( ) { if ( mTitleLayout == null ) { LayoutInflater inflater = LayoutInflater . from ( getContext ( ) ) ; mTitleLayout = ( LinearLayout ) inflater . inflate ( R . layout . abs__action_bar_title_item , this , false ) ; mTitleView = ( TextView ) mTitleLayout . findViewById ( R . id . abs__action_bar_title ) ; mSubtitleView = ( TextView ) mTitleLayout . findViewById ( R . id . abs__action_bar_subtitle ) ; mTitleUpView = mTitleLayout . findViewById ( R . id . abs__up ) ; mTitleLayout . setOnClickListener ( mUpClickListener ) ; if ( mTitleStyleRes != <NUM_LIT:0> ) { mTitleView . setTextAppearance ( mContext , mTitleStyleRes ) ; } if ( mTitle != null ) { mTitleView . setText ( mTitle ) ; } if ( mSubtitleStyleRes != <NUM_LIT:0> ) { mSubtitleView . setTextAppearance ( mContext , mSubtitleStyleRes ) ; } if ( mSubtitle != null ) { mSubtitleView . setText ( mSubtitle ) ; mSubtitleView . setVisibility ( VISIBLE ) ; } final boolean homeAsUp = ( mDisplayOptions & ActionBar . DISPLAY_HOME_AS_UP ) != <NUM_LIT:0> ; final boolean showHome = ( mDisplayOptions & ActionBar . DISPLAY_SHOW_HOME ) != <NUM_LIT:0> ; mTitleUpView . setVisibility ( ! showHome ? ( homeAsUp ? VISIBLE : INVISIBLE ) : GONE ) ; mTitleLayout . setEnabled ( homeAsUp && ! showHome ) ; } addView ( mTitleLayout ) ; if ( mExpandedActionView != null || ( TextUtils . isEmpty ( mTitle ) && TextUtils . isEmpty ( mSubtitle ) ) ) { mTitleLayout . setVisibility ( GONE ) ; } } public void setContextView ( ActionBarContextView view ) { mContextView = view ; } public void setCollapsable ( boolean collapsable ) { mIsCollapsable = collapsable ; } public boolean isCollapsed ( ) { return mIsCollapsed ; } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { final int childCount = getChildCount ( ) ; if ( mIsCollapsable ) { int visibleChildren = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; if ( child . getVisibility ( ) != GONE && ! ( child == mMenuView && mMenuView . getChildCount ( ) == <NUM_LIT:0> ) ) { visibleChildren ++ ; } } if ( visibleChildren == <NUM_LIT:0> ) { setMeasuredDimension ( <NUM_LIT:0> , <NUM_LIT:0> ) ; mIsCollapsed = true ; return ; } } mIsCollapsed = false ; int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; if ( widthMode != MeasureSpec . EXACTLY ) { throw new IllegalStateException ( getClass ( ) . getSimpleName ( ) + "<STR_LIT>" + "<STR_LIT>" ) ; } int heightMode = MeasureSpec . getMode ( heightMeasureSpec ) ; if ( heightMode != MeasureSpec . AT_MOST ) { throw new IllegalStateException ( getClass ( ) . getSimpleName ( ) + "<STR_LIT>" + "<STR_LIT>" ) ; } int contentWidth = MeasureSpec . getSize ( widthMeasureSpec ) ; int maxHeight = mContentHeight > <NUM_LIT:0> ? mContentHeight : MeasureSpec . getSize ( heightMeasureSpec ) ; final int verticalPadding = getPaddingTop ( ) + getPaddingBottom ( ) ; final int paddingLeft = getPaddingLeft ( ) ; final int paddingRight = getPaddingRight ( ) ; final int height = maxHeight - verticalPadding ; final int childSpecHeight = MeasureSpec . makeMeasureSpec ( height , MeasureSpec . AT_MOST ) ; int availableWidth = contentWidth - paddingLeft - paddingRight ; int leftOfCenter = availableWidth / <NUM_LIT:2> ; int rightOfCenter = leftOfCenter ; HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout ; if ( homeLayout . getVisibility ( ) != GONE ) { final ViewGroup . LayoutParams lp = homeLayout . getLayoutParams ( ) ; int homeWidthSpec ; if ( lp . width < <NUM_LIT:0> ) { homeWidthSpec = MeasureSpec . makeMeasureSpec ( availableWidth , MeasureSpec . AT_MOST ) ; } else { homeWidthSpec = MeasureSpec . makeMeasureSpec ( lp . width , MeasureSpec . EXACTLY ) ; } homeLayout . measure ( homeWidthSpec , MeasureSpec . makeMeasureSpec ( height , MeasureSpec . EXACTLY ) ) ; final int homeWidth = homeLayout . getMeasuredWidth ( ) + homeLayout . getLeftOffset ( ) ; availableWidth = Math . max ( <NUM_LIT:0> , availableWidth - homeWidth ) ; leftOfCenter = Math . max ( <NUM_LIT:0> , availableWidth - homeWidth ) ; } if ( mMenuView != null && mMenuView . getParent ( ) == this ) { availableWidth = measureChildView ( mMenuView , availableWidth , childSpecHeight , <NUM_LIT:0> ) ; rightOfCenter = Math . max ( <NUM_LIT:0> , rightOfCenter - mMenuView . getMeasuredWidth ( ) ) ; } if ( mIndeterminateProgressView != null && mIndeterminateProgressView . getVisibility ( ) != GONE ) { availableWidth = measureChildView ( mIndeterminateProgressView , availableWidth , childSpecHeight , <NUM_LIT:0> ) ; rightOfCenter = Math . max ( <NUM_LIT:0> , rightOfCenter - mIndeterminateProgressView . getMeasuredWidth ( ) ) ; } final boolean showTitle = mTitleLayout != null && mTitleLayout . getVisibility ( ) != GONE && ( mDisplayOptions & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> ; if ( mExpandedActionView == null ) { switch ( mNavigationMode ) { case ActionBar . NAVIGATION_MODE_LIST : if ( mListNavLayout != null ) { final int itemPaddingSize = showTitle ? mItemPadding * <NUM_LIT:2> : mItemPadding ; availableWidth = Math . max ( <NUM_LIT:0> , availableWidth - itemPaddingSize ) ; leftOfCenter = Math . max ( <NUM_LIT:0> , leftOfCenter - itemPaddingSize ) ; mListNavLayout . measure ( MeasureSpec . makeMeasureSpec ( availableWidth , MeasureSpec . AT_MOST ) , MeasureSpec . makeMeasureSpec ( height , MeasureSpec . EXACTLY ) ) ; final int listNavWidth = mListNavLayout . getMeasuredWidth ( ) ; availableWidth = Math . max ( <NUM_LIT:0> , availableWidth - listNavWidth ) ; leftOfCenter = Math . max ( <NUM_LIT:0> , leftOfCenter - listNavWidth ) ; } break ; case ActionBar . NAVIGATION_MODE_TABS : if ( mTabScrollView != null ) { final int itemPaddingSize = showTitle ? mItemPadding * <NUM_LIT:2> : mItemPadding ; availableWidth = Math . max ( <NUM_LIT:0> , availableWidth - itemPaddingSize ) ; leftOfCenter = Math . max ( <NUM_LIT:0> , leftOfCenter - itemPaddingSize ) ; mTabScrollView . measure ( MeasureSpec . makeMeasureSpec ( availableWidth , MeasureSpec . AT_MOST ) , MeasureSpec . makeMeasureSpec ( height , MeasureSpec . EXACTLY ) ) ; final int tabWidth = mTabScrollView . getMeasuredWidth ( ) ; availableWidth = Math . max ( <NUM_LIT:0> , availableWidth - tabWidth ) ; leftOfCenter = Math . max ( <NUM_LIT:0> , leftOfCenter - tabWidth ) ; } break ; } } View customView = null ; if ( mExpandedActionView != null ) { customView = mExpandedActionView ; } else if ( ( mDisplayOptions & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> && mCustomNavView != null ) { customView = mCustomNavView ; } if ( customView != null ) { final ViewGroup . LayoutParams lp = generateLayoutParams ( customView . getLayoutParams ( ) ) ; final ActionBar . LayoutParams ablp = lp instanceof ActionBar . LayoutParams ? ( ActionBar . LayoutParams ) lp : null ; int horizontalMargin = <NUM_LIT:0> ; int verticalMargin = <NUM_LIT:0> ; if ( ablp != null ) { horizontalMargin = ablp . leftMargin + ablp . rightMargin ; verticalMargin = ablp . topMargin + ablp . bottomMargin ; } int customNavHeightMode ; if ( mContentHeight <= <NUM_LIT:0> ) { customNavHeightMode = MeasureSpec . AT_MOST ; } else { customNavHeightMode = lp . height != LayoutParams . WRAP_CONTENT ? MeasureSpec . EXACTLY : MeasureSpec . AT_MOST ; } final int customNavHeight = Math . max ( <NUM_LIT:0> , ( lp . height >= <NUM_LIT:0> ? Math . min ( lp . height , height ) : height ) - verticalMargin ) ; final int customNavWidthMode = lp . width != LayoutParams . WRAP_CONTENT ? MeasureSpec . EXACTLY : MeasureSpec . AT_MOST ; int customNavWidth = Math . max ( <NUM_LIT:0> , ( lp . width >= <NUM_LIT:0> ? Math . min ( lp . width , availableWidth ) : availableWidth ) - horizontalMargin ) ; final int hgrav = ( ablp != null ? ablp . gravity : DEFAULT_CUSTOM_GRAVITY ) & Gravity . HORIZONTAL_GRAVITY_MASK ; if ( hgrav == Gravity . CENTER_HORIZONTAL && lp . width == LayoutParams . MATCH_PARENT ) { customNavWidth = Math . min ( leftOfCenter , rightOfCenter ) * <NUM_LIT:2> ; } customView . measure ( MeasureSpec . makeMeasureSpec ( customNavWidth , customNavWidthMode ) , MeasureSpec . makeMeasureSpec ( customNavHeight , customNavHeightMode ) ) ; availableWidth -= horizontalMargin + customView . getMeasuredWidth ( ) ; } if ( mExpandedActionView == null && showTitle ) { availableWidth = measureChildView ( mTitleLayout , availableWidth , MeasureSpec . makeMeasureSpec ( mContentHeight , MeasureSpec . EXACTLY ) , <NUM_LIT:0> ) ; leftOfCenter = Math . max ( <NUM_LIT:0> , leftOfCenter - mTitleLayout . getMeasuredWidth ( ) ) ; } if ( mContentHeight <= <NUM_LIT:0> ) { int measuredHeight = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < childCount ; i ++ ) { View v = getChildAt ( i ) ; int paddedViewHeight = v . getMeasuredHeight ( ) + verticalPadding ; if ( paddedViewHeight > measuredHeight ) { measuredHeight = paddedViewHeight ; } } setMeasuredDimension ( contentWidth , measuredHeight ) ; } else { setMeasuredDimension ( contentWidth , maxHeight ) ; } if ( mContextView != null ) { mContextView . setContentHeight ( getMeasuredHeight ( ) ) ; } if ( mProgressView != null && mProgressView . getVisibility ( ) != GONE ) { mProgressView . measure ( MeasureSpec . makeMeasureSpec ( contentWidth - mProgressBarPadding * <NUM_LIT:2> , MeasureSpec . EXACTLY ) , MeasureSpec . makeMeasureSpec ( getMeasuredHeight ( ) , MeasureSpec . AT_MOST ) ) ; } } @ Override protected void onLayout ( boolean changed , int l , int t , int r , int b ) { int x = getPaddingLeft ( ) ; final int y = getPaddingTop ( ) ; final int contentHeight = b - t - getPaddingTop ( ) - getPaddingBottom ( ) ; if ( contentHeight <= <NUM_LIT:0> ) { return ; } HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout ; if ( homeLayout . getVisibility ( ) != GONE ) { final int leftOffset = homeLayout . getLeftOffset ( ) ; x += positionChild ( homeLayout , x + leftOffset , y , contentHeight ) + leftOffset ; } if ( mExpandedActionView == null ) { final boolean showTitle = mTitleLayout != null && mTitleLayout . getVisibility ( ) != GONE && ( mDisplayOptions & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> ; if ( showTitle ) { x += positionChild ( mTitleLayout , x , y , contentHeight ) ; } switch ( mNavigationMode ) { case ActionBar . NAVIGATION_MODE_STANDARD : break ; case ActionBar . NAVIGATION_MODE_LIST : if ( mListNavLayout != null ) { if ( showTitle ) x += mItemPadding ; x += positionChild ( mListNavLayout , x , y , contentHeight ) + mItemPadding ; } break ; case ActionBar . NAVIGATION_MODE_TABS : if ( mTabScrollView != null ) { if ( showTitle ) x += mItemPadding ; x += positionChild ( mTabScrollView , x , y , contentHeight ) + mItemPadding ; } break ; } } int menuLeft = r - l - getPaddingRight ( ) ; if ( mMenuView != null && mMenuView . getParent ( ) == this ) { positionChildInverse ( mMenuView , menuLeft , y , contentHeight ) ; menuLeft -= mMenuView . getMeasuredWidth ( ) ; } if ( mIndeterminateProgressView != null && mIndeterminateProgressView . getVisibility ( ) != GONE ) { positionChildInverse ( mIndeterminateProgressView , menuLeft , y , contentHeight ) ; menuLeft -= mIndeterminateProgressView . getMeasuredWidth ( ) ; } View customView = null ; if ( mExpandedActionView != null ) { customView = mExpandedActionView ; } else if ( ( mDisplayOptions & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> && mCustomNavView != null ) { customView = mCustomNavView ; } if ( customView != null ) { ViewGroup . LayoutParams lp = customView . getLayoutParams ( ) ; final ActionBar . LayoutParams ablp = lp instanceof ActionBar . LayoutParams ? ( ActionBar . LayoutParams ) lp : null ; final int gravity = ablp != null ? ablp . gravity : DEFAULT_CUSTOM_GRAVITY ; final int navWidth = customView . getMeasuredWidth ( ) ; int topMargin = <NUM_LIT:0> ; int bottomMargin = <NUM_LIT:0> ; if ( ablp != null ) { x += ablp . leftMargin ; menuLeft -= ablp . rightMargin ; topMargin = ablp . topMargin ; bottomMargin = ablp . bottomMargin ; } int hgravity = gravity & Gravity . HORIZONTAL_GRAVITY_MASK ; if ( hgravity == Gravity . CENTER_HORIZONTAL ) { final int centeredLeft = ( ( getRight ( ) - getLeft ( ) ) - navWidth ) / <NUM_LIT:2> ; if ( centeredLeft < x ) { hgravity = Gravity . LEFT ; } else if ( centeredLeft + navWidth > menuLeft ) { hgravity = Gravity . RIGHT ; } } else if ( gravity == - <NUM_LIT:1> ) { hgravity = Gravity . LEFT ; } int xpos = <NUM_LIT:0> ; switch ( hgravity ) { case Gravity . CENTER_HORIZONTAL : xpos = ( ( getRight ( ) - getLeft ( ) ) - navWidth ) / <NUM_LIT:2> ; break ; case Gravity . LEFT : xpos = x ; break ; case Gravity . RIGHT : xpos = menuLeft - navWidth ; break ; } int vgravity = gravity & Gravity . VERTICAL_GRAVITY_MASK ; if ( gravity == - <NUM_LIT:1> ) { vgravity = Gravity . CENTER_VERTICAL ; } int ypos = <NUM_LIT:0> ; switch ( vgravity ) { case Gravity . CENTER_VERTICAL : final int paddedTop = getPaddingTop ( ) ; final int paddedBottom = getBottom ( ) - getTop ( ) - getPaddingBottom ( ) ; ypos = ( ( paddedBottom - paddedTop ) - customView . getMeasuredHeight ( ) ) / <NUM_LIT:2> ; break ; case Gravity . TOP : ypos = getPaddingTop ( ) + topMargin ; break ; case Gravity . BOTTOM : ypos = getHeight ( ) - getPaddingBottom ( ) - customView . getMeasuredHeight ( ) - bottomMargin ; break ; } final int customWidth = customView . getMeasuredWidth ( ) ; customView . layout ( xpos , ypos , xpos + customWidth , ypos + customView . getMeasuredHeight ( ) ) ; x += customWidth ; } if ( mProgressView != null ) { mProgressView . bringToFront ( ) ; final int halfProgressHeight = mProgressView . getMeasuredHeight ( ) / <NUM_LIT:2> ; mProgressView . layout ( mProgressBarPadding , - halfProgressHeight , mProgressBarPadding + mProgressView . getMeasuredWidth ( ) , halfProgressHeight ) ; } } @ Override public ViewGroup . LayoutParams generateLayoutParams ( AttributeSet attrs ) { return new ActionBar . LayoutParams ( getContext ( ) , attrs ) ; } @ Override public ViewGroup . LayoutParams generateLayoutParams ( ViewGroup . LayoutParams lp ) { if ( lp == null ) { lp = generateDefaultLayoutParams ( ) ; } return lp ; } @ Override public Parcelable onSaveInstanceState ( ) { Parcelable superState = super . onSaveInstanceState ( ) ; SavedState state = new SavedState ( superState ) ; if ( mExpandedMenuPresenter != null && mExpandedMenuPresenter . mCurrentExpandedItem != null ) { state . expandedMenuItemId = mExpandedMenuPresenter . mCurrentExpandedItem . getItemId ( ) ; } state . isOverflowOpen = isOverflowMenuShowing ( ) ; return state ; } @ Override public void onRestoreInstanceState ( Parcelable p ) { SavedState state = ( SavedState ) p ; super . onRestoreInstanceState ( state . getSuperState ( ) ) ; if ( state . expandedMenuItemId != <NUM_LIT:0> && mExpandedMenuPresenter != null && mOptionsMenu != null ) { final MenuItem item = mOptionsMenu . findItem ( state . expandedMenuItemId ) ; if ( item != null ) { item . expandActionView ( ) ; } } if ( state . isOverflowOpen ) { postShowOverflowMenu ( ) ; } } static class SavedState extends BaseSavedState { int expandedMenuItemId ; boolean isOverflowOpen ; SavedState ( Parcelable superState ) { super ( superState ) ; } private SavedState ( Parcel in ) { super ( in ) ; expandedMenuItemId = in . readInt ( ) ; isOverflowOpen = in . readInt ( ) != <NUM_LIT:0> ; } @ Override public void writeToParcel ( Parcel out , int flags ) { super . writeToParcel ( out , flags ) ; out . writeInt ( expandedMenuItemId ) ; out . writeInt ( isOverflowOpen ? <NUM_LIT:1> : <NUM_LIT:0> ) ; } public static final Parcelable . Creator < SavedState > CREATOR = new Parcelable . Creator < SavedState > ( ) { public SavedState createFromParcel ( Parcel in ) { return new SavedState ( in ) ; } public SavedState [ ] newArray ( int size ) { return new SavedState [ size ] ; } } ; } public static class HomeView extends FrameLayout { private View mUpView ; private ImageView mIconView ; private int mUpWidth ; public HomeView ( Context context ) { this ( context , null ) ; } public HomeView ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; } public void setUp ( boolean isUp ) { mUpView . setVisibility ( isUp ? VISIBLE : GONE ) ; } public void setIcon ( Drawable icon ) { mIconView . setImageDrawable ( icon ) ; } @ Override public boolean dispatchPopulateAccessibilityEvent ( AccessibilityEvent event ) { onPopulateAccessibilityEvent ( event ) ; return true ; } @ Override public void onPopulateAccessibilityEvent ( AccessibilityEvent event ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . ICE_CREAM_SANDWICH ) { super . onPopulateAccessibilityEvent ( event ) ; } final CharSequence cdesc = getContentDescription ( ) ; if ( ! TextUtils . isEmpty ( cdesc ) ) { event . getText ( ) . add ( cdesc ) ; } } @ Override public boolean dispatchHoverEvent ( MotionEvent event ) { return onHoverEvent ( event ) ; } @ Override protected void onFinishInflate ( ) { mUpView = findViewById ( R . id . abs__up ) ; mIconView = ( ImageView ) findViewById ( R . id . abs__home ) ; } public int getLeftOffset ( ) { return mUpView . getVisibility ( ) == GONE ? mUpWidth : <NUM_LIT:0> ; } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { measureChildWithMargins ( mUpView , widthMeasureSpec , <NUM_LIT:0> , heightMeasureSpec , <NUM_LIT:0> ) ; final LayoutParams upLp = ( LayoutParams ) mUpView . getLayoutParams ( ) ; mUpWidth = upLp . leftMargin + mUpView . getMeasuredWidth ( ) + upLp . rightMargin ; int width = mUpView . getVisibility ( ) == GONE ? <NUM_LIT:0> : mUpWidth ; int height = upLp . topMargin + mUpView . getMeasuredHeight ( ) + upLp . bottomMargin ; measureChildWithMargins ( mIconView , widthMeasureSpec , width , heightMeasureSpec , <NUM_LIT:0> ) ; final LayoutParams iconLp = ( LayoutParams ) mIconView . getLayoutParams ( ) ; width += iconLp . leftMargin + mIconView . getMeasuredWidth ( ) + iconLp . rightMargin ; height = Math . max ( height , iconLp . topMargin + mIconView . getMeasuredHeight ( ) + iconLp . bottomMargin ) ; final int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; final int heightMode = MeasureSpec . getMode ( heightMeasureSpec ) ; final int widthSize = MeasureSpec . getSize ( widthMeasureSpec ) ; final int heightSize = MeasureSpec . getSize ( heightMeasureSpec ) ; switch ( widthMode ) { case MeasureSpec . AT_MOST : width = Math . min ( width , widthSize ) ; break ; case MeasureSpec . EXACTLY : width = widthSize ; break ; case MeasureSpec . UNSPECIFIED : default : break ; } switch ( heightMode ) { case MeasureSpec . AT_MOST : height = Math . min ( height , heightSize ) ; break ; case MeasureSpec . EXACTLY : height = heightSize ; break ; case MeasureSpec . UNSPECIFIED : default : break ; } setMeasuredDimension ( width , height ) ; } @ Override protected void onLayout ( boolean changed , int l , int t , int r , int b ) { final int vCenter = ( b - t ) / <NUM_LIT:2> ; int upOffset = <NUM_LIT:0> ; if ( mUpView . getVisibility ( ) != GONE ) { final LayoutParams upLp = ( LayoutParams ) mUpView . getLayoutParams ( ) ; final int upHeight = mUpView . getMeasuredHeight ( ) ; final int upWidth = mUpView . getMeasuredWidth ( ) ; final int upTop = vCenter - upHeight / <NUM_LIT:2> ; mUpView . layout ( <NUM_LIT:0> , upTop , upWidth , upTop + upHeight ) ; upOffset = upLp . leftMargin + upWidth + upLp . rightMargin ; l += upOffset ; } final LayoutParams iconLp = ( LayoutParams ) mIconView . getLayoutParams ( ) ; final int iconHeight = mIconView . getMeasuredHeight ( ) ; final int iconWidth = mIconView . getMeasuredWidth ( ) ; final int hCenter = ( r - l ) / <NUM_LIT:2> ; final int iconLeft = upOffset + Math . max ( iconLp . leftMargin , hCenter - iconWidth / <NUM_LIT:2> ) ; final int iconTop = Math . max ( iconLp . topMargin , vCenter - iconHeight / <NUM_LIT:2> ) ; mIconView . layout ( iconLeft , iconTop , iconLeft + iconWidth , iconTop + iconHeight ) ; } } private class ExpandedActionViewMenuPresenter implements MenuPresenter { MenuBuilder mMenu ; MenuItemImpl mCurrentExpandedItem ; @ Override public void initForMenu ( Context context , MenuBuilder menu ) { if ( mMenu != null && mCurrentExpandedItem != null ) { mMenu . collapseItemActionView ( mCurrentExpandedItem ) ; } mMenu = menu ; } @ Override public MenuView getMenuView ( ViewGroup root ) { return null ; } @ Override public void updateMenuView ( boolean cleared ) { if ( mCurrentExpandedItem != null ) { boolean found = false ; if ( mMenu != null ) { final int count = mMenu . size ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { final MenuItem item = mMenu . getItem ( i ) ; if ( item == mCurrentExpandedItem ) { found = true ; break ; } } } if ( ! found ) { collapseItemActionView ( mMenu , mCurrentExpandedItem ) ; } } } @ Override public void setCallback ( Callback cb ) { } @ Override public boolean onSubMenuSelected ( SubMenuBuilder subMenu ) { return false ; } @ Override public void onCloseMenu ( MenuBuilder menu , boolean allMenusAreClosing ) { } @ Override public boolean flagActionItems ( ) { return false ; } @ Override public boolean expandItemActionView ( MenuBuilder menu , MenuItemImpl item ) { mExpandedActionView = item . getActionView ( ) ; mExpandedHomeLayout . setIcon ( mIcon . getConstantState ( ) . newDrawable ( ) ) ; mCurrentExpandedItem = item ; if ( mExpandedActionView . getParent ( ) != ActionBarView . this ) { addView ( mExpandedActionView ) ; } if ( mExpandedHomeLayout . getParent ( ) != ActionBarView . this ) { addView ( mExpandedHomeLayout ) ; } mHomeLayout . setVisibility ( GONE ) ; if ( mTitleLayout != null ) mTitleLayout . setVisibility ( GONE ) ; if ( mTabScrollView != null ) mTabScrollView . setVisibility ( GONE ) ; if ( mSpinner != null ) mSpinner . setVisibility ( GONE ) ; if ( mCustomNavView != null ) mCustomNavView . setVisibility ( GONE ) ; requestLayout ( ) ; item . setActionViewExpanded ( true ) ; if ( mExpandedActionView instanceof CollapsibleActionView ) { ( ( CollapsibleActionView ) mExpandedActionView ) . onActionViewExpanded ( ) ; } return true ; } @ Override public boolean collapseItemActionView ( MenuBuilder menu , MenuItemImpl item ) { if ( mExpandedActionView instanceof CollapsibleActionView ) { ( ( CollapsibleActionView ) mExpandedActionView ) . onActionViewCollapsed ( ) ; } removeView ( mExpandedActionView ) ; removeView ( mExpandedHomeLayout ) ; mExpandedActionView = null ; if ( ( mDisplayOptions & ActionBar . DISPLAY_SHOW_HOME ) != <NUM_LIT:0> ) { mHomeLayout . setVisibility ( VISIBLE ) ; } if ( ( mDisplayOptions & ActionBar . DISPLAY_SHOW_TITLE ) != <NUM_LIT:0> ) { if ( mTitleLayout == null ) { initTitle ( ) ; } else { mTitleLayout . setVisibility ( VISIBLE ) ; } } if ( mTabScrollView != null && mNavigationMode == ActionBar . NAVIGATION_MODE_TABS ) { mTabScrollView . setVisibility ( VISIBLE ) ; } if ( mSpinner != null && mNavigationMode == ActionBar . NAVIGATION_MODE_LIST ) { mSpinner . setVisibility ( VISIBLE ) ; } if ( mCustomNavView != null && ( mDisplayOptions & ActionBar . DISPLAY_SHOW_CUSTOM ) != <NUM_LIT:0> ) { mCustomNavView . setVisibility ( VISIBLE ) ; } mExpandedHomeLayout . setIcon ( null ) ; mCurrentExpandedItem = null ; requestLayout ( ) ; item . setActionViewExpanded ( false ) ; return true ; } @ Override public int getId ( ) { return <NUM_LIT:0> ; } @ Override public Parcelable onSaveInstanceState ( ) { return null ; } @ Override public void onRestoreInstanceState ( Parcelable state ) { } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . content . res . TypedArray ; import android . graphics . Canvas ; import android . graphics . drawable . Drawable ; import android . util . AttributeSet ; import android . view . View ; import com . actionbarsherlock . internal . nineoldandroids . widget . NineLinearLayout ; public class IcsLinearLayout extends NineLinearLayout { private static final int [ ] LinearLayout = new int [ ] { android . R . attr . divider , android . R . attr . showDividers , android . R . attr . dividerPadding , } ; private static final int LinearLayout_divider = <NUM_LIT:0> ; private static final int LinearLayout_showDividers = <NUM_LIT:1> ; private static final int LinearLayout_dividerPadding = <NUM_LIT:2> ; public static final int SHOW_DIVIDER_NONE = <NUM_LIT:0> ; public static final int SHOW_DIVIDER_BEGINNING = <NUM_LIT:1> ; public static final int SHOW_DIVIDER_MIDDLE = <NUM_LIT:2> ; public static final int SHOW_DIVIDER_END = <NUM_LIT:4> ; private Drawable mDivider ; private int mDividerWidth ; private int mDividerHeight ; private int mShowDividers ; private int mDividerPadding ; public IcsLinearLayout ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; TypedArray a = context . obtainStyledAttributes ( attrs , LinearLayout ) ; setDividerDrawable ( a . getDrawable ( LinearLayout_divider ) ) ; mShowDividers = a . getInt ( LinearLayout_showDividers , SHOW_DIVIDER_NONE ) ; mDividerPadding = a . getDimensionPixelSize ( LinearLayout_dividerPadding , <NUM_LIT:0> ) ; a . recycle ( ) ; } public void setShowDividers ( int showDividers ) { if ( showDividers != mShowDividers ) { requestLayout ( ) ; invalidate ( ) ; } mShowDividers = showDividers ; } public int getShowDividers ( ) { return mShowDividers ; } public void setDividerDrawable ( Drawable divider ) { if ( divider == mDivider ) { return ; } mDivider = divider ; if ( divider != null ) { mDividerWidth = divider . getIntrinsicWidth ( ) ; mDividerHeight = divider . getIntrinsicHeight ( ) ; } else { mDividerWidth = <NUM_LIT:0> ; mDividerHeight = <NUM_LIT:0> ; } setWillNotDraw ( divider == null ) ; requestLayout ( ) ; } public void setDividerPadding ( int padding ) { mDividerPadding = padding ; } public int getDividerPadding ( ) { return mDividerPadding ; } public int getDividerWidth ( ) { return mDividerWidth ; } @ Override protected void measureChildWithMargins ( View child , int parentWidthMeasureSpec , int widthUsed , int parentHeightMeasureSpec , int heightUsed ) { final int index = indexOfChild ( child ) ; final int orientation = getOrientation ( ) ; final LayoutParams params = ( LayoutParams ) child . getLayoutParams ( ) ; if ( hasDividerBeforeChildAt ( index ) ) { if ( orientation == VERTICAL ) { params . topMargin = mDividerHeight ; } else { params . leftMargin = mDividerWidth ; } } final int count = getChildCount ( ) ; if ( index == count - <NUM_LIT:1> ) { if ( hasDividerBeforeChildAt ( count ) ) { if ( orientation == VERTICAL ) { params . bottomMargin = mDividerHeight ; } else { params . rightMargin = mDividerWidth ; } } } super . measureChildWithMargins ( child , parentWidthMeasureSpec , widthUsed , parentHeightMeasureSpec , heightUsed ) ; } @ Override protected void onDraw ( Canvas canvas ) { if ( mDivider != null ) { if ( getOrientation ( ) == VERTICAL ) { drawDividersVertical ( canvas ) ; } else { drawDividersHorizontal ( canvas ) ; } } super . onDraw ( canvas ) ; } void drawDividersVertical ( Canvas canvas ) { final int count = getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { final View child = getChildAt ( i ) ; if ( child != null && child . getVisibility ( ) != GONE ) { if ( hasDividerBeforeChildAt ( i ) ) { final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; final int top = child . getTop ( ) - lp . topMargin ; drawHorizontalDivider ( canvas , top ) ; } } } if ( hasDividerBeforeChildAt ( count ) ) { final View child = getChildAt ( count - <NUM_LIT:1> ) ; int bottom = <NUM_LIT:0> ; if ( child == null ) { bottom = getHeight ( ) - getPaddingBottom ( ) - mDividerHeight ; } else { final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; bottom = child . getBottom ( ) ; } drawHorizontalDivider ( canvas , bottom ) ; } } void drawDividersHorizontal ( Canvas canvas ) { final int count = getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { final View child = getChildAt ( i ) ; if ( child != null && child . getVisibility ( ) != GONE ) { if ( hasDividerBeforeChildAt ( i ) ) { final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; final int left = child . getLeft ( ) - lp . leftMargin ; drawVerticalDivider ( canvas , left ) ; } } } if ( hasDividerBeforeChildAt ( count ) ) { final View child = getChildAt ( count - <NUM_LIT:1> ) ; int right = <NUM_LIT:0> ; if ( child == null ) { right = getWidth ( ) - getPaddingRight ( ) - mDividerWidth ; } else { final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; right = child . getRight ( ) ; } drawVerticalDivider ( canvas , right ) ; } } void drawHorizontalDivider ( Canvas canvas , int top ) { mDivider . setBounds ( getPaddingLeft ( ) + mDividerPadding , top , getWidth ( ) - getPaddingRight ( ) - mDividerPadding , top + mDividerHeight ) ; mDivider . draw ( canvas ) ; } void drawVerticalDivider ( Canvas canvas , int left ) { mDivider . setBounds ( left , getPaddingTop ( ) + mDividerPadding , left + mDividerWidth , getHeight ( ) - getPaddingBottom ( ) - mDividerPadding ) ; mDivider . draw ( canvas ) ; } protected boolean hasDividerBeforeChildAt ( int childIndex ) { if ( childIndex == <NUM_LIT:0> ) { return ( mShowDividers & SHOW_DIVIDER_BEGINNING ) != <NUM_LIT:0> ; } else if ( childIndex == getChildCount ( ) ) { return ( mShowDividers & SHOW_DIVIDER_END ) != <NUM_LIT:0> ; } else if ( ( mShowDividers & SHOW_DIVIDER_MIDDLE ) != <NUM_LIT:0> ) { boolean hasVisibleViewBefore = false ; for ( int i = childIndex - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { if ( getChildAt ( i ) . getVisibility ( ) != GONE ) { hasVisibleViewBefore = true ; break ; } } return hasVisibleViewBefore ; } return false ; } } </s>
<s> package com . actionbarsherlock . internal . widget ; import java . util . Locale ; import android . content . Context ; import android . content . res . TypedArray ; import android . os . Build ; import android . util . AttributeSet ; import android . widget . TextView ; public class CapitalizingTextView extends TextView { private static final boolean SANS_ICE_CREAM = Build . VERSION . SDK_INT < Build . VERSION_CODES . ICE_CREAM_SANDWICH ; private static final boolean IS_GINGERBREAD = Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ; private static final int [ ] R_styleable_TextView = new int [ ] { android . R . attr . textAllCaps } ; private static final int R_styleable_TextView_textAllCaps = <NUM_LIT:0> ; private boolean mAllCaps ; public CapitalizingTextView ( Context context , AttributeSet attrs ) { this ( context , attrs , <NUM_LIT:0> ) ; } public CapitalizingTextView ( Context context , AttributeSet attrs , int defStyle ) { super ( context , attrs , defStyle ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R_styleable_TextView , defStyle , <NUM_LIT:0> ) ; mAllCaps = a . getBoolean ( R_styleable_TextView_textAllCaps , true ) ; a . recycle ( ) ; } public void setTextCompat ( CharSequence text ) { if ( SANS_ICE_CREAM && mAllCaps && text != null ) { if ( IS_GINGERBREAD ) { setText ( text . toString ( ) . toUpperCase ( Locale . ROOT ) ) ; } else { setText ( text . toString ( ) . toUpperCase ( ) ) ; } } else { setText ( text ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . content . res . TypedArray ; import android . graphics . Bitmap ; import android . graphics . BitmapShader ; import android . graphics . Canvas ; import android . graphics . Rect ; import android . graphics . Shader ; import android . graphics . drawable . Animatable ; import android . graphics . drawable . AnimationDrawable ; import android . graphics . drawable . BitmapDrawable ; import android . graphics . drawable . ClipDrawable ; import android . graphics . drawable . Drawable ; import android . graphics . drawable . LayerDrawable ; import android . graphics . drawable . ShapeDrawable ; import android . graphics . drawable . shapes . RoundRectShape ; import android . graphics . drawable . shapes . Shape ; import android . os . Build ; import android . os . Parcel ; import android . os . Parcelable ; import android . os . SystemClock ; import android . util . AttributeSet ; import android . view . Gravity ; import android . view . View ; import android . view . ViewDebug ; import android . view . accessibility . AccessibilityEvent ; import android . view . accessibility . AccessibilityManager ; import android . view . animation . AlphaAnimation ; import android . view . animation . Animation ; import android . view . animation . AnimationUtils ; import android . view . animation . Interpolator ; import android . view . animation . LinearInterpolator ; import android . view . animation . Transformation ; import android . widget . RemoteViews . RemoteView ; @ RemoteView public class IcsProgressBar extends View { private static final boolean IS_HONEYCOMB = Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ; private static final int MAX_LEVEL = <NUM_LIT> ; private static final int ANIMATION_RESOLUTION = <NUM_LIT> ; private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = <NUM_LIT> ; private static final int [ ] ProgressBar = new int [ ] { android . R . attr . maxWidth , android . R . attr . maxHeight , android . R . attr . max , android . R . attr . progress , android . R . attr . secondaryProgress , android . R . attr . indeterminate , android . R . attr . indeterminateOnly , android . R . attr . indeterminateDrawable , android . R . attr . progressDrawable , android . R . attr . indeterminateDuration , android . R . attr . indeterminateBehavior , android . R . attr . minWidth , android . R . attr . minHeight , android . R . attr . interpolator , android . R . attr . animationResolution , } ; private static final int ProgressBar_maxWidth = <NUM_LIT:0> ; private static final int ProgressBar_maxHeight = <NUM_LIT:1> ; private static final int ProgressBar_max = <NUM_LIT:2> ; private static final int ProgressBar_progress = <NUM_LIT:3> ; private static final int ProgressBar_secondaryProgress = <NUM_LIT:4> ; private static final int ProgressBar_indeterminate = <NUM_LIT:5> ; private static final int ProgressBar_indeterminateOnly = <NUM_LIT:6> ; private static final int ProgressBar_indeterminateDrawable = <NUM_LIT:7> ; private static final int ProgressBar_progressDrawable = <NUM_LIT:8> ; private static final int ProgressBar_indeterminateDuration = <NUM_LIT:9> ; private static final int ProgressBar_indeterminateBehavior = <NUM_LIT:10> ; private static final int ProgressBar_minWidth = <NUM_LIT:11> ; private static final int ProgressBar_minHeight = <NUM_LIT:12> ; private static final int ProgressBar_interpolator = <NUM_LIT> ; private static final int ProgressBar_animationResolution = <NUM_LIT> ; int mMinWidth ; int mMaxWidth ; int mMinHeight ; int mMaxHeight ; private int mProgress ; private int mSecondaryProgress ; private int mMax ; private int mBehavior ; private int mDuration ; private boolean mIndeterminate ; private boolean mOnlyIndeterminate ; private Transformation mTransformation ; private AlphaAnimation mAnimation ; private Drawable mIndeterminateDrawable ; private int mIndeterminateRealLeft ; private int mIndeterminateRealTop ; private Drawable mProgressDrawable ; private Drawable mCurrentDrawable ; Bitmap mSampleTile ; private boolean mNoInvalidate ; private Interpolator mInterpolator ; private RefreshProgressRunnable mRefreshProgressRunnable ; private long mUiThreadId ; private boolean mShouldStartAnimationDrawable ; private long mLastDrawTime ; private boolean mInDrawing ; private int mAnimationResolution ; private AccessibilityManager mAccessibilityManager ; private AccessibilityEventSender mAccessibilityEventSender ; public IcsProgressBar ( Context context ) { this ( context , null ) ; } public IcsProgressBar ( Context context , AttributeSet attrs ) { this ( context , attrs , android . R . attr . progressBarStyle ) ; } public IcsProgressBar ( Context context , AttributeSet attrs , int defStyle ) { this ( context , attrs , defStyle , <NUM_LIT:0> ) ; } public IcsProgressBar ( Context context , AttributeSet attrs , int defStyle , int styleRes ) { super ( context , attrs , defStyle ) ; mUiThreadId = Thread . currentThread ( ) . getId ( ) ; initProgressBar ( ) ; TypedArray a = context . obtainStyledAttributes ( attrs , ProgressBar , defStyle , styleRes ) ; mNoInvalidate = true ; Drawable drawable = a . getDrawable ( ProgressBar_progressDrawable ) ; if ( drawable != null ) { drawable = tileify ( drawable , false ) ; setProgressDrawable ( drawable ) ; } mDuration = a . getInt ( ProgressBar_indeterminateDuration , mDuration ) ; mMinWidth = a . getDimensionPixelSize ( ProgressBar_minWidth , mMinWidth ) ; mMaxWidth = a . getDimensionPixelSize ( ProgressBar_maxWidth , mMaxWidth ) ; mMinHeight = a . getDimensionPixelSize ( ProgressBar_minHeight , mMinHeight ) ; mMaxHeight = a . getDimensionPixelSize ( ProgressBar_maxHeight , mMaxHeight ) ; mBehavior = a . getInt ( ProgressBar_indeterminateBehavior , mBehavior ) ; final int resID = a . getResourceId ( ProgressBar_interpolator , android . R . anim . linear_interpolator ) ; if ( resID > <NUM_LIT:0> ) { setInterpolator ( context , resID ) ; } setMax ( a . getInt ( ProgressBar_max , mMax ) ) ; setProgress ( a . getInt ( ProgressBar_progress , mProgress ) ) ; setSecondaryProgress ( a . getInt ( ProgressBar_secondaryProgress , mSecondaryProgress ) ) ; drawable = a . getDrawable ( ProgressBar_indeterminateDrawable ) ; if ( drawable != null ) { drawable = tileifyIndeterminate ( drawable ) ; setIndeterminateDrawable ( drawable ) ; } mOnlyIndeterminate = a . getBoolean ( ProgressBar_indeterminateOnly , mOnlyIndeterminate ) ; mNoInvalidate = false ; setIndeterminate ( mOnlyIndeterminate || a . getBoolean ( ProgressBar_indeterminate , mIndeterminate ) ) ; mAnimationResolution = a . getInteger ( ProgressBar_animationResolution , ANIMATION_RESOLUTION ) ; a . recycle ( ) ; mAccessibilityManager = ( AccessibilityManager ) context . getSystemService ( Context . ACCESSIBILITY_SERVICE ) ; } private Drawable tileify ( Drawable drawable , boolean clip ) { if ( drawable instanceof LayerDrawable ) { LayerDrawable background = ( LayerDrawable ) drawable ; final int N = background . getNumberOfLayers ( ) ; Drawable [ ] outDrawables = new Drawable [ N ] ; for ( int i = <NUM_LIT:0> ; i < N ; i ++ ) { int id = background . getId ( i ) ; outDrawables [ i ] = tileify ( background . getDrawable ( i ) , ( id == android . R . id . progress || id == android . R . id . secondaryProgress ) ) ; } LayerDrawable newBg = new LayerDrawable ( outDrawables ) ; for ( int i = <NUM_LIT:0> ; i < N ; i ++ ) { newBg . setId ( i , background . getId ( i ) ) ; } return newBg ; } else if ( drawable instanceof BitmapDrawable ) { final Bitmap tileBitmap = ( ( BitmapDrawable ) drawable ) . getBitmap ( ) ; if ( mSampleTile == null ) { mSampleTile = tileBitmap ; } final ShapeDrawable shapeDrawable = new ShapeDrawable ( getDrawableShape ( ) ) ; final BitmapShader bitmapShader = new BitmapShader ( tileBitmap , Shader . TileMode . REPEAT , Shader . TileMode . CLAMP ) ; shapeDrawable . getPaint ( ) . setShader ( bitmapShader ) ; return ( clip ) ? new ClipDrawable ( shapeDrawable , Gravity . LEFT , ClipDrawable . HORIZONTAL ) : shapeDrawable ; } return drawable ; } Shape getDrawableShape ( ) { final float [ ] roundedCorners = new float [ ] { <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> } ; return new RoundRectShape ( roundedCorners , null , null ) ; } private Drawable tileifyIndeterminate ( Drawable drawable ) { if ( drawable instanceof AnimationDrawable ) { AnimationDrawable background = ( AnimationDrawable ) drawable ; final int N = background . getNumberOfFrames ( ) ; AnimationDrawable newBg = new AnimationDrawable ( ) ; newBg . setOneShot ( background . isOneShot ( ) ) ; for ( int i = <NUM_LIT:0> ; i < N ; i ++ ) { Drawable frame = tileify ( background . getFrame ( i ) , true ) ; frame . setLevel ( <NUM_LIT> ) ; newBg . addFrame ( frame , background . getDuration ( i ) ) ; } newBg . setLevel ( <NUM_LIT> ) ; drawable = newBg ; } return drawable ; } private void initProgressBar ( ) { mMax = <NUM_LIT:100> ; mProgress = <NUM_LIT:0> ; mSecondaryProgress = <NUM_LIT:0> ; mIndeterminate = false ; mOnlyIndeterminate = false ; mDuration = <NUM_LIT> ; mBehavior = AlphaAnimation . RESTART ; mMinWidth = <NUM_LIT:24> ; mMaxWidth = <NUM_LIT> ; mMinHeight = <NUM_LIT:24> ; mMaxHeight = <NUM_LIT> ; } @ ViewDebug . ExportedProperty ( category = "<STR_LIT>" ) public synchronized boolean isIndeterminate ( ) { return mIndeterminate ; } public synchronized void setIndeterminate ( boolean indeterminate ) { if ( ( ! mOnlyIndeterminate || ! mIndeterminate ) && indeterminate != mIndeterminate ) { mIndeterminate = indeterminate ; if ( indeterminate ) { mCurrentDrawable = mIndeterminateDrawable ; startAnimation ( ) ; } else { mCurrentDrawable = mProgressDrawable ; stopAnimation ( ) ; } } } public Drawable getIndeterminateDrawable ( ) { return mIndeterminateDrawable ; } public void setIndeterminateDrawable ( Drawable d ) { if ( d != null ) { d . setCallback ( this ) ; } mIndeterminateDrawable = d ; if ( mIndeterminate ) { mCurrentDrawable = d ; postInvalidate ( ) ; } } public Drawable getProgressDrawable ( ) { return mProgressDrawable ; } public void setProgressDrawable ( Drawable d ) { boolean needUpdate ; if ( mProgressDrawable != null && d != mProgressDrawable ) { mProgressDrawable . setCallback ( null ) ; needUpdate = true ; } else { needUpdate = false ; } if ( d != null ) { d . setCallback ( this ) ; int drawableHeight = d . getMinimumHeight ( ) ; if ( mMaxHeight < drawableHeight ) { mMaxHeight = drawableHeight ; requestLayout ( ) ; } } mProgressDrawable = d ; if ( ! mIndeterminate ) { mCurrentDrawable = d ; postInvalidate ( ) ; } if ( needUpdate ) { updateDrawableBounds ( getWidth ( ) , getHeight ( ) ) ; updateDrawableState ( ) ; doRefreshProgress ( android . R . id . progress , mProgress , false , false ) ; doRefreshProgress ( android . R . id . secondaryProgress , mSecondaryProgress , false , false ) ; } } Drawable getCurrentDrawable ( ) { return mCurrentDrawable ; } @ Override protected boolean verifyDrawable ( Drawable who ) { return who == mProgressDrawable || who == mIndeterminateDrawable || super . verifyDrawable ( who ) ; } @ Override public void jumpDrawablesToCurrentState ( ) { super . jumpDrawablesToCurrentState ( ) ; if ( mProgressDrawable != null ) mProgressDrawable . jumpToCurrentState ( ) ; if ( mIndeterminateDrawable != null ) mIndeterminateDrawable . jumpToCurrentState ( ) ; } @ Override public void postInvalidate ( ) { if ( ! mNoInvalidate ) { super . postInvalidate ( ) ; } } private class RefreshProgressRunnable implements Runnable { private int mId ; private int mProgress ; private boolean mFromUser ; RefreshProgressRunnable ( int id , int progress , boolean fromUser ) { mId = id ; mProgress = progress ; mFromUser = fromUser ; } public void run ( ) { doRefreshProgress ( mId , mProgress , mFromUser , true ) ; mRefreshProgressRunnable = this ; } public void setup ( int id , int progress , boolean fromUser ) { mId = id ; mProgress = progress ; mFromUser = fromUser ; } } private synchronized void doRefreshProgress ( int id , int progress , boolean fromUser , boolean callBackToApp ) { float scale = mMax > <NUM_LIT:0> ? ( float ) progress / ( float ) mMax : <NUM_LIT:0> ; final Drawable d = mCurrentDrawable ; if ( d != null ) { Drawable progressDrawable = null ; if ( d instanceof LayerDrawable ) { progressDrawable = ( ( LayerDrawable ) d ) . findDrawableByLayerId ( id ) ; } final int level = ( int ) ( scale * MAX_LEVEL ) ; ( progressDrawable != null ? progressDrawable : d ) . setLevel ( level ) ; } else { invalidate ( ) ; } if ( callBackToApp && id == android . R . id . progress ) { onProgressRefresh ( scale , fromUser ) ; } } void onProgressRefresh ( float scale , boolean fromUser ) { if ( mAccessibilityManager . isEnabled ( ) ) { scheduleAccessibilityEventSender ( ) ; } } private synchronized void refreshProgress ( int id , int progress , boolean fromUser ) { if ( mUiThreadId == Thread . currentThread ( ) . getId ( ) ) { doRefreshProgress ( id , progress , fromUser , true ) ; } else { RefreshProgressRunnable r ; if ( mRefreshProgressRunnable != null ) { r = mRefreshProgressRunnable ; mRefreshProgressRunnable = null ; r . setup ( id , progress , fromUser ) ; } else { r = new RefreshProgressRunnable ( id , progress , fromUser ) ; } post ( r ) ; } } public synchronized void setProgress ( int progress ) { setProgress ( progress , false ) ; } synchronized void setProgress ( int progress , boolean fromUser ) { if ( mIndeterminate ) { return ; } if ( progress < <NUM_LIT:0> ) { progress = <NUM_LIT:0> ; } if ( progress > mMax ) { progress = mMax ; } if ( progress != mProgress ) { mProgress = progress ; refreshProgress ( android . R . id . progress , mProgress , fromUser ) ; } } public synchronized void setSecondaryProgress ( int secondaryProgress ) { if ( mIndeterminate ) { return ; } if ( secondaryProgress < <NUM_LIT:0> ) { secondaryProgress = <NUM_LIT:0> ; } if ( secondaryProgress > mMax ) { secondaryProgress = mMax ; } if ( secondaryProgress != mSecondaryProgress ) { mSecondaryProgress = secondaryProgress ; refreshProgress ( android . R . id . secondaryProgress , mSecondaryProgress , false ) ; } } @ ViewDebug . ExportedProperty ( category = "<STR_LIT>" ) public synchronized int getProgress ( ) { return mIndeterminate ? <NUM_LIT:0> : mProgress ; } @ ViewDebug . ExportedProperty ( category = "<STR_LIT>" ) public synchronized int getSecondaryProgress ( ) { return mIndeterminate ? <NUM_LIT:0> : mSecondaryProgress ; } @ ViewDebug . ExportedProperty ( category = "<STR_LIT>" ) public synchronized int getMax ( ) { return mMax ; } public synchronized void setMax ( int max ) { if ( max < <NUM_LIT:0> ) { max = <NUM_LIT:0> ; } if ( max != mMax ) { mMax = max ; postInvalidate ( ) ; if ( mProgress > max ) { mProgress = max ; } refreshProgress ( android . R . id . progress , mProgress , false ) ; } } public synchronized final void incrementProgressBy ( int diff ) { setProgress ( mProgress + diff ) ; } public synchronized final void incrementSecondaryProgressBy ( int diff ) { setSecondaryProgress ( mSecondaryProgress + diff ) ; } void startAnimation ( ) { if ( getVisibility ( ) != VISIBLE ) { return ; } if ( mIndeterminateDrawable instanceof Animatable ) { mShouldStartAnimationDrawable = true ; mAnimation = null ; } else { if ( mInterpolator == null ) { mInterpolator = new LinearInterpolator ( ) ; } mTransformation = new Transformation ( ) ; mAnimation = new AlphaAnimation ( <NUM_LIT:0.0f> , <NUM_LIT:1.0f> ) ; mAnimation . setRepeatMode ( mBehavior ) ; mAnimation . setRepeatCount ( Animation . INFINITE ) ; mAnimation . setDuration ( mDuration ) ; mAnimation . setInterpolator ( mInterpolator ) ; mAnimation . setStartTime ( Animation . START_ON_FIRST_FRAME ) ; } postInvalidate ( ) ; } void stopAnimation ( ) { mAnimation = null ; mTransformation = null ; if ( mIndeterminateDrawable instanceof Animatable ) { ( ( Animatable ) mIndeterminateDrawable ) . stop ( ) ; mShouldStartAnimationDrawable = false ; } postInvalidate ( ) ; } public void setInterpolator ( Context context , int resID ) { setInterpolator ( AnimationUtils . loadInterpolator ( context , resID ) ) ; } public void setInterpolator ( Interpolator interpolator ) { mInterpolator = interpolator ; } public Interpolator getInterpolator ( ) { return mInterpolator ; } @ Override public void setVisibility ( int v ) { if ( getVisibility ( ) != v ) { super . setVisibility ( v ) ; if ( mIndeterminate ) { if ( v == GONE || v == INVISIBLE ) { stopAnimation ( ) ; } else { startAnimation ( ) ; } } } } @ Override protected void onVisibilityChanged ( View changedView , int visibility ) { super . onVisibilityChanged ( changedView , visibility ) ; if ( mIndeterminate ) { if ( visibility == GONE || visibility == INVISIBLE ) { stopAnimation ( ) ; } else { startAnimation ( ) ; } } } @ Override public void invalidateDrawable ( Drawable dr ) { if ( ! mInDrawing ) { if ( verifyDrawable ( dr ) ) { final Rect dirty = dr . getBounds ( ) ; final int scrollX = getScrollX ( ) + getPaddingLeft ( ) ; final int scrollY = getScrollY ( ) + getPaddingTop ( ) ; invalidate ( dirty . left + scrollX , dirty . top + scrollY , dirty . right + scrollX , dirty . bottom + scrollY ) ; } else { super . invalidateDrawable ( dr ) ; } } } @ Override protected void onSizeChanged ( int w , int h , int oldw , int oldh ) { updateDrawableBounds ( w , h ) ; } private void updateDrawableBounds ( int w , int h ) { int right = w - getPaddingRight ( ) - getPaddingLeft ( ) ; int bottom = h - getPaddingBottom ( ) - getPaddingTop ( ) ; int top = <NUM_LIT:0> ; int left = <NUM_LIT:0> ; if ( mIndeterminateDrawable != null ) { if ( mOnlyIndeterminate && ! ( mIndeterminateDrawable instanceof AnimationDrawable ) ) { final int intrinsicWidth = mIndeterminateDrawable . getIntrinsicWidth ( ) ; final int intrinsicHeight = mIndeterminateDrawable . getIntrinsicHeight ( ) ; final float intrinsicAspect = ( float ) intrinsicWidth / intrinsicHeight ; final float boundAspect = ( float ) w / h ; if ( intrinsicAspect != boundAspect ) { if ( boundAspect > intrinsicAspect ) { final int width = ( int ) ( h * intrinsicAspect ) ; left = ( w - width ) / <NUM_LIT:2> ; right = left + width ; } else { final int height = ( int ) ( w * ( <NUM_LIT:1> / intrinsicAspect ) ) ; top = ( h - height ) / <NUM_LIT:2> ; bottom = top + height ; } } } mIndeterminateDrawable . setBounds ( <NUM_LIT:0> , <NUM_LIT:0> , right - left , bottom - top ) ; mIndeterminateRealLeft = left ; mIndeterminateRealTop = top ; } if ( mProgressDrawable != null ) { mProgressDrawable . setBounds ( <NUM_LIT:0> , <NUM_LIT:0> , right , bottom ) ; } } @ Override protected synchronized void onDraw ( Canvas canvas ) { super . onDraw ( canvas ) ; Drawable d = mCurrentDrawable ; if ( d != null ) { canvas . save ( ) ; canvas . translate ( getPaddingLeft ( ) + mIndeterminateRealLeft , getPaddingTop ( ) + mIndeterminateRealTop ) ; long time = getDrawingTime ( ) ; if ( mAnimation != null ) { mAnimation . getTransformation ( time , mTransformation ) ; float scale = mTransformation . getAlpha ( ) ; try { mInDrawing = true ; d . setLevel ( ( int ) ( scale * MAX_LEVEL ) ) ; } finally { mInDrawing = false ; } if ( SystemClock . uptimeMillis ( ) - mLastDrawTime >= mAnimationResolution ) { mLastDrawTime = SystemClock . uptimeMillis ( ) ; postInvalidateDelayed ( mAnimationResolution ) ; } } d . draw ( canvas ) ; canvas . restore ( ) ; if ( mShouldStartAnimationDrawable && d instanceof Animatable ) { ( ( Animatable ) d ) . start ( ) ; mShouldStartAnimationDrawable = false ; } } } @ Override protected synchronized void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { Drawable d = mCurrentDrawable ; int dw = <NUM_LIT:0> ; int dh = <NUM_LIT:0> ; if ( d != null ) { dw = Math . max ( mMinWidth , Math . min ( mMaxWidth , d . getIntrinsicWidth ( ) ) ) ; dh = Math . max ( mMinHeight , Math . min ( mMaxHeight , d . getIntrinsicHeight ( ) ) ) ; } updateDrawableState ( ) ; dw += getPaddingLeft ( ) + getPaddingRight ( ) ; dh += getPaddingTop ( ) + getPaddingBottom ( ) ; if ( IS_HONEYCOMB ) { setMeasuredDimension ( View . resolveSizeAndState ( dw , widthMeasureSpec , <NUM_LIT:0> ) , View . resolveSizeAndState ( dh , heightMeasureSpec , <NUM_LIT:0> ) ) ; } else { setMeasuredDimension ( View . resolveSize ( dw , widthMeasureSpec ) , View . resolveSize ( dh , heightMeasureSpec ) ) ; } } @ Override protected void drawableStateChanged ( ) { super . drawableStateChanged ( ) ; updateDrawableState ( ) ; } private void updateDrawableState ( ) { int [ ] state = getDrawableState ( ) ; if ( mProgressDrawable != null && mProgressDrawable . isStateful ( ) ) { mProgressDrawable . setState ( state ) ; } if ( mIndeterminateDrawable != null && mIndeterminateDrawable . isStateful ( ) ) { mIndeterminateDrawable . setState ( state ) ; } } static class SavedState extends BaseSavedState { int progress ; int secondaryProgress ; SavedState ( Parcelable superState ) { super ( superState ) ; } private SavedState ( Parcel in ) { super ( in ) ; progress = in . readInt ( ) ; secondaryProgress = in . readInt ( ) ; } @ Override public void writeToParcel ( Parcel out , int flags ) { super . writeToParcel ( out , flags ) ; out . writeInt ( progress ) ; out . writeInt ( secondaryProgress ) ; } public static final Parcelable . Creator < SavedState > CREATOR = new Parcelable . Creator < SavedState > ( ) { public SavedState createFromParcel ( Parcel in ) { return new SavedState ( in ) ; } public SavedState [ ] newArray ( int size ) { return new SavedState [ size ] ; } } ; } @ Override public Parcelable onSaveInstanceState ( ) { Parcelable superState = super . onSaveInstanceState ( ) ; SavedState ss = new SavedState ( superState ) ; ss . progress = mProgress ; ss . secondaryProgress = mSecondaryProgress ; return ss ; } @ Override public void onRestoreInstanceState ( Parcelable state ) { SavedState ss = ( SavedState ) state ; super . onRestoreInstanceState ( ss . getSuperState ( ) ) ; setProgress ( ss . progress ) ; setSecondaryProgress ( ss . secondaryProgress ) ; } @ Override protected void onAttachedToWindow ( ) { super . onAttachedToWindow ( ) ; if ( mIndeterminate ) { startAnimation ( ) ; } } @ Override protected void onDetachedFromWindow ( ) { if ( mIndeterminate ) { stopAnimation ( ) ; } if ( mRefreshProgressRunnable != null ) { removeCallbacks ( mRefreshProgressRunnable ) ; } if ( mAccessibilityEventSender != null ) { removeCallbacks ( mAccessibilityEventSender ) ; } super . onDetachedFromWindow ( ) ; } @ Override public void onInitializeAccessibilityEvent ( AccessibilityEvent event ) { super . onInitializeAccessibilityEvent ( event ) ; event . setItemCount ( mMax ) ; event . setCurrentItemIndex ( mProgress ) ; } private void scheduleAccessibilityEventSender ( ) { if ( mAccessibilityEventSender == null ) { mAccessibilityEventSender = new AccessibilityEventSender ( ) ; } else { removeCallbacks ( mAccessibilityEventSender ) ; } postDelayed ( mAccessibilityEventSender , TIMEOUT_SEND_ACCESSIBILITY_EVENT ) ; } private class AccessibilityEventSender implements Runnable { public void run ( ) { sendAccessibilityEvent ( AccessibilityEvent . TYPE_VIEW_SELECTED ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . content . res . Configuration ; import android . content . res . TypedArray ; import android . graphics . drawable . Drawable ; import android . text . TextUtils . TruncateAt ; import android . util . AttributeSet ; import android . view . Gravity ; import android . view . LayoutInflater ; import android . view . View ; import android . view . ViewGroup ; import android . view . ViewParent ; import android . view . animation . DecelerateInterpolator ; import android . view . animation . Interpolator ; import android . widget . BaseAdapter ; import android . widget . ImageView ; import android . widget . LinearLayout ; import android . widget . ListView ; import com . actionbarsherlock . R ; import com . actionbarsherlock . app . ActionBar ; import com . actionbarsherlock . internal . nineoldandroids . animation . Animator ; import com . actionbarsherlock . internal . nineoldandroids . animation . ObjectAnimator ; import com . actionbarsherlock . internal . nineoldandroids . widget . NineHorizontalScrollView ; public class ScrollingTabContainerView extends NineHorizontalScrollView implements IcsAdapterView . OnItemSelectedListener { Runnable mTabSelector ; private TabClickListener mTabClickListener ; private IcsLinearLayout mTabLayout ; private IcsSpinner mTabSpinner ; private boolean mAllowCollapse ; private LayoutInflater mInflater ; int mMaxTabWidth ; private int mContentHeight ; private int mSelectedTabIndex ; protected Animator mVisibilityAnim ; protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener ( ) ; private static final Interpolator sAlphaInterpolator = new DecelerateInterpolator ( ) ; private static final int FADE_DURATION = <NUM_LIT> ; public ScrollingTabContainerView ( Context context ) { super ( context ) ; setHorizontalScrollBarEnabled ( false ) ; TypedArray a = getContext ( ) . obtainStyledAttributes ( null , R . styleable . SherlockActionBar , R . attr . actionBarStyle , <NUM_LIT:0> ) ; setContentHeight ( a . getLayoutDimension ( R . styleable . SherlockActionBar_height , <NUM_LIT:0> ) ) ; a . recycle ( ) ; mInflater = LayoutInflater . from ( context ) ; mTabLayout = createTabLayout ( ) ; addView ( mTabLayout , new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . WRAP_CONTENT , ViewGroup . LayoutParams . MATCH_PARENT ) ) ; } @ Override public void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { final int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; final boolean lockedExpanded = widthMode == MeasureSpec . EXACTLY ; setFillViewport ( lockedExpanded ) ; final int childCount = mTabLayout . getChildCount ( ) ; if ( childCount > <NUM_LIT:1> && ( widthMode == MeasureSpec . EXACTLY || widthMode == MeasureSpec . AT_MOST ) ) { if ( childCount > <NUM_LIT:2> ) { mMaxTabWidth = ( int ) ( MeasureSpec . getSize ( widthMeasureSpec ) * <NUM_LIT> ) ; } else { mMaxTabWidth = MeasureSpec . getSize ( widthMeasureSpec ) / <NUM_LIT:2> ; } } else { mMaxTabWidth = - <NUM_LIT:1> ; } heightMeasureSpec = MeasureSpec . makeMeasureSpec ( mContentHeight , MeasureSpec . EXACTLY ) ; final boolean canCollapse = ! lockedExpanded && mAllowCollapse ; if ( canCollapse ) { mTabLayout . measure ( MeasureSpec . UNSPECIFIED , heightMeasureSpec ) ; if ( mTabLayout . getMeasuredWidth ( ) > MeasureSpec . getSize ( widthMeasureSpec ) ) { performCollapse ( ) ; } else { performExpand ( ) ; } } else { performExpand ( ) ; } final int oldWidth = getMeasuredWidth ( ) ; super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; final int newWidth = getMeasuredWidth ( ) ; if ( lockedExpanded && oldWidth != newWidth ) { setTabSelected ( mSelectedTabIndex ) ; } } private boolean isCollapsed ( ) { return mTabSpinner != null && mTabSpinner . getParent ( ) == this ; } public void setAllowCollapse ( boolean allowCollapse ) { mAllowCollapse = allowCollapse ; } private void performCollapse ( ) { if ( isCollapsed ( ) ) return ; if ( mTabSpinner == null ) { mTabSpinner = createSpinner ( ) ; } removeView ( mTabLayout ) ; addView ( mTabSpinner , new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . WRAP_CONTENT , ViewGroup . LayoutParams . MATCH_PARENT ) ) ; if ( mTabSpinner . getAdapter ( ) == null ) { mTabSpinner . setAdapter ( new TabAdapter ( ) ) ; } if ( mTabSelector != null ) { removeCallbacks ( mTabSelector ) ; mTabSelector = null ; } mTabSpinner . setSelection ( mSelectedTabIndex ) ; } private boolean performExpand ( ) { if ( ! isCollapsed ( ) ) return false ; removeView ( mTabSpinner ) ; addView ( mTabLayout , new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . WRAP_CONTENT , ViewGroup . LayoutParams . MATCH_PARENT ) ) ; setTabSelected ( mTabSpinner . getSelectedItemPosition ( ) ) ; return false ; } public void setTabSelected ( int position ) { mSelectedTabIndex = position ; final int tabCount = mTabLayout . getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < tabCount ; i ++ ) { final View child = mTabLayout . getChildAt ( i ) ; final boolean isSelected = i == position ; child . setSelected ( isSelected ) ; if ( isSelected ) { animateToTab ( position ) ; } } } public void setContentHeight ( int contentHeight ) { mContentHeight = contentHeight ; requestLayout ( ) ; } private IcsLinearLayout createTabLayout ( ) { final IcsLinearLayout tabLayout = ( IcsLinearLayout ) LayoutInflater . from ( getContext ( ) ) . inflate ( R . layout . abs__action_bar_tab_bar_view , null ) ; tabLayout . setLayoutParams ( new LinearLayout . LayoutParams ( LinearLayout . LayoutParams . WRAP_CONTENT , LinearLayout . LayoutParams . MATCH_PARENT ) ) ; return tabLayout ; } private IcsSpinner createSpinner ( ) { final IcsSpinner spinner = new IcsSpinner ( getContext ( ) , null , R . attr . actionDropDownStyle ) ; spinner . setLayoutParams ( new LinearLayout . LayoutParams ( LinearLayout . LayoutParams . WRAP_CONTENT , LinearLayout . LayoutParams . MATCH_PARENT ) ) ; spinner . setOnItemSelectedListener ( this ) ; return spinner ; } @ Override protected void onConfigurationChanged ( Configuration newConfig ) { super . onConfigurationChanged ( newConfig ) ; TypedArray a = getContext ( ) . obtainStyledAttributes ( null , R . styleable . SherlockActionBar , R . attr . actionBarStyle , <NUM_LIT:0> ) ; setContentHeight ( a . getLayoutDimension ( R . styleable . SherlockActionBar_height , <NUM_LIT:0> ) ) ; a . recycle ( ) ; } public void animateToVisibility ( int visibility ) { if ( mVisibilityAnim != null ) { mVisibilityAnim . cancel ( ) ; } if ( visibility == VISIBLE ) { if ( getVisibility ( ) != VISIBLE ) { setAlpha ( <NUM_LIT:0> ) ; } ObjectAnimator anim = ObjectAnimator . ofFloat ( this , "<STR_LIT>" , <NUM_LIT:1> ) ; anim . setDuration ( FADE_DURATION ) ; anim . setInterpolator ( sAlphaInterpolator ) ; anim . addListener ( mVisAnimListener . withFinalVisibility ( visibility ) ) ; anim . start ( ) ; } else { ObjectAnimator anim = ObjectAnimator . ofFloat ( this , "<STR_LIT>" , <NUM_LIT:0> ) ; anim . setDuration ( FADE_DURATION ) ; anim . setInterpolator ( sAlphaInterpolator ) ; anim . addListener ( mVisAnimListener . withFinalVisibility ( visibility ) ) ; anim . start ( ) ; } } public void animateToTab ( final int position ) { final View tabView = mTabLayout . getChildAt ( position ) ; if ( mTabSelector != null ) { removeCallbacks ( mTabSelector ) ; } mTabSelector = new Runnable ( ) { public void run ( ) { final int scrollPos = tabView . getLeft ( ) - ( getWidth ( ) - tabView . getWidth ( ) ) / <NUM_LIT:2> ; smoothScrollTo ( scrollPos , <NUM_LIT:0> ) ; mTabSelector = null ; } } ; post ( mTabSelector ) ; } @ Override public void onAttachedToWindow ( ) { super . onAttachedToWindow ( ) ; if ( mTabSelector != null ) { post ( mTabSelector ) ; } } @ Override public void onDetachedFromWindow ( ) { super . onDetachedFromWindow ( ) ; if ( mTabSelector != null ) { removeCallbacks ( mTabSelector ) ; } } private TabView createTabView ( ActionBar . Tab tab , boolean forAdapter ) { final TabView tabView = ( TabView ) mInflater . inflate ( R . layout . abs__action_bar_tab , null ) ; tabView . init ( this , tab , forAdapter ) ; if ( forAdapter ) { tabView . setBackgroundDrawable ( null ) ; tabView . setLayoutParams ( new ListView . LayoutParams ( ListView . LayoutParams . MATCH_PARENT , mContentHeight ) ) ; } else { tabView . setFocusable ( true ) ; if ( mTabClickListener == null ) { mTabClickListener = new TabClickListener ( ) ; } tabView . setOnClickListener ( mTabClickListener ) ; } return tabView ; } public void addTab ( ActionBar . Tab tab , boolean setSelected ) { TabView tabView = createTabView ( tab , false ) ; mTabLayout . addView ( tabView , new IcsLinearLayout . LayoutParams ( <NUM_LIT:0> , LayoutParams . MATCH_PARENT , <NUM_LIT:1> ) ) ; if ( mTabSpinner != null ) { ( ( TabAdapter ) mTabSpinner . getAdapter ( ) ) . notifyDataSetChanged ( ) ; } if ( setSelected ) { tabView . setSelected ( true ) ; } if ( mAllowCollapse ) { requestLayout ( ) ; } } public void addTab ( ActionBar . Tab tab , int position , boolean setSelected ) { final TabView tabView = createTabView ( tab , false ) ; mTabLayout . addView ( tabView , position , new IcsLinearLayout . LayoutParams ( <NUM_LIT:0> , LayoutParams . MATCH_PARENT , <NUM_LIT:1> ) ) ; if ( mTabSpinner != null ) { ( ( TabAdapter ) mTabSpinner . getAdapter ( ) ) . notifyDataSetChanged ( ) ; } if ( setSelected ) { tabView . setSelected ( true ) ; } if ( mAllowCollapse ) { requestLayout ( ) ; } } public void updateTab ( int position ) { ( ( TabView ) mTabLayout . getChildAt ( position ) ) . update ( ) ; if ( mTabSpinner != null ) { ( ( TabAdapter ) mTabSpinner . getAdapter ( ) ) . notifyDataSetChanged ( ) ; } if ( mAllowCollapse ) { requestLayout ( ) ; } } public void removeTabAt ( int position ) { mTabLayout . removeViewAt ( position ) ; if ( mTabSpinner != null ) { ( ( TabAdapter ) mTabSpinner . getAdapter ( ) ) . notifyDataSetChanged ( ) ; } if ( mAllowCollapse ) { requestLayout ( ) ; } } public void removeAllTabs ( ) { mTabLayout . removeAllViews ( ) ; if ( mTabSpinner != null ) { ( ( TabAdapter ) mTabSpinner . getAdapter ( ) ) . notifyDataSetChanged ( ) ; } if ( mAllowCollapse ) { requestLayout ( ) ; } } @ Override public void onItemSelected ( IcsAdapterView < ? > parent , View view , int position , long id ) { TabView tabView = ( TabView ) view ; tabView . getTab ( ) . select ( ) ; } @ Override public void onNothingSelected ( IcsAdapterView < ? > parent ) { } public static class TabView extends LinearLayout { private ScrollingTabContainerView mParent ; private ActionBar . Tab mTab ; private CapitalizingTextView mTextView ; private ImageView mIconView ; private View mCustomView ; public TabView ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; } public void init ( ScrollingTabContainerView parent , ActionBar . Tab tab , boolean forList ) { mParent = parent ; mTab = tab ; if ( forList ) { setGravity ( Gravity . LEFT | Gravity . CENTER_VERTICAL ) ; } update ( ) ; } public void bindTab ( ActionBar . Tab tab ) { mTab = tab ; update ( ) ; } @ Override public void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; if ( mParent . mMaxTabWidth > <NUM_LIT:0> && getMeasuredWidth ( ) > mParent . mMaxTabWidth ) { super . onMeasure ( MeasureSpec . makeMeasureSpec ( mParent . mMaxTabWidth , MeasureSpec . EXACTLY ) , heightMeasureSpec ) ; } } public void update ( ) { final ActionBar . Tab tab = mTab ; final View custom = tab . getCustomView ( ) ; if ( custom != null ) { final ViewParent customParent = custom . getParent ( ) ; if ( customParent != this ) { if ( customParent != null ) ( ( ViewGroup ) customParent ) . removeView ( custom ) ; addView ( custom ) ; } mCustomView = custom ; if ( mTextView != null ) mTextView . setVisibility ( GONE ) ; if ( mIconView != null ) { mIconView . setVisibility ( GONE ) ; mIconView . setImageDrawable ( null ) ; } } else { if ( mCustomView != null ) { removeView ( mCustomView ) ; mCustomView = null ; } final Drawable icon = tab . getIcon ( ) ; final CharSequence text = tab . getText ( ) ; if ( icon != null ) { if ( mIconView == null ) { ImageView iconView = new ImageView ( getContext ( ) ) ; LayoutParams lp = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; lp . gravity = Gravity . CENTER_VERTICAL ; iconView . setLayoutParams ( lp ) ; addView ( iconView , <NUM_LIT:0> ) ; mIconView = iconView ; } mIconView . setImageDrawable ( icon ) ; mIconView . setVisibility ( VISIBLE ) ; } else if ( mIconView != null ) { mIconView . setVisibility ( GONE ) ; mIconView . setImageDrawable ( null ) ; } if ( text != null ) { if ( mTextView == null ) { CapitalizingTextView textView = new CapitalizingTextView ( getContext ( ) , null , R . attr . actionBarTabTextStyle ) ; textView . setEllipsize ( TruncateAt . END ) ; LayoutParams lp = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; lp . gravity = Gravity . CENTER_VERTICAL ; textView . setLayoutParams ( lp ) ; addView ( textView ) ; mTextView = textView ; } mTextView . setTextCompat ( text ) ; mTextView . setVisibility ( VISIBLE ) ; } else if ( mTextView != null ) { mTextView . setVisibility ( GONE ) ; mTextView . setText ( null ) ; } if ( mIconView != null ) { mIconView . setContentDescription ( tab . getContentDescription ( ) ) ; } } } public ActionBar . Tab getTab ( ) { return mTab ; } } private class TabAdapter extends BaseAdapter { @ Override public int getCount ( ) { return mTabLayout . getChildCount ( ) ; } @ Override public Object getItem ( int position ) { return ( ( TabView ) mTabLayout . getChildAt ( position ) ) . getTab ( ) ; } @ Override public long getItemId ( int position ) { return position ; } @ Override public View getView ( int position , View convertView , ViewGroup parent ) { if ( convertView == null ) { convertView = createTabView ( ( ActionBar . Tab ) getItem ( position ) , true ) ; } else { ( ( TabView ) convertView ) . bindTab ( ( ActionBar . Tab ) getItem ( position ) ) ; } return convertView ; } } private class TabClickListener implements OnClickListener { public void onClick ( View view ) { TabView tabView = ( TabView ) view ; tabView . getTab ( ) . select ( ) ; final int tabCount = mTabLayout . getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < tabCount ; i ++ ) { final View child = mTabLayout . getChildAt ( i ) ; child . setSelected ( child == view ) ; } } } protected class VisibilityAnimListener implements Animator . AnimatorListener { private boolean mCanceled = false ; private int mFinalVisibility ; public VisibilityAnimListener withFinalVisibility ( int visibility ) { mFinalVisibility = visibility ; return this ; } @ Override public void onAnimationStart ( Animator animation ) { setVisibility ( VISIBLE ) ; mVisibilityAnim = animation ; mCanceled = false ; } @ Override public void onAnimationEnd ( Animator animation ) { if ( mCanceled ) return ; mVisibilityAnim = null ; setVisibility ( mFinalVisibility ) ; } @ Override public void onAnimationCancel ( Animator animation ) { mCanceled = true ; } @ Override public void onAnimationRepeat ( Animator animation ) { } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . database . DataSetObserver ; import android . graphics . Rect ; import android . os . Build ; import android . os . Parcel ; import android . os . Parcelable ; import android . util . AttributeSet ; import android . util . SparseArray ; import android . view . View ; import android . view . ViewGroup ; import android . widget . SpinnerAdapter ; public abstract class IcsAbsSpinner extends IcsAdapterView < SpinnerAdapter > { private static final boolean IS_HONEYCOMB = Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ; SpinnerAdapter mAdapter ; int mHeightMeasureSpec ; int mWidthMeasureSpec ; boolean mBlockLayoutRequests ; int mSelectionLeftPadding = <NUM_LIT:0> ; int mSelectionTopPadding = <NUM_LIT:0> ; int mSelectionRightPadding = <NUM_LIT:0> ; int mSelectionBottomPadding = <NUM_LIT:0> ; final Rect mSpinnerPadding = new Rect ( ) ; final RecycleBin mRecycler = new RecycleBin ( ) ; private DataSetObserver mDataSetObserver ; private Rect mTouchFrame ; public IcsAbsSpinner ( Context context ) { super ( context ) ; initAbsSpinner ( ) ; } public IcsAbsSpinner ( Context context , AttributeSet attrs ) { this ( context , attrs , <NUM_LIT:0> ) ; } public IcsAbsSpinner ( Context context , AttributeSet attrs , int defStyle ) { super ( context , attrs , defStyle ) ; initAbsSpinner ( ) ; } private void initAbsSpinner ( ) { setFocusable ( true ) ; setWillNotDraw ( false ) ; } @ Override public void setAdapter ( SpinnerAdapter adapter ) { if ( null != mAdapter ) { mAdapter . unregisterDataSetObserver ( mDataSetObserver ) ; resetList ( ) ; } mAdapter = adapter ; mOldSelectedPosition = INVALID_POSITION ; mOldSelectedRowId = INVALID_ROW_ID ; if ( mAdapter != null ) { mOldItemCount = mItemCount ; mItemCount = mAdapter . getCount ( ) ; checkFocus ( ) ; mDataSetObserver = new AdapterDataSetObserver ( ) ; mAdapter . registerDataSetObserver ( mDataSetObserver ) ; int position = mItemCount > <NUM_LIT:0> ? <NUM_LIT:0> : INVALID_POSITION ; setSelectedPositionInt ( position ) ; setNextSelectedPositionInt ( position ) ; if ( mItemCount == <NUM_LIT:0> ) { checkSelectionChanged ( ) ; } } else { checkFocus ( ) ; resetList ( ) ; checkSelectionChanged ( ) ; } requestLayout ( ) ; } void resetList ( ) { mDataChanged = false ; mNeedSync = false ; removeAllViewsInLayout ( ) ; mOldSelectedPosition = INVALID_POSITION ; mOldSelectedRowId = INVALID_ROW_ID ; setSelectedPositionInt ( INVALID_POSITION ) ; setNextSelectedPositionInt ( INVALID_POSITION ) ; invalidate ( ) ; } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; int widthSize ; int heightSize ; final int mPaddingLeft = getPaddingLeft ( ) ; final int mPaddingTop = getPaddingTop ( ) ; final int mPaddingRight = getPaddingRight ( ) ; final int mPaddingBottom = getPaddingBottom ( ) ; mSpinnerPadding . left = mPaddingLeft > mSelectionLeftPadding ? mPaddingLeft : mSelectionLeftPadding ; mSpinnerPadding . top = mPaddingTop > mSelectionTopPadding ? mPaddingTop : mSelectionTopPadding ; mSpinnerPadding . right = mPaddingRight > mSelectionRightPadding ? mPaddingRight : mSelectionRightPadding ; mSpinnerPadding . bottom = mPaddingBottom > mSelectionBottomPadding ? mPaddingBottom : mSelectionBottomPadding ; if ( mDataChanged ) { handleDataChanged ( ) ; } int preferredHeight = <NUM_LIT:0> ; int preferredWidth = <NUM_LIT:0> ; boolean needsMeasuring = true ; int selectedPosition = getSelectedItemPosition ( ) ; if ( selectedPosition >= <NUM_LIT:0> && mAdapter != null && selectedPosition < mAdapter . getCount ( ) ) { View view = mRecycler . get ( selectedPosition ) ; if ( view == null ) { view = mAdapter . getView ( selectedPosition , null , this ) ; } if ( view != null ) { mRecycler . put ( selectedPosition , view ) ; } if ( view != null ) { if ( view . getLayoutParams ( ) == null ) { mBlockLayoutRequests = true ; view . setLayoutParams ( generateDefaultLayoutParams ( ) ) ; mBlockLayoutRequests = false ; } measureChild ( view , widthMeasureSpec , heightMeasureSpec ) ; preferredHeight = getChildHeight ( view ) + mSpinnerPadding . top + mSpinnerPadding . bottom ; preferredWidth = getChildWidth ( view ) + mSpinnerPadding . left + mSpinnerPadding . right ; needsMeasuring = false ; } } if ( needsMeasuring ) { preferredHeight = mSpinnerPadding . top + mSpinnerPadding . bottom ; if ( widthMode == MeasureSpec . UNSPECIFIED ) { preferredWidth = mSpinnerPadding . left + mSpinnerPadding . right ; } } preferredHeight = Math . max ( preferredHeight , getSuggestedMinimumHeight ( ) ) ; preferredWidth = Math . max ( preferredWidth , getSuggestedMinimumWidth ( ) ) ; if ( IS_HONEYCOMB ) { heightSize = resolveSizeAndState ( preferredHeight , heightMeasureSpec , <NUM_LIT:0> ) ; widthSize = resolveSizeAndState ( preferredWidth , widthMeasureSpec , <NUM_LIT:0> ) ; } else { heightSize = resolveSize ( preferredHeight , heightMeasureSpec ) ; widthSize = resolveSize ( preferredWidth , widthMeasureSpec ) ; } setMeasuredDimension ( widthSize , heightSize ) ; mHeightMeasureSpec = heightMeasureSpec ; mWidthMeasureSpec = widthMeasureSpec ; } int getChildHeight ( View child ) { return child . getMeasuredHeight ( ) ; } int getChildWidth ( View child ) { return child . getMeasuredWidth ( ) ; } @ Override protected ViewGroup . LayoutParams generateDefaultLayoutParams ( ) { return new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ; } void recycleAllViews ( ) { final int childCount = getChildCount ( ) ; final IcsAbsSpinner . RecycleBin recycleBin = mRecycler ; final int position = mFirstPosition ; for ( int i = <NUM_LIT:0> ; i < childCount ; i ++ ) { View v = getChildAt ( i ) ; int index = position + i ; recycleBin . put ( index , v ) ; } } public void setSelection ( int position , boolean animate ) { boolean shouldAnimate = animate && mFirstPosition <= position && position <= mFirstPosition + getChildCount ( ) - <NUM_LIT:1> ; setSelectionInt ( position , shouldAnimate ) ; } @ Override public void setSelection ( int position ) { setNextSelectedPositionInt ( position ) ; requestLayout ( ) ; invalidate ( ) ; } void setSelectionInt ( int position , boolean animate ) { if ( position != mOldSelectedPosition ) { mBlockLayoutRequests = true ; int delta = position - mSelectedPosition ; setNextSelectedPositionInt ( position ) ; layout ( delta , animate ) ; mBlockLayoutRequests = false ; } } abstract void layout ( int delta , boolean animate ) ; @ Override public View getSelectedView ( ) { if ( mItemCount > <NUM_LIT:0> && mSelectedPosition >= <NUM_LIT:0> ) { return getChildAt ( mSelectedPosition - mFirstPosition ) ; } else { return null ; } } @ Override public void requestLayout ( ) { if ( ! mBlockLayoutRequests ) { super . requestLayout ( ) ; } } @ Override public SpinnerAdapter getAdapter ( ) { return mAdapter ; } @ Override public int getCount ( ) { return mItemCount ; } public int pointToPosition ( int x , int y ) { Rect frame = mTouchFrame ; if ( frame == null ) { mTouchFrame = new Rect ( ) ; frame = mTouchFrame ; } final int count = getChildCount ( ) ; for ( int i = count - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { View child = getChildAt ( i ) ; if ( child . getVisibility ( ) == View . VISIBLE ) { child . getHitRect ( frame ) ; if ( frame . contains ( x , y ) ) { return mFirstPosition + i ; } } } return INVALID_POSITION ; } static class SavedState extends BaseSavedState { long selectedId ; int position ; SavedState ( Parcelable superState ) { super ( superState ) ; } private SavedState ( Parcel in ) { super ( in ) ; selectedId = in . readLong ( ) ; position = in . readInt ( ) ; } @ Override public void writeToParcel ( Parcel out , int flags ) { super . writeToParcel ( out , flags ) ; out . writeLong ( selectedId ) ; out . writeInt ( position ) ; } @ Override public String toString ( ) { return "<STR_LIT>" + Integer . toHexString ( System . identityHashCode ( this ) ) + "<STR_LIT>" + selectedId + "<STR_LIT>" + position + "<STR_LIT:}>" ; } public static final Parcelable . Creator < SavedState > CREATOR = new Parcelable . Creator < SavedState > ( ) { public SavedState createFromParcel ( Parcel in ) { return new SavedState ( in ) ; } public SavedState [ ] newArray ( int size ) { return new SavedState [ size ] ; } } ; } @ Override public Parcelable onSaveInstanceState ( ) { Parcelable superState = super . onSaveInstanceState ( ) ; SavedState ss = new SavedState ( superState ) ; ss . selectedId = getSelectedItemId ( ) ; if ( ss . selectedId >= <NUM_LIT:0> ) { ss . position = getSelectedItemPosition ( ) ; } else { ss . position = INVALID_POSITION ; } return ss ; } @ Override public void onRestoreInstanceState ( Parcelable state ) { SavedState ss = ( SavedState ) state ; super . onRestoreInstanceState ( ss . getSuperState ( ) ) ; if ( ss . selectedId >= <NUM_LIT:0> ) { mDataChanged = true ; mNeedSync = true ; mSyncRowId = ss . selectedId ; mSyncPosition = ss . position ; mSyncMode = SYNC_SELECTED_POSITION ; requestLayout ( ) ; } } class RecycleBin { private final SparseArray < View > mScrapHeap = new SparseArray < View > ( ) ; public void put ( int position , View v ) { mScrapHeap . put ( position , v ) ; } View get ( int position ) { View result = mScrapHeap . get ( position ) ; if ( result != null ) { mScrapHeap . delete ( position ) ; } else { } return result ; } void clear ( ) { final SparseArray < View > scrapHeap = mScrapHeap ; final int count = scrapHeap . size ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { final View view = scrapHeap . valueAt ( i ) ; if ( view != null ) { removeDetachedView ( view , true ) ; } } scrapHeap . clear ( ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . content . res . Configuration ; import android . content . res . TypedArray ; import android . os . Build ; import android . util . AttributeSet ; import android . view . View ; import android . view . animation . DecelerateInterpolator ; import android . view . animation . Interpolator ; import com . actionbarsherlock . R ; import com . actionbarsherlock . internal . nineoldandroids . animation . Animator ; import com . actionbarsherlock . internal . nineoldandroids . animation . AnimatorSet ; import com . actionbarsherlock . internal . nineoldandroids . animation . ObjectAnimator ; import com . actionbarsherlock . internal . nineoldandroids . view . NineViewGroup ; import com . actionbarsherlock . internal . view . menu . ActionMenuPresenter ; import com . actionbarsherlock . internal . view . menu . ActionMenuView ; import static com . actionbarsherlock . internal . ResourcesCompat . getResources_getBoolean ; public abstract class AbsActionBarView extends NineViewGroup { protected ActionMenuView mMenuView ; protected ActionMenuPresenter mActionMenuPresenter ; protected ActionBarContainer mSplitView ; protected boolean mSplitActionBar ; protected boolean mSplitWhenNarrow ; protected int mContentHeight ; final Context mContext ; protected Animator mVisibilityAnim ; protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener ( ) ; private static final Interpolator sAlphaInterpolator = new DecelerateInterpolator ( ) ; private static final int FADE_DURATION = <NUM_LIT> ; public AbsActionBarView ( Context context ) { super ( context ) ; mContext = context ; } public AbsActionBarView ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; mContext = context ; } public AbsActionBarView ( Context context , AttributeSet attrs , int defStyle ) { super ( context , attrs , defStyle ) ; mContext = context ; } @ Override public void onConfigurationChanged ( Configuration newConfig ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . FROYO ) { super . onConfigurationChanged ( newConfig ) ; } else if ( mMenuView != null ) { mMenuView . onConfigurationChanged ( newConfig ) ; } TypedArray a = getContext ( ) . obtainStyledAttributes ( null , R . styleable . SherlockActionBar , R . attr . actionBarStyle , <NUM_LIT:0> ) ; setContentHeight ( a . getLayoutDimension ( R . styleable . SherlockActionBar_height , <NUM_LIT:0> ) ) ; a . recycle ( ) ; if ( mSplitWhenNarrow ) { setSplitActionBar ( getResources_getBoolean ( getContext ( ) , R . bool . abs__split_action_bar_is_narrow ) ) ; } if ( mActionMenuPresenter != null ) { mActionMenuPresenter . onConfigurationChanged ( newConfig ) ; } } public void setSplitActionBar ( boolean split ) { mSplitActionBar = split ; } public void setSplitWhenNarrow ( boolean splitWhenNarrow ) { mSplitWhenNarrow = splitWhenNarrow ; } public void setContentHeight ( int height ) { mContentHeight = height ; requestLayout ( ) ; } public int getContentHeight ( ) { return mContentHeight ; } public void setSplitView ( ActionBarContainer splitView ) { mSplitView = splitView ; } public int getAnimatedVisibility ( ) { if ( mVisibilityAnim != null ) { return mVisAnimListener . mFinalVisibility ; } return getVisibility ( ) ; } public void animateToVisibility ( int visibility ) { if ( mVisibilityAnim != null ) { mVisibilityAnim . cancel ( ) ; } if ( visibility == VISIBLE ) { if ( getVisibility ( ) != VISIBLE ) { setAlpha ( <NUM_LIT:0> ) ; if ( mSplitView != null && mMenuView != null ) { mMenuView . setAlpha ( <NUM_LIT:0> ) ; } } ObjectAnimator anim = ObjectAnimator . ofFloat ( this , "<STR_LIT>" , <NUM_LIT:1> ) ; anim . setDuration ( FADE_DURATION ) ; anim . setInterpolator ( sAlphaInterpolator ) ; if ( mSplitView != null && mMenuView != null ) { AnimatorSet set = new AnimatorSet ( ) ; ObjectAnimator splitAnim = ObjectAnimator . ofFloat ( mMenuView , "<STR_LIT>" , <NUM_LIT:1> ) ; splitAnim . setDuration ( FADE_DURATION ) ; set . addListener ( mVisAnimListener . withFinalVisibility ( visibility ) ) ; set . play ( anim ) . with ( splitAnim ) ; set . start ( ) ; } else { anim . addListener ( mVisAnimListener . withFinalVisibility ( visibility ) ) ; anim . start ( ) ; } } else { ObjectAnimator anim = ObjectAnimator . ofFloat ( this , "<STR_LIT>" , <NUM_LIT:0> ) ; anim . setDuration ( FADE_DURATION ) ; anim . setInterpolator ( sAlphaInterpolator ) ; if ( mSplitView != null && mMenuView != null ) { AnimatorSet set = new AnimatorSet ( ) ; ObjectAnimator splitAnim = ObjectAnimator . ofFloat ( mMenuView , "<STR_LIT>" , <NUM_LIT:0> ) ; splitAnim . setDuration ( FADE_DURATION ) ; set . addListener ( mVisAnimListener . withFinalVisibility ( visibility ) ) ; set . play ( anim ) . with ( splitAnim ) ; set . start ( ) ; } else { anim . addListener ( mVisAnimListener . withFinalVisibility ( visibility ) ) ; anim . start ( ) ; } } } @ Override public void setVisibility ( int visibility ) { if ( mVisibilityAnim != null ) { mVisibilityAnim . end ( ) ; } super . setVisibility ( visibility ) ; } public boolean showOverflowMenu ( ) { if ( mActionMenuPresenter != null ) { return mActionMenuPresenter . showOverflowMenu ( ) ; } return false ; } public void postShowOverflowMenu ( ) { post ( new Runnable ( ) { public void run ( ) { showOverflowMenu ( ) ; } } ) ; } public boolean hideOverflowMenu ( ) { if ( mActionMenuPresenter != null ) { return mActionMenuPresenter . hideOverflowMenu ( ) ; } return false ; } public boolean isOverflowMenuShowing ( ) { if ( mActionMenuPresenter != null ) { return mActionMenuPresenter . isOverflowMenuShowing ( ) ; } return false ; } public boolean isOverflowReserved ( ) { return mActionMenuPresenter != null && mActionMenuPresenter . isOverflowReserved ( ) ; } public void dismissPopupMenus ( ) { if ( mActionMenuPresenter != null ) { mActionMenuPresenter . dismissPopupMenus ( ) ; } } protected int measureChildView ( View child , int availableWidth , int childSpecHeight , int spacing ) { child . measure ( MeasureSpec . makeMeasureSpec ( availableWidth , MeasureSpec . AT_MOST ) , childSpecHeight ) ; availableWidth -= child . getMeasuredWidth ( ) ; availableWidth -= spacing ; return Math . max ( <NUM_LIT:0> , availableWidth ) ; } protected int positionChild ( View child , int x , int y , int contentHeight ) { int childWidth = child . getMeasuredWidth ( ) ; int childHeight = child . getMeasuredHeight ( ) ; int childTop = y + ( contentHeight - childHeight ) / <NUM_LIT:2> ; child . layout ( x , childTop , x + childWidth , childTop + childHeight ) ; return childWidth ; } protected int positionChildInverse ( View child , int x , int y , int contentHeight ) { int childWidth = child . getMeasuredWidth ( ) ; int childHeight = child . getMeasuredHeight ( ) ; int childTop = y + ( contentHeight - childHeight ) / <NUM_LIT:2> ; child . layout ( x - childWidth , childTop , x , childTop + childHeight ) ; return childWidth ; } protected class VisibilityAnimListener implements Animator . AnimatorListener { private boolean mCanceled = false ; int mFinalVisibility ; public VisibilityAnimListener withFinalVisibility ( int visibility ) { mFinalVisibility = visibility ; return this ; } @ Override public void onAnimationStart ( Animator animation ) { setVisibility ( VISIBLE ) ; mVisibilityAnim = animation ; mCanceled = false ; } @ Override public void onAnimationEnd ( Animator animation ) { if ( mCanceled ) return ; mVisibilityAnim = null ; setVisibility ( mFinalVisibility ) ; if ( mSplitView != null && mMenuView != null ) { mMenuView . setVisibility ( mFinalVisibility ) ; } } @ Override public void onAnimationCancel ( Animator animation ) { mCanceled = true ; } @ Override public void onAnimationRepeat ( Animator animation ) { } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . content . res . TypedArray ; import android . graphics . Canvas ; import android . graphics . drawable . Drawable ; import android . util . AttributeSet ; import android . view . MotionEvent ; import android . view . View ; import android . view . ViewGroup ; import com . actionbarsherlock . R ; import com . actionbarsherlock . app . ActionBar ; import com . actionbarsherlock . internal . nineoldandroids . widget . NineFrameLayout ; public class ActionBarContainer extends NineFrameLayout { private boolean mIsTransitioning ; private View mTabContainer ; private ActionBarView mActionBarView ; private Drawable mBackground ; private Drawable mStackedBackground ; private Drawable mSplitBackground ; private boolean mIsSplit ; private boolean mIsStacked ; public ActionBarContainer ( Context context ) { this ( context , null ) ; } public ActionBarContainer ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; setBackgroundDrawable ( null ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . SherlockActionBar ) ; mBackground = a . getDrawable ( R . styleable . SherlockActionBar_background ) ; mStackedBackground = a . getDrawable ( R . styleable . SherlockActionBar_backgroundStacked ) ; if ( getId ( ) == R . id . abs__split_action_bar ) { mIsSplit = true ; mSplitBackground = a . getDrawable ( R . styleable . SherlockActionBar_backgroundSplit ) ; } a . recycle ( ) ; setWillNotDraw ( mIsSplit ? mSplitBackground == null : mBackground == null && mStackedBackground == null ) ; } @ Override public void onFinishInflate ( ) { super . onFinishInflate ( ) ; mActionBarView = ( ActionBarView ) findViewById ( R . id . abs__action_bar ) ; } public void setPrimaryBackground ( Drawable bg ) { mBackground = bg ; invalidate ( ) ; } public void setStackedBackground ( Drawable bg ) { mStackedBackground = bg ; invalidate ( ) ; } public void setSplitBackground ( Drawable bg ) { mSplitBackground = bg ; invalidate ( ) ; } public void setTransitioning ( boolean isTransitioning ) { mIsTransitioning = isTransitioning ; setDescendantFocusability ( isTransitioning ? FOCUS_BLOCK_DESCENDANTS : FOCUS_AFTER_DESCENDANTS ) ; } @ Override public boolean onInterceptTouchEvent ( MotionEvent ev ) { return mIsTransitioning || super . onInterceptTouchEvent ( ev ) ; } @ Override public boolean onTouchEvent ( MotionEvent ev ) { super . onTouchEvent ( ev ) ; return true ; } @ Override public boolean onHoverEvent ( MotionEvent ev ) { super . onHoverEvent ( ev ) ; return true ; } public void setTabContainer ( ScrollingTabContainerView tabView ) { if ( mTabContainer != null ) { removeView ( mTabContainer ) ; } mTabContainer = tabView ; if ( tabView != null ) { addView ( tabView ) ; final ViewGroup . LayoutParams lp = tabView . getLayoutParams ( ) ; lp . width = LayoutParams . MATCH_PARENT ; lp . height = LayoutParams . WRAP_CONTENT ; tabView . setAllowCollapse ( false ) ; } } public View getTabContainer ( ) { return mTabContainer ; } @ Override public void onDraw ( Canvas canvas ) { if ( getWidth ( ) == <NUM_LIT:0> || getHeight ( ) == <NUM_LIT:0> ) { return ; } if ( mIsSplit ) { if ( mSplitBackground != null ) mSplitBackground . draw ( canvas ) ; } else { if ( mBackground != null ) { mBackground . draw ( canvas ) ; } if ( mStackedBackground != null && mIsStacked ) { mStackedBackground . draw ( canvas ) ; } } } @ Override public void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; if ( mActionBarView == null ) return ; final LayoutParams lp = ( LayoutParams ) mActionBarView . getLayoutParams ( ) ; final int actionBarViewHeight = mActionBarView . isCollapsed ( ) ? <NUM_LIT:0> : mActionBarView . getMeasuredHeight ( ) + lp . topMargin + lp . bottomMargin ; if ( mTabContainer != null && mTabContainer . getVisibility ( ) != GONE ) { final int mode = MeasureSpec . getMode ( heightMeasureSpec ) ; if ( mode == MeasureSpec . AT_MOST ) { final int maxHeight = MeasureSpec . getSize ( heightMeasureSpec ) ; setMeasuredDimension ( getMeasuredWidth ( ) , Math . min ( actionBarViewHeight + mTabContainer . getMeasuredHeight ( ) , maxHeight ) ) ; } } } @ Override public void onLayout ( boolean changed , int l , int t , int r , int b ) { super . onLayout ( changed , l , t , r , b ) ; final boolean hasTabs = mTabContainer != null && mTabContainer . getVisibility ( ) != GONE ; if ( mTabContainer != null && mTabContainer . getVisibility ( ) != GONE ) { final int containerHeight = getMeasuredHeight ( ) ; final int tabHeight = mTabContainer . getMeasuredHeight ( ) ; if ( ( mActionBarView . getDisplayOptions ( ) & ActionBar . DISPLAY_SHOW_HOME ) == <NUM_LIT:0> ) { final int count = getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { final View child = getChildAt ( i ) ; if ( child == mTabContainer ) continue ; if ( ! mActionBarView . isCollapsed ( ) ) { child . offsetTopAndBottom ( tabHeight ) ; } } mTabContainer . layout ( l , <NUM_LIT:0> , r , tabHeight ) ; } else { mTabContainer . layout ( l , containerHeight - tabHeight , r , containerHeight ) ; } } boolean needsInvalidate = false ; if ( mIsSplit ) { if ( mSplitBackground != null ) { mSplitBackground . setBounds ( <NUM_LIT:0> , <NUM_LIT:0> , getMeasuredWidth ( ) , getMeasuredHeight ( ) ) ; needsInvalidate = true ; } } else { if ( mBackground != null ) { mBackground . setBounds ( mActionBarView . getLeft ( ) , mActionBarView . getTop ( ) , mActionBarView . getRight ( ) , mActionBarView . getBottom ( ) ) ; needsInvalidate = true ; } if ( ( mIsStacked = hasTabs && mStackedBackground != null ) ) { mStackedBackground . setBounds ( mTabContainer . getLeft ( ) , mTabContainer . getTop ( ) , mTabContainer . getRight ( ) , mTabContainer . getBottom ( ) ) ; needsInvalidate = true ; } } if ( needsInvalidate ) { invalidate ( ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import com . actionbarsherlock . R ; import android . content . Context ; import android . content . res . Resources ; import android . database . DataSetObserver ; import android . graphics . Rect ; import android . graphics . drawable . Drawable ; import android . os . Build ; import android . os . Handler ; import android . util . AttributeSet ; import android . view . ContextThemeWrapper ; import android . view . MotionEvent ; import android . view . View ; import android . view . View . MeasureSpec ; import android . view . View . OnTouchListener ; import android . view . ViewGroup ; import android . view . ViewParent ; import android . widget . AbsListView ; import android . widget . AdapterView ; import android . widget . LinearLayout ; import android . widget . ListAdapter ; import android . widget . ListView ; import android . widget . PopupWindow ; public class IcsListPopupWindow { private static final int EXPAND_LIST_TIMEOUT = <NUM_LIT> ; private Context mContext ; private PopupWindow mPopup ; private ListAdapter mAdapter ; private DropDownListView mDropDownList ; private int mDropDownHeight = ViewGroup . LayoutParams . WRAP_CONTENT ; private int mDropDownWidth = ViewGroup . LayoutParams . WRAP_CONTENT ; private int mDropDownHorizontalOffset ; private int mDropDownVerticalOffset ; private boolean mDropDownVerticalOffsetSet ; private int mListItemExpandMaximum = Integer . MAX_VALUE ; private View mPromptView ; private int mPromptPosition = POSITION_PROMPT_ABOVE ; private DataSetObserver mObserver ; private View mDropDownAnchorView ; private Drawable mDropDownListHighlight ; private AdapterView . OnItemClickListener mItemClickListener ; private AdapterView . OnItemSelectedListener mItemSelectedListener ; private final ResizePopupRunnable mResizePopupRunnable = new ResizePopupRunnable ( ) ; private final PopupTouchInterceptor mTouchInterceptor = new PopupTouchInterceptor ( ) ; private final PopupScrollListener mScrollListener = new PopupScrollListener ( ) ; private final ListSelectorHider mHideSelector = new ListSelectorHider ( ) ; private Handler mHandler = new Handler ( ) ; private Rect mTempRect = new Rect ( ) ; private boolean mModal ; public static final int POSITION_PROMPT_ABOVE = <NUM_LIT:0> ; public static final int POSITION_PROMPT_BELOW = <NUM_LIT:1> ; public IcsListPopupWindow ( Context context ) { this ( context , null , R . attr . listPopupWindowStyle ) ; } public IcsListPopupWindow ( Context context , AttributeSet attrs , int defStyleAttr ) { mContext = context ; mPopup = new PopupWindow ( context , attrs , defStyleAttr ) ; mPopup . setInputMethodMode ( PopupWindow . INPUT_METHOD_NEEDED ) ; } public IcsListPopupWindow ( Context context , AttributeSet attrs , int defStyleAttr , int defStyleRes ) { mContext = context ; if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . HONEYCOMB ) { Context wrapped = new ContextThemeWrapper ( context , defStyleRes ) ; mPopup = new PopupWindow ( wrapped , attrs , defStyleAttr ) ; } else { mPopup = new PopupWindow ( context , attrs , defStyleAttr , defStyleRes ) ; } mPopup . setInputMethodMode ( PopupWindow . INPUT_METHOD_NEEDED ) ; } public void setAdapter ( ListAdapter adapter ) { if ( mObserver == null ) { mObserver = new PopupDataSetObserver ( ) ; } else if ( mAdapter != null ) { mAdapter . unregisterDataSetObserver ( mObserver ) ; } mAdapter = adapter ; if ( mAdapter != null ) { adapter . registerDataSetObserver ( mObserver ) ; } if ( mDropDownList != null ) { mDropDownList . setAdapter ( mAdapter ) ; } } public void setPromptPosition ( int position ) { mPromptPosition = position ; } public void setModal ( boolean modal ) { mModal = true ; mPopup . setFocusable ( modal ) ; } public void setBackgroundDrawable ( Drawable d ) { mPopup . setBackgroundDrawable ( d ) ; } public void setAnchorView ( View anchor ) { mDropDownAnchorView = anchor ; } public void setHorizontalOffset ( int offset ) { mDropDownHorizontalOffset = offset ; } public void setVerticalOffset ( int offset ) { mDropDownVerticalOffset = offset ; mDropDownVerticalOffsetSet = true ; } public void setContentWidth ( int width ) { Drawable popupBackground = mPopup . getBackground ( ) ; if ( popupBackground != null ) { popupBackground . getPadding ( mTempRect ) ; mDropDownWidth = mTempRect . left + mTempRect . right + width ; } else { mDropDownWidth = width ; } } public void setOnItemClickListener ( AdapterView . OnItemClickListener clickListener ) { mItemClickListener = clickListener ; } public void show ( ) { int height = buildDropDown ( ) ; int widthSpec = <NUM_LIT:0> ; int heightSpec = <NUM_LIT:0> ; boolean noInputMethod = isInputMethodNotNeeded ( ) ; if ( mPopup . isShowing ( ) ) { if ( mDropDownWidth == ViewGroup . LayoutParams . MATCH_PARENT ) { widthSpec = - <NUM_LIT:1> ; } else if ( mDropDownWidth == ViewGroup . LayoutParams . WRAP_CONTENT ) { widthSpec = mDropDownAnchorView . getWidth ( ) ; } else { widthSpec = mDropDownWidth ; } if ( mDropDownHeight == ViewGroup . LayoutParams . MATCH_PARENT ) { heightSpec = noInputMethod ? height : ViewGroup . LayoutParams . MATCH_PARENT ; if ( noInputMethod ) { mPopup . setWindowLayoutMode ( mDropDownWidth == ViewGroup . LayoutParams . MATCH_PARENT ? ViewGroup . LayoutParams . MATCH_PARENT : <NUM_LIT:0> , <NUM_LIT:0> ) ; } else { mPopup . setWindowLayoutMode ( mDropDownWidth == ViewGroup . LayoutParams . MATCH_PARENT ? ViewGroup . LayoutParams . MATCH_PARENT : <NUM_LIT:0> , ViewGroup . LayoutParams . MATCH_PARENT ) ; } } else if ( mDropDownHeight == ViewGroup . LayoutParams . WRAP_CONTENT ) { heightSpec = height ; } else { heightSpec = mDropDownHeight ; } mPopup . setOutsideTouchable ( true ) ; mPopup . update ( mDropDownAnchorView , mDropDownHorizontalOffset , mDropDownVerticalOffset , widthSpec , heightSpec ) ; } else { if ( mDropDownWidth == ViewGroup . LayoutParams . MATCH_PARENT ) { widthSpec = ViewGroup . LayoutParams . MATCH_PARENT ; } else { if ( mDropDownWidth == ViewGroup . LayoutParams . WRAP_CONTENT ) { mPopup . setWidth ( mDropDownAnchorView . getWidth ( ) ) ; } else { mPopup . setWidth ( mDropDownWidth ) ; } } if ( mDropDownHeight == ViewGroup . LayoutParams . MATCH_PARENT ) { heightSpec = ViewGroup . LayoutParams . MATCH_PARENT ; } else { if ( mDropDownHeight == ViewGroup . LayoutParams . WRAP_CONTENT ) { mPopup . setHeight ( height ) ; } else { mPopup . setHeight ( mDropDownHeight ) ; } } mPopup . setWindowLayoutMode ( widthSpec , heightSpec ) ; mPopup . setOutsideTouchable ( true ) ; mPopup . setTouchInterceptor ( mTouchInterceptor ) ; mPopup . showAsDropDown ( mDropDownAnchorView , mDropDownHorizontalOffset , mDropDownVerticalOffset ) ; mDropDownList . setSelection ( ListView . INVALID_POSITION ) ; if ( ! mModal || mDropDownList . isInTouchMode ( ) ) { clearListSelection ( ) ; } if ( ! mModal ) { mHandler . post ( mHideSelector ) ; } } } public void dismiss ( ) { mPopup . dismiss ( ) ; if ( mPromptView != null ) { final ViewParent parent = mPromptView . getParent ( ) ; if ( parent instanceof ViewGroup ) { final ViewGroup group = ( ViewGroup ) parent ; group . removeView ( mPromptView ) ; } } mPopup . setContentView ( null ) ; mDropDownList = null ; mHandler . removeCallbacks ( mResizePopupRunnable ) ; } public void setOnDismissListener ( PopupWindow . OnDismissListener listener ) { mPopup . setOnDismissListener ( listener ) ; } public void setInputMethodMode ( int mode ) { mPopup . setInputMethodMode ( mode ) ; } public void clearListSelection ( ) { final DropDownListView list = mDropDownList ; if ( list != null ) { list . mListSelectionHidden = true ; list . requestLayout ( ) ; } } public boolean isShowing ( ) { return mPopup . isShowing ( ) ; } private boolean isInputMethodNotNeeded ( ) { return mPopup . getInputMethodMode ( ) == PopupWindow . INPUT_METHOD_NOT_NEEDED ; } public ListView getListView ( ) { return mDropDownList ; } private int buildDropDown ( ) { ViewGroup dropDownView ; int otherHeights = <NUM_LIT:0> ; if ( mDropDownList == null ) { Context context = mContext ; mDropDownList = new DropDownListView ( context , ! mModal ) ; if ( mDropDownListHighlight != null ) { mDropDownList . setSelector ( mDropDownListHighlight ) ; } mDropDownList . setAdapter ( mAdapter ) ; mDropDownList . setOnItemClickListener ( mItemClickListener ) ; mDropDownList . setFocusable ( true ) ; mDropDownList . setFocusableInTouchMode ( true ) ; mDropDownList . setOnItemSelectedListener ( new AdapterView . OnItemSelectedListener ( ) { public void onItemSelected ( AdapterView < ? > parent , View view , int position , long id ) { if ( position != - <NUM_LIT:1> ) { DropDownListView dropDownList = mDropDownList ; if ( dropDownList != null ) { dropDownList . mListSelectionHidden = false ; } } } public void onNothingSelected ( AdapterView < ? > parent ) { } } ) ; mDropDownList . setOnScrollListener ( mScrollListener ) ; if ( mItemSelectedListener != null ) { mDropDownList . setOnItemSelectedListener ( mItemSelectedListener ) ; } dropDownView = mDropDownList ; View hintView = mPromptView ; if ( hintView != null ) { LinearLayout hintContainer = new LinearLayout ( context ) ; hintContainer . setOrientation ( LinearLayout . VERTICAL ) ; LinearLayout . LayoutParams hintParams = new LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , <NUM_LIT:0> , <NUM_LIT:1.0f> ) ; switch ( mPromptPosition ) { case POSITION_PROMPT_BELOW : hintContainer . addView ( dropDownView , hintParams ) ; hintContainer . addView ( hintView ) ; break ; case POSITION_PROMPT_ABOVE : hintContainer . addView ( hintView ) ; hintContainer . addView ( dropDownView , hintParams ) ; break ; default : break ; } int widthSpec = MeasureSpec . makeMeasureSpec ( mDropDownWidth , MeasureSpec . AT_MOST ) ; int heightSpec = MeasureSpec . UNSPECIFIED ; hintView . measure ( widthSpec , heightSpec ) ; hintParams = ( LinearLayout . LayoutParams ) hintView . getLayoutParams ( ) ; otherHeights = hintView . getMeasuredHeight ( ) + hintParams . topMargin + hintParams . bottomMargin ; dropDownView = hintContainer ; } mPopup . setContentView ( dropDownView ) ; } else { dropDownView = ( ViewGroup ) mPopup . getContentView ( ) ; final View view = mPromptView ; if ( view != null ) { LinearLayout . LayoutParams hintParams = ( LinearLayout . LayoutParams ) view . getLayoutParams ( ) ; otherHeights = view . getMeasuredHeight ( ) + hintParams . topMargin + hintParams . bottomMargin ; } } int padding = <NUM_LIT:0> ; Drawable background = mPopup . getBackground ( ) ; if ( background != null ) { background . getPadding ( mTempRect ) ; padding = mTempRect . top + mTempRect . bottom ; if ( ! mDropDownVerticalOffsetSet ) { mDropDownVerticalOffset = - mTempRect . top ; } } boolean ignoreBottomDecorations = mPopup . getInputMethodMode ( ) == PopupWindow . INPUT_METHOD_NOT_NEEDED ; final int maxHeight = getMaxAvailableHeight ( mDropDownAnchorView , mDropDownVerticalOffset , ignoreBottomDecorations ) ; if ( mDropDownHeight == ViewGroup . LayoutParams . MATCH_PARENT ) { return maxHeight + padding ; } final int listContent = measureHeightOfChildren ( MeasureSpec . UNSPECIFIED , <NUM_LIT:0> , - <NUM_LIT:1> , maxHeight - otherHeights , - <NUM_LIT:1> ) ; if ( listContent > <NUM_LIT:0> ) otherHeights += padding ; return listContent + otherHeights ; } private int getMaxAvailableHeight ( View anchor , int yOffset , boolean ignoreBottomDecorations ) { final Rect displayFrame = new Rect ( ) ; anchor . getWindowVisibleDisplayFrame ( displayFrame ) ; final int [ ] anchorPos = new int [ <NUM_LIT:2> ] ; anchor . getLocationOnScreen ( anchorPos ) ; int bottomEdge = displayFrame . bottom ; if ( ignoreBottomDecorations ) { Resources res = anchor . getContext ( ) . getResources ( ) ; bottomEdge = res . getDisplayMetrics ( ) . heightPixels ; } final int distanceToBottom = bottomEdge - ( anchorPos [ <NUM_LIT:1> ] + anchor . getHeight ( ) ) - yOffset ; final int distanceToTop = anchorPos [ <NUM_LIT:1> ] - displayFrame . top + yOffset ; int returnedHeight = Math . max ( distanceToBottom , distanceToTop ) ; if ( mPopup . getBackground ( ) != null ) { mPopup . getBackground ( ) . getPadding ( mTempRect ) ; returnedHeight -= mTempRect . top + mTempRect . bottom ; } return returnedHeight ; } private int measureHeightOfChildren ( int widthMeasureSpec , int startPosition , int endPosition , final int maxHeight , int disallowPartialChildPosition ) { final ListAdapter adapter = mAdapter ; if ( adapter == null ) { return mDropDownList . getListPaddingTop ( ) + mDropDownList . getListPaddingBottom ( ) ; } int returnedHeight = mDropDownList . getListPaddingTop ( ) + mDropDownList . getListPaddingBottom ( ) ; final int dividerHeight = ( ( mDropDownList . getDividerHeight ( ) > <NUM_LIT:0> ) && mDropDownList . getDivider ( ) != null ) ? mDropDownList . getDividerHeight ( ) : <NUM_LIT:0> ; int prevHeightWithoutPartialChild = <NUM_LIT:0> ; int i ; View child ; endPosition = ( endPosition == - <NUM_LIT:1> ) ? adapter . getCount ( ) - <NUM_LIT:1> : endPosition ; for ( i = startPosition ; i <= endPosition ; ++ i ) { child = mAdapter . getView ( i , null , mDropDownList ) ; if ( mDropDownList . getCacheColorHint ( ) != <NUM_LIT:0> ) { child . setDrawingCacheBackgroundColor ( mDropDownList . getCacheColorHint ( ) ) ; } measureScrapChild ( child , i , widthMeasureSpec ) ; if ( i > <NUM_LIT:0> ) { returnedHeight += dividerHeight ; } returnedHeight += child . getMeasuredHeight ( ) ; if ( returnedHeight >= maxHeight ) { return ( disallowPartialChildPosition >= <NUM_LIT:0> ) && ( i > disallowPartialChildPosition ) && ( prevHeightWithoutPartialChild > <NUM_LIT:0> ) && ( returnedHeight != maxHeight ) ? prevHeightWithoutPartialChild : maxHeight ; } if ( ( disallowPartialChildPosition >= <NUM_LIT:0> ) && ( i >= disallowPartialChildPosition ) ) { prevHeightWithoutPartialChild = returnedHeight ; } } return returnedHeight ; } private void measureScrapChild ( View child , int position , int widthMeasureSpec ) { ListView . LayoutParams p = ( ListView . LayoutParams ) child . getLayoutParams ( ) ; if ( p == null ) { p = new ListView . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT , <NUM_LIT:0> ) ; child . setLayoutParams ( p ) ; } int childWidthSpec = ViewGroup . getChildMeasureSpec ( widthMeasureSpec , mDropDownList . getPaddingLeft ( ) + mDropDownList . getPaddingRight ( ) , p . width ) ; int lpHeight = p . height ; int childHeightSpec ; if ( lpHeight > <NUM_LIT:0> ) { childHeightSpec = MeasureSpec . makeMeasureSpec ( lpHeight , MeasureSpec . EXACTLY ) ; } else { childHeightSpec = MeasureSpec . makeMeasureSpec ( <NUM_LIT:0> , MeasureSpec . UNSPECIFIED ) ; } child . measure ( childWidthSpec , childHeightSpec ) ; } private static class DropDownListView extends ListView { private boolean mListSelectionHidden ; private boolean mHijackFocus ; public DropDownListView ( Context context , boolean hijackFocus ) { super ( context , null , R . attr . dropDownListViewStyle ) ; mHijackFocus = hijackFocus ; setCacheColorHint ( <NUM_LIT:0> ) ; } @ Override public boolean isInTouchMode ( ) { return ( mHijackFocus && mListSelectionHidden ) || super . isInTouchMode ( ) ; } @ Override public boolean hasWindowFocus ( ) { return mHijackFocus || super . hasWindowFocus ( ) ; } @ Override public boolean isFocused ( ) { return mHijackFocus || super . isFocused ( ) ; } @ Override public boolean hasFocus ( ) { return mHijackFocus || super . hasFocus ( ) ; } } private class PopupDataSetObserver extends DataSetObserver { @ Override public void onChanged ( ) { if ( isShowing ( ) ) { show ( ) ; } } @ Override public void onInvalidated ( ) { dismiss ( ) ; } } private class ListSelectorHider implements Runnable { public void run ( ) { clearListSelection ( ) ; } } private class ResizePopupRunnable implements Runnable { public void run ( ) { if ( mDropDownList != null && mDropDownList . getCount ( ) > mDropDownList . getChildCount ( ) && mDropDownList . getChildCount ( ) <= mListItemExpandMaximum ) { mPopup . setInputMethodMode ( PopupWindow . INPUT_METHOD_NOT_NEEDED ) ; show ( ) ; } } } private class PopupTouchInterceptor implements OnTouchListener { public boolean onTouch ( View v , MotionEvent event ) { final int action = event . getAction ( ) ; final int x = ( int ) event . getX ( ) ; final int y = ( int ) event . getY ( ) ; if ( action == MotionEvent . ACTION_DOWN && mPopup != null && mPopup . isShowing ( ) && ( x >= <NUM_LIT:0> && x < mPopup . getWidth ( ) && y >= <NUM_LIT:0> && y < mPopup . getHeight ( ) ) ) { mHandler . postDelayed ( mResizePopupRunnable , EXPAND_LIST_TIMEOUT ) ; } else if ( action == MotionEvent . ACTION_UP ) { mHandler . removeCallbacks ( mResizePopupRunnable ) ; } return false ; } } private class PopupScrollListener implements ListView . OnScrollListener { public void onScroll ( AbsListView view , int firstVisibleItem , int visibleItemCount , int totalItemCount ) { } public void onScrollStateChanged ( AbsListView view , int scrollState ) { if ( scrollState == SCROLL_STATE_TOUCH_SCROLL && ! isInputMethodNotNeeded ( ) && mPopup . getContentView ( ) != null ) { mHandler . removeCallbacks ( mResizePopupRunnable ) ; mResizePopupRunnable . run ( ) ; } } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . view . View ; final class IcsView { private IcsView ( ) { } public static int getMeasuredStateInt ( View child ) { return ( child . getMeasuredWidth ( ) & View . MEASURED_STATE_MASK ) | ( ( child . getMeasuredHeight ( ) > > View . MEASURED_HEIGHT_STATE_SHIFT ) & ( View . MEASURED_STATE_MASK > > View . MEASURED_HEIGHT_STATE_SHIFT ) ) ; } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . content . res . TypedArray ; import android . graphics . drawable . Drawable ; import android . text . TextUtils ; import android . util . AttributeSet ; import android . view . LayoutInflater ; import android . view . View ; import android . view . ViewGroup ; import android . view . accessibility . AccessibilityEvent ; import android . view . animation . DecelerateInterpolator ; import android . widget . LinearLayout ; import android . widget . TextView ; import com . actionbarsherlock . R ; import com . actionbarsherlock . internal . nineoldandroids . animation . Animator ; import com . actionbarsherlock . internal . nineoldandroids . animation . Animator . AnimatorListener ; import com . actionbarsherlock . internal . nineoldandroids . animation . AnimatorSet ; import com . actionbarsherlock . internal . nineoldandroids . animation . ObjectAnimator ; import com . actionbarsherlock . internal . nineoldandroids . view . animation . AnimatorProxy ; import com . actionbarsherlock . internal . nineoldandroids . widget . NineLinearLayout ; import com . actionbarsherlock . internal . view . menu . ActionMenuPresenter ; import com . actionbarsherlock . internal . view . menu . ActionMenuView ; import com . actionbarsherlock . internal . view . menu . MenuBuilder ; import com . actionbarsherlock . view . ActionMode ; public class ActionBarContextView extends AbsActionBarView implements AnimatorListener { private CharSequence mTitle ; private CharSequence mSubtitle ; private NineLinearLayout mClose ; private View mCustomView ; private LinearLayout mTitleLayout ; private TextView mTitleView ; private TextView mSubtitleView ; private int mTitleStyleRes ; private int mSubtitleStyleRes ; private Drawable mSplitBackground ; private Animator mCurrentAnimation ; private boolean mAnimateInOnLayout ; private int mAnimationMode ; private static final int ANIMATE_IDLE = <NUM_LIT:0> ; private static final int ANIMATE_IN = <NUM_LIT:1> ; private static final int ANIMATE_OUT = <NUM_LIT:2> ; public ActionBarContextView ( Context context ) { this ( context , null ) ; } public ActionBarContextView ( Context context , AttributeSet attrs ) { this ( context , attrs , R . attr . actionModeStyle ) ; } public ActionBarContextView ( Context context , AttributeSet attrs , int defStyle ) { super ( context , attrs , defStyle ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . SherlockActionMode , defStyle , <NUM_LIT:0> ) ; setBackgroundDrawable ( a . getDrawable ( R . styleable . SherlockActionMode_background ) ) ; mTitleStyleRes = a . getResourceId ( R . styleable . SherlockActionMode_titleTextStyle , <NUM_LIT:0> ) ; mSubtitleStyleRes = a . getResourceId ( R . styleable . SherlockActionMode_subtitleTextStyle , <NUM_LIT:0> ) ; mContentHeight = a . getLayoutDimension ( R . styleable . SherlockActionMode_height , <NUM_LIT:0> ) ; mSplitBackground = a . getDrawable ( R . styleable . SherlockActionMode_backgroundSplit ) ; a . recycle ( ) ; } @ Override public void onDetachedFromWindow ( ) { super . onDetachedFromWindow ( ) ; if ( mActionMenuPresenter != null ) { mActionMenuPresenter . hideOverflowMenu ( ) ; mActionMenuPresenter . hideSubMenus ( ) ; } } @ Override public void setSplitActionBar ( boolean split ) { if ( mSplitActionBar != split ) { if ( mActionMenuPresenter != null ) { final LayoutParams layoutParams = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . MATCH_PARENT ) ; if ( ! split ) { mMenuView = ( ActionMenuView ) mActionMenuPresenter . getMenuView ( this ) ; mMenuView . setBackgroundDrawable ( null ) ; final ViewGroup oldParent = ( ViewGroup ) mMenuView . getParent ( ) ; if ( oldParent != null ) oldParent . removeView ( mMenuView ) ; addView ( mMenuView , layoutParams ) ; } else { mActionMenuPresenter . setWidthLimit ( getContext ( ) . getResources ( ) . getDisplayMetrics ( ) . widthPixels , true ) ; mActionMenuPresenter . setItemLimit ( Integer . MAX_VALUE ) ; layoutParams . width = LayoutParams . MATCH_PARENT ; layoutParams . height = mContentHeight ; mMenuView = ( ActionMenuView ) mActionMenuPresenter . getMenuView ( this ) ; mMenuView . setBackgroundDrawable ( mSplitBackground ) ; final ViewGroup oldParent = ( ViewGroup ) mMenuView . getParent ( ) ; if ( oldParent != null ) oldParent . removeView ( mMenuView ) ; mSplitView . addView ( mMenuView , layoutParams ) ; } } super . setSplitActionBar ( split ) ; } } public void setContentHeight ( int height ) { mContentHeight = height ; } public void setCustomView ( View view ) { if ( mCustomView != null ) { removeView ( mCustomView ) ; } mCustomView = view ; if ( mTitleLayout != null ) { removeView ( mTitleLayout ) ; mTitleLayout = null ; } if ( view != null ) { addView ( view ) ; } requestLayout ( ) ; } public void setTitle ( CharSequence title ) { mTitle = title ; initTitle ( ) ; } public void setSubtitle ( CharSequence subtitle ) { mSubtitle = subtitle ; initTitle ( ) ; } public CharSequence getTitle ( ) { return mTitle ; } public CharSequence getSubtitle ( ) { return mSubtitle ; } private void initTitle ( ) { if ( mTitleLayout == null ) { LayoutInflater inflater = LayoutInflater . from ( getContext ( ) ) ; inflater . inflate ( R . layout . abs__action_bar_title_item , this ) ; mTitleLayout = ( LinearLayout ) getChildAt ( getChildCount ( ) - <NUM_LIT:1> ) ; mTitleView = ( TextView ) mTitleLayout . findViewById ( R . id . abs__action_bar_title ) ; mSubtitleView = ( TextView ) mTitleLayout . findViewById ( R . id . abs__action_bar_subtitle ) ; if ( mTitleStyleRes != <NUM_LIT:0> ) { mTitleView . setTextAppearance ( mContext , mTitleStyleRes ) ; } if ( mSubtitleStyleRes != <NUM_LIT:0> ) { mSubtitleView . setTextAppearance ( mContext , mSubtitleStyleRes ) ; } } mTitleView . setText ( mTitle ) ; mSubtitleView . setText ( mSubtitle ) ; final boolean hasTitle = ! TextUtils . isEmpty ( mTitle ) ; final boolean hasSubtitle = ! TextUtils . isEmpty ( mSubtitle ) ; mSubtitleView . setVisibility ( hasSubtitle ? VISIBLE : GONE ) ; mTitleLayout . setVisibility ( hasTitle || hasSubtitle ? VISIBLE : GONE ) ; if ( mTitleLayout . getParent ( ) == null ) { addView ( mTitleLayout ) ; } } public void initForMode ( final ActionMode mode ) { if ( mClose == null ) { LayoutInflater inflater = LayoutInflater . from ( mContext ) ; mClose = ( NineLinearLayout ) inflater . inflate ( R . layout . abs__action_mode_close_item , this , false ) ; addView ( mClose ) ; } else if ( mClose . getParent ( ) == null ) { addView ( mClose ) ; } View closeButton = mClose . findViewById ( R . id . abs__action_mode_close_button ) ; closeButton . setOnClickListener ( new OnClickListener ( ) { public void onClick ( View v ) { mode . finish ( ) ; } } ) ; final MenuBuilder menu = ( MenuBuilder ) mode . getMenu ( ) ; if ( mActionMenuPresenter != null ) { mActionMenuPresenter . dismissPopupMenus ( ) ; } mActionMenuPresenter = new ActionMenuPresenter ( mContext ) ; mActionMenuPresenter . setReserveOverflow ( true ) ; final LayoutParams layoutParams = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . MATCH_PARENT ) ; if ( ! mSplitActionBar ) { menu . addMenuPresenter ( mActionMenuPresenter ) ; mMenuView = ( ActionMenuView ) mActionMenuPresenter . getMenuView ( this ) ; mMenuView . setBackgroundDrawable ( null ) ; addView ( mMenuView , layoutParams ) ; } else { mActionMenuPresenter . setWidthLimit ( getContext ( ) . getResources ( ) . getDisplayMetrics ( ) . widthPixels , true ) ; mActionMenuPresenter . setItemLimit ( Integer . MAX_VALUE ) ; layoutParams . width = LayoutParams . MATCH_PARENT ; layoutParams . height = mContentHeight ; menu . addMenuPresenter ( mActionMenuPresenter ) ; mMenuView = ( ActionMenuView ) mActionMenuPresenter . getMenuView ( this ) ; mMenuView . setBackgroundDrawable ( mSplitBackground ) ; mSplitView . addView ( mMenuView , layoutParams ) ; } mAnimateInOnLayout = true ; } public void closeMode ( ) { if ( mAnimationMode == ANIMATE_OUT ) { return ; } if ( mClose == null ) { killMode ( ) ; return ; } finishAnimation ( ) ; mAnimationMode = ANIMATE_OUT ; mCurrentAnimation = makeOutAnimation ( ) ; mCurrentAnimation . start ( ) ; } private void finishAnimation ( ) { final Animator a = mCurrentAnimation ; if ( a != null ) { mCurrentAnimation = null ; a . end ( ) ; } } public void killMode ( ) { finishAnimation ( ) ; removeAllViews ( ) ; if ( mSplitView != null ) { mSplitView . removeView ( mMenuView ) ; } mCustomView = null ; mMenuView = null ; mAnimateInOnLayout = false ; } @ Override public boolean showOverflowMenu ( ) { if ( mActionMenuPresenter != null ) { return mActionMenuPresenter . showOverflowMenu ( ) ; } return false ; } @ Override public boolean hideOverflowMenu ( ) { if ( mActionMenuPresenter != null ) { return mActionMenuPresenter . hideOverflowMenu ( ) ; } return false ; } @ Override public boolean isOverflowMenuShowing ( ) { if ( mActionMenuPresenter != null ) { return mActionMenuPresenter . isOverflowMenuShowing ( ) ; } return false ; } @ Override protected ViewGroup . LayoutParams generateDefaultLayoutParams ( ) { return new MarginLayoutParams ( LayoutParams . MATCH_PARENT , LayoutParams . WRAP_CONTENT ) ; } @ Override public ViewGroup . LayoutParams generateLayoutParams ( AttributeSet attrs ) { return new MarginLayoutParams ( getContext ( ) , attrs ) ; } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { final int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; if ( widthMode != MeasureSpec . EXACTLY ) { throw new IllegalStateException ( getClass ( ) . getSimpleName ( ) + "<STR_LIT>" + "<STR_LIT>" ) ; } final int heightMode = MeasureSpec . getMode ( heightMeasureSpec ) ; if ( heightMode == MeasureSpec . UNSPECIFIED ) { throw new IllegalStateException ( getClass ( ) . getSimpleName ( ) + "<STR_LIT>" + "<STR_LIT>" ) ; } final int contentWidth = MeasureSpec . getSize ( widthMeasureSpec ) ; int maxHeight = mContentHeight > <NUM_LIT:0> ? mContentHeight : MeasureSpec . getSize ( heightMeasureSpec ) ; final int verticalPadding = getPaddingTop ( ) + getPaddingBottom ( ) ; int availableWidth = contentWidth - getPaddingLeft ( ) - getPaddingRight ( ) ; final int height = maxHeight - verticalPadding ; final int childSpecHeight = MeasureSpec . makeMeasureSpec ( height , MeasureSpec . AT_MOST ) ; if ( mClose != null ) { availableWidth = measureChildView ( mClose , availableWidth , childSpecHeight , <NUM_LIT:0> ) ; MarginLayoutParams lp = ( MarginLayoutParams ) mClose . getLayoutParams ( ) ; availableWidth -= lp . leftMargin + lp . rightMargin ; } if ( mMenuView != null && mMenuView . getParent ( ) == this ) { availableWidth = measureChildView ( mMenuView , availableWidth , childSpecHeight , <NUM_LIT:0> ) ; } if ( mTitleLayout != null && mCustomView == null ) { availableWidth = measureChildView ( mTitleLayout , availableWidth , childSpecHeight , <NUM_LIT:0> ) ; } if ( mCustomView != null ) { ViewGroup . LayoutParams lp = mCustomView . getLayoutParams ( ) ; final int customWidthMode = lp . width != LayoutParams . WRAP_CONTENT ? MeasureSpec . EXACTLY : MeasureSpec . AT_MOST ; final int customWidth = lp . width >= <NUM_LIT:0> ? Math . min ( lp . width , availableWidth ) : availableWidth ; final int customHeightMode = lp . height != LayoutParams . WRAP_CONTENT ? MeasureSpec . EXACTLY : MeasureSpec . AT_MOST ; final int customHeight = lp . height >= <NUM_LIT:0> ? Math . min ( lp . height , height ) : height ; mCustomView . measure ( MeasureSpec . makeMeasureSpec ( customWidth , customWidthMode ) , MeasureSpec . makeMeasureSpec ( customHeight , customHeightMode ) ) ; } if ( mContentHeight <= <NUM_LIT:0> ) { int measuredHeight = <NUM_LIT:0> ; final int count = getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { View v = getChildAt ( i ) ; int paddedViewHeight = v . getMeasuredHeight ( ) + verticalPadding ; if ( paddedViewHeight > measuredHeight ) { measuredHeight = paddedViewHeight ; } } setMeasuredDimension ( contentWidth , measuredHeight ) ; } else { setMeasuredDimension ( contentWidth , maxHeight ) ; } } private Animator makeInAnimation ( ) { mClose . setTranslationX ( - mClose . getWidth ( ) - ( ( MarginLayoutParams ) mClose . getLayoutParams ( ) ) . leftMargin ) ; ObjectAnimator buttonAnimator = ObjectAnimator . ofFloat ( mClose , "<STR_LIT>" , <NUM_LIT:0> ) ; buttonAnimator . setDuration ( <NUM_LIT> ) ; buttonAnimator . addListener ( this ) ; buttonAnimator . setInterpolator ( new DecelerateInterpolator ( ) ) ; AnimatorSet set = new AnimatorSet ( ) ; AnimatorSet . Builder b = set . play ( buttonAnimator ) ; if ( mMenuView != null ) { final int count = mMenuView . getChildCount ( ) ; if ( count > <NUM_LIT:0> ) { for ( int i = count - <NUM_LIT:1> , j = <NUM_LIT:0> ; i >= <NUM_LIT:0> ; i -- , j ++ ) { AnimatorProxy child = AnimatorProxy . wrap ( mMenuView . getChildAt ( i ) ) ; child . setScaleY ( <NUM_LIT:0> ) ; ObjectAnimator a = ObjectAnimator . ofFloat ( child , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:1> ) ; a . setDuration ( <NUM_LIT:100> ) ; a . setStartDelay ( j * <NUM_LIT> ) ; b . with ( a ) ; } } } return set ; } private Animator makeOutAnimation ( ) { ObjectAnimator buttonAnimator = ObjectAnimator . ofFloat ( mClose , "<STR_LIT>" , - mClose . getWidth ( ) - ( ( MarginLayoutParams ) mClose . getLayoutParams ( ) ) . leftMargin ) ; buttonAnimator . setDuration ( <NUM_LIT> ) ; buttonAnimator . addListener ( this ) ; buttonAnimator . setInterpolator ( new DecelerateInterpolator ( ) ) ; AnimatorSet set = new AnimatorSet ( ) ; AnimatorSet . Builder b = set . play ( buttonAnimator ) ; if ( mMenuView != null ) { final int count = mMenuView . getChildCount ( ) ; if ( count > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:0> ; i ++ ) { AnimatorProxy child = AnimatorProxy . wrap ( mMenuView . getChildAt ( i ) ) ; child . setScaleY ( <NUM_LIT:0> ) ; ObjectAnimator a = ObjectAnimator . ofFloat ( child , "<STR_LIT>" , <NUM_LIT:0> ) ; a . setDuration ( <NUM_LIT:100> ) ; a . setStartDelay ( i * <NUM_LIT> ) ; b . with ( a ) ; } } } return set ; } @ Override protected void onLayout ( boolean changed , int l , int t , int r , int b ) { int x = getPaddingLeft ( ) ; final int y = getPaddingTop ( ) ; final int contentHeight = b - t - getPaddingTop ( ) - getPaddingBottom ( ) ; if ( mClose != null && mClose . getVisibility ( ) != GONE ) { MarginLayoutParams lp = ( MarginLayoutParams ) mClose . getLayoutParams ( ) ; x += lp . leftMargin ; x += positionChild ( mClose , x , y , contentHeight ) ; x += lp . rightMargin ; if ( mAnimateInOnLayout ) { mAnimationMode = ANIMATE_IN ; mCurrentAnimation = makeInAnimation ( ) ; mCurrentAnimation . start ( ) ; mAnimateInOnLayout = false ; } } if ( mTitleLayout != null && mCustomView == null ) { x += positionChild ( mTitleLayout , x , y , contentHeight ) ; } if ( mCustomView != null ) { x += positionChild ( mCustomView , x , y , contentHeight ) ; } x = r - l - getPaddingRight ( ) ; if ( mMenuView != null ) { x -= positionChildInverse ( mMenuView , x , y , contentHeight ) ; } } @ Override public void onAnimationStart ( Animator animation ) { } @ Override public void onAnimationEnd ( Animator animation ) { if ( mAnimationMode == ANIMATE_OUT ) { killMode ( ) ; } mAnimationMode = ANIMATE_IDLE ; } @ Override public void onAnimationCancel ( Animator animation ) { } @ Override public void onAnimationRepeat ( Animator animation ) { } @ Override public boolean shouldDelayChildPressedState ( ) { return false ; } @ Override public void onInitializeAccessibilityEvent ( AccessibilityEvent event ) { if ( event . getEventType ( ) == AccessibilityEvent . TYPE_WINDOW_STATE_CHANGED ) { event . setClassName ( getClass ( ) . getName ( ) ) ; event . setPackageName ( getContext ( ) . getPackageName ( ) ) ; event . setContentDescription ( mTitle ) ; } else { } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import static android . view . ViewGroup . LayoutParams . MATCH_PARENT ; import static android . view . ViewGroup . LayoutParams . WRAP_CONTENT ; import com . actionbarsherlock . R ; import android . content . Context ; import android . content . DialogInterface ; import android . content . DialogInterface . OnClickListener ; import android . content . res . TypedArray ; import android . database . DataSetObserver ; import android . graphics . Rect ; import android . graphics . drawable . Drawable ; import android . util . AttributeSet ; import android . view . Gravity ; import android . view . View ; import android . view . ViewGroup ; import android . widget . AdapterView ; import android . widget . AdapterView . OnItemClickListener ; import android . widget . ListAdapter ; import android . widget . ListView ; import android . widget . PopupWindow ; import android . widget . SpinnerAdapter ; public class IcsSpinner extends IcsAbsSpinner implements OnClickListener { private static final int MAX_ITEMS_MEASURED = <NUM_LIT:15> ; public static final int MODE_DROPDOWN = <NUM_LIT:1> ; private SpinnerPopup mPopup ; private DropDownAdapter mTempAdapter ; int mDropDownWidth ; private int mGravity ; private boolean mDisableChildrenWhenDisabled ; private Rect mTempRect = new Rect ( ) ; public IcsSpinner ( Context context , AttributeSet attrs ) { this ( context , attrs , R . attr . actionDropDownStyle ) ; } public IcsSpinner ( Context context , AttributeSet attrs , int defStyle ) { super ( context , attrs , defStyle ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . SherlockSpinner , defStyle , <NUM_LIT:0> ) ; DropdownPopup popup = new DropdownPopup ( context , attrs , defStyle ) ; mDropDownWidth = a . getLayoutDimension ( R . styleable . SherlockSpinner_android_dropDownWidth , ViewGroup . LayoutParams . WRAP_CONTENT ) ; popup . setBackgroundDrawable ( a . getDrawable ( R . styleable . SherlockSpinner_android_popupBackground ) ) ; final int verticalOffset = a . getDimensionPixelOffset ( R . styleable . SherlockSpinner_android_dropDownVerticalOffset , <NUM_LIT:0> ) ; if ( verticalOffset != <NUM_LIT:0> ) { popup . setVerticalOffset ( verticalOffset ) ; } final int horizontalOffset = a . getDimensionPixelOffset ( R . styleable . SherlockSpinner_android_dropDownHorizontalOffset , <NUM_LIT:0> ) ; if ( horizontalOffset != <NUM_LIT:0> ) { popup . setHorizontalOffset ( horizontalOffset ) ; } mPopup = popup ; mGravity = a . getInt ( R . styleable . SherlockSpinner_android_gravity , Gravity . CENTER ) ; mPopup . setPromptText ( a . getString ( R . styleable . SherlockSpinner_android_prompt ) ) ; mDisableChildrenWhenDisabled = true ; a . recycle ( ) ; if ( mTempAdapter != null ) { mPopup . setAdapter ( mTempAdapter ) ; mTempAdapter = null ; } } @ Override public void setEnabled ( boolean enabled ) { super . setEnabled ( enabled ) ; if ( mDisableChildrenWhenDisabled ) { final int count = getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { getChildAt ( i ) . setEnabled ( enabled ) ; } } } public void setGravity ( int gravity ) { if ( mGravity != gravity ) { if ( ( gravity & Gravity . HORIZONTAL_GRAVITY_MASK ) == <NUM_LIT:0> ) { gravity |= Gravity . LEFT ; } mGravity = gravity ; requestLayout ( ) ; } } @ Override public void setAdapter ( SpinnerAdapter adapter ) { super . setAdapter ( adapter ) ; if ( mPopup != null ) { mPopup . setAdapter ( new DropDownAdapter ( adapter ) ) ; } else { mTempAdapter = new DropDownAdapter ( adapter ) ; } } @ Override public int getBaseline ( ) { View child = null ; if ( getChildCount ( ) > <NUM_LIT:0> ) { child = getChildAt ( <NUM_LIT:0> ) ; } else if ( mAdapter != null && mAdapter . getCount ( ) > <NUM_LIT:0> ) { child = makeAndAddView ( <NUM_LIT:0> ) ; mRecycler . put ( <NUM_LIT:0> , child ) ; removeAllViewsInLayout ( ) ; } if ( child != null ) { final int childBaseline = child . getBaseline ( ) ; return childBaseline >= <NUM_LIT:0> ? child . getTop ( ) + childBaseline : - <NUM_LIT:1> ; } else { return - <NUM_LIT:1> ; } } @ Override protected void onDetachedFromWindow ( ) { super . onDetachedFromWindow ( ) ; if ( mPopup != null && mPopup . isShowing ( ) ) { mPopup . dismiss ( ) ; } } @ Override public void setOnItemClickListener ( OnItemClickListener l ) { throw new RuntimeException ( "<STR_LIT>" ) ; } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; if ( mPopup != null && MeasureSpec . getMode ( widthMeasureSpec ) == MeasureSpec . AT_MOST ) { final int measuredWidth = getMeasuredWidth ( ) ; setMeasuredDimension ( Math . min ( Math . max ( measuredWidth , measureContentWidth ( getAdapter ( ) , getBackground ( ) ) ) , MeasureSpec . getSize ( widthMeasureSpec ) ) , getMeasuredHeight ( ) ) ; } } @ Override protected void onLayout ( boolean changed , int l , int t , int r , int b ) { super . onLayout ( changed , l , t , r , b ) ; mInLayout = true ; layout ( <NUM_LIT:0> , false ) ; mInLayout = false ; } @ Override void layout ( int delta , boolean animate ) { int childrenLeft = mSpinnerPadding . left ; int childrenWidth = getRight ( ) - getLeft ( ) - mSpinnerPadding . left - mSpinnerPadding . right ; if ( mDataChanged ) { handleDataChanged ( ) ; } if ( mItemCount == <NUM_LIT:0> ) { resetList ( ) ; return ; } if ( mNextSelectedPosition >= <NUM_LIT:0> ) { setSelectedPositionInt ( mNextSelectedPosition ) ; } recycleAllViews ( ) ; removeAllViewsInLayout ( ) ; mFirstPosition = mSelectedPosition ; View sel = makeAndAddView ( mSelectedPosition ) ; int width = sel . getMeasuredWidth ( ) ; int selectedOffset = childrenLeft ; switch ( mGravity & Gravity . HORIZONTAL_GRAVITY_MASK ) { case Gravity . CENTER_HORIZONTAL : selectedOffset = childrenLeft + ( childrenWidth / <NUM_LIT:2> ) - ( width / <NUM_LIT:2> ) ; break ; case Gravity . RIGHT : selectedOffset = childrenLeft + childrenWidth - width ; break ; } sel . offsetLeftAndRight ( selectedOffset ) ; mRecycler . clear ( ) ; invalidate ( ) ; checkSelectionChanged ( ) ; mDataChanged = false ; mNeedSync = false ; setNextSelectedPositionInt ( mSelectedPosition ) ; } private View makeAndAddView ( int position ) { View child ; if ( ! mDataChanged ) { child = mRecycler . get ( position ) ; if ( child != null ) { setUpChild ( child ) ; return child ; } } child = mAdapter . getView ( position , null , this ) ; setUpChild ( child ) ; return child ; } private void setUpChild ( View child ) { ViewGroup . LayoutParams lp = child . getLayoutParams ( ) ; if ( lp == null ) { lp = generateDefaultLayoutParams ( ) ; } addViewInLayout ( child , <NUM_LIT:0> , lp ) ; child . setSelected ( hasFocus ( ) ) ; if ( mDisableChildrenWhenDisabled ) { child . setEnabled ( isEnabled ( ) ) ; } int childHeightSpec = ViewGroup . getChildMeasureSpec ( mHeightMeasureSpec , mSpinnerPadding . top + mSpinnerPadding . bottom , lp . height ) ; int childWidthSpec = ViewGroup . getChildMeasureSpec ( mWidthMeasureSpec , mSpinnerPadding . left + mSpinnerPadding . right , lp . width ) ; child . measure ( childWidthSpec , childHeightSpec ) ; int childLeft ; int childRight ; int childTop = mSpinnerPadding . top + ( ( getMeasuredHeight ( ) - mSpinnerPadding . bottom - mSpinnerPadding . top - child . getMeasuredHeight ( ) ) / <NUM_LIT:2> ) ; int childBottom = childTop + child . getMeasuredHeight ( ) ; int width = child . getMeasuredWidth ( ) ; childLeft = <NUM_LIT:0> ; childRight = childLeft + width ; child . layout ( childLeft , childTop , childRight , childBottom ) ; } @ Override public boolean performClick ( ) { boolean handled = super . performClick ( ) ; if ( ! handled ) { handled = true ; if ( ! mPopup . isShowing ( ) ) { mPopup . show ( ) ; } } return handled ; } public void onClick ( DialogInterface dialog , int which ) { setSelection ( which ) ; dialog . dismiss ( ) ; } public void setPrompt ( CharSequence prompt ) { mPopup . setPromptText ( prompt ) ; } public void setPromptId ( int promptId ) { setPrompt ( getContext ( ) . getText ( promptId ) ) ; } public CharSequence getPrompt ( ) { return mPopup . getHintText ( ) ; } int measureContentWidth ( SpinnerAdapter adapter , Drawable background ) { if ( adapter == null ) { return <NUM_LIT:0> ; } int width = <NUM_LIT:0> ; View itemView = null ; int itemType = <NUM_LIT:0> ; final int widthMeasureSpec = MeasureSpec . makeMeasureSpec ( <NUM_LIT:0> , MeasureSpec . UNSPECIFIED ) ; final int heightMeasureSpec = MeasureSpec . makeMeasureSpec ( <NUM_LIT:0> , MeasureSpec . UNSPECIFIED ) ; int start = Math . max ( <NUM_LIT:0> , getSelectedItemPosition ( ) ) ; final int end = Math . min ( adapter . getCount ( ) , start + MAX_ITEMS_MEASURED ) ; final int count = end - start ; start = Math . max ( <NUM_LIT:0> , start - ( MAX_ITEMS_MEASURED - count ) ) ; for ( int i = start ; i < end ; i ++ ) { final int positionType = adapter . getItemViewType ( i ) ; if ( positionType != itemType ) { itemType = positionType ; itemView = null ; } itemView = adapter . getView ( i , itemView , this ) ; if ( itemView . getLayoutParams ( ) == null ) { itemView . setLayoutParams ( new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . WRAP_CONTENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ) ; } itemView . measure ( widthMeasureSpec , heightMeasureSpec ) ; width = Math . max ( width , itemView . getMeasuredWidth ( ) ) ; } if ( background != null ) { background . getPadding ( mTempRect ) ; width += mTempRect . left + mTempRect . right ; } return width ; } private static class DropDownAdapter implements ListAdapter , SpinnerAdapter { private SpinnerAdapter mAdapter ; private ListAdapter mListAdapter ; public DropDownAdapter ( SpinnerAdapter adapter ) { this . mAdapter = adapter ; if ( adapter instanceof ListAdapter ) { this . mListAdapter = ( ListAdapter ) adapter ; } } public int getCount ( ) { return mAdapter == null ? <NUM_LIT:0> : mAdapter . getCount ( ) ; } public Object getItem ( int position ) { return mAdapter == null ? null : mAdapter . getItem ( position ) ; } public long getItemId ( int position ) { return mAdapter == null ? - <NUM_LIT:1> : mAdapter . getItemId ( position ) ; } public View getView ( int position , View convertView , ViewGroup parent ) { return getDropDownView ( position , convertView , parent ) ; } public View getDropDownView ( int position , View convertView , ViewGroup parent ) { return mAdapter == null ? null : mAdapter . getDropDownView ( position , convertView , parent ) ; } public boolean hasStableIds ( ) { return mAdapter != null && mAdapter . hasStableIds ( ) ; } public void registerDataSetObserver ( DataSetObserver observer ) { if ( mAdapter != null ) { mAdapter . registerDataSetObserver ( observer ) ; } } public void unregisterDataSetObserver ( DataSetObserver observer ) { if ( mAdapter != null ) { mAdapter . unregisterDataSetObserver ( observer ) ; } } public boolean areAllItemsEnabled ( ) { final ListAdapter adapter = mListAdapter ; if ( adapter != null ) { return adapter . areAllItemsEnabled ( ) ; } else { return true ; } } public boolean isEnabled ( int position ) { final ListAdapter adapter = mListAdapter ; if ( adapter != null ) { return adapter . isEnabled ( position ) ; } else { return true ; } } public int getItemViewType ( int position ) { return <NUM_LIT:0> ; } public int getViewTypeCount ( ) { return <NUM_LIT:1> ; } public boolean isEmpty ( ) { return getCount ( ) == <NUM_LIT:0> ; } } private interface SpinnerPopup { public void setAdapter ( ListAdapter adapter ) ; public void show ( ) ; public void dismiss ( ) ; public boolean isShowing ( ) ; public void setPromptText ( CharSequence hintText ) ; public CharSequence getHintText ( ) ; } private class DropdownPopup extends IcsListPopupWindow implements SpinnerPopup { private CharSequence mHintText ; private ListAdapter mAdapter ; public DropdownPopup ( Context context , AttributeSet attrs , int defStyleRes ) { super ( context , attrs , <NUM_LIT:0> , defStyleRes ) ; setAnchorView ( IcsSpinner . this ) ; setModal ( true ) ; setPromptPosition ( POSITION_PROMPT_ABOVE ) ; setOnItemClickListener ( new OnItemClickListener ( ) { @ SuppressWarnings ( "<STR_LIT:rawtypes>" ) public void onItemClick ( AdapterView parent , View v , int position , long id ) { IcsSpinner . this . setSelection ( position ) ; dismiss ( ) ; } } ) ; } @ Override public void setAdapter ( ListAdapter adapter ) { super . setAdapter ( adapter ) ; mAdapter = adapter ; } public CharSequence getHintText ( ) { return mHintText ; } public void setPromptText ( CharSequence hintText ) { mHintText = hintText ; } @ Override public void show ( ) { final int spinnerPaddingLeft = IcsSpinner . this . getPaddingLeft ( ) ; if ( mDropDownWidth == WRAP_CONTENT ) { final int spinnerWidth = IcsSpinner . this . getWidth ( ) ; final int spinnerPaddingRight = IcsSpinner . this . getPaddingRight ( ) ; setContentWidth ( Math . max ( measureContentWidth ( ( SpinnerAdapter ) mAdapter , getBackground ( ) ) , spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight ) ) ; } else if ( mDropDownWidth == MATCH_PARENT ) { final int spinnerWidth = IcsSpinner . this . getWidth ( ) ; final int spinnerPaddingRight = IcsSpinner . this . getPaddingRight ( ) ; setContentWidth ( spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight ) ; } else { setContentWidth ( mDropDownWidth ) ; } final Drawable background = getBackground ( ) ; int bgOffset = <NUM_LIT:0> ; if ( background != null ) { background . getPadding ( mTempRect ) ; bgOffset = - mTempRect . left ; } setHorizontalOffset ( bgOffset + spinnerPaddingLeft ) ; setInputMethodMode ( PopupWindow . INPUT_METHOD_NOT_NEEDED ) ; super . show ( ) ; getListView ( ) . setChoiceMode ( ListView . CHOICE_MODE_SINGLE ) ; setSelection ( IcsSpinner . this . getSelectedItemPosition ( ) ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import static android . view . View . MeasureSpec . EXACTLY ; import android . content . Context ; import android . content . res . TypedArray ; import android . util . AttributeSet ; import android . util . DisplayMetrics ; import android . util . TypedValue ; import android . widget . LinearLayout ; import com . actionbarsherlock . R ; public class FakeDialogPhoneWindow extends LinearLayout { final TypedValue mMinWidthMajor = new TypedValue ( ) ; final TypedValue mMinWidthMinor = new TypedValue ( ) ; public FakeDialogPhoneWindow ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . SherlockTheme ) ; a . getValue ( R . styleable . SherlockTheme_windowMinWidthMajor , mMinWidthMajor ) ; a . getValue ( R . styleable . SherlockTheme_windowMinWidthMinor , mMinWidthMinor ) ; a . recycle ( ) ; } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { final DisplayMetrics metrics = getContext ( ) . getResources ( ) . getDisplayMetrics ( ) ; final boolean isPortrait = metrics . widthPixels < metrics . heightPixels ; super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; int width = getMeasuredWidth ( ) ; boolean measure = false ; widthMeasureSpec = MeasureSpec . makeMeasureSpec ( width , EXACTLY ) ; final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor ; if ( tv . type != TypedValue . TYPE_NULL ) { final int min ; if ( tv . type == TypedValue . TYPE_DIMENSION ) { min = ( int ) tv . getDimension ( metrics ) ; } else if ( tv . type == TypedValue . TYPE_FRACTION ) { min = ( int ) tv . getFraction ( metrics . widthPixels , metrics . widthPixels ) ; } else { min = <NUM_LIT:0> ; } if ( width < min ) { widthMeasureSpec = MeasureSpec . makeMeasureSpec ( min , EXACTLY ) ; measure = true ; } } if ( measure ) { super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import java . util . Locale ; import android . content . Context ; import android . content . res . TypedArray ; import android . os . Build ; import android . util . AttributeSet ; import android . widget . Button ; public class CapitalizingButton extends Button { private static final boolean SANS_ICE_CREAM = Build . VERSION . SDK_INT < Build . VERSION_CODES . ICE_CREAM_SANDWICH ; private static final boolean IS_GINGERBREAD = Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ; private static final int [ ] R_styleable_Button = new int [ ] { android . R . attr . textAllCaps } ; private static final int R_styleable_Button_textAllCaps = <NUM_LIT:0> ; private boolean mAllCaps ; public CapitalizingButton ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; TypedArray a = context . obtainStyledAttributes ( attrs , R_styleable_Button ) ; mAllCaps = a . getBoolean ( R_styleable_Button_textAllCaps , true ) ; a . recycle ( ) ; } public void setTextCompat ( CharSequence text ) { if ( SANS_ICE_CREAM && mAllCaps && text != null ) { if ( IS_GINGERBREAD ) { setText ( text . toString ( ) . toUpperCase ( Locale . ROOT ) ) ; } else { setText ( text . toString ( ) . toUpperCase ( ) ) ; } } else { setText ( text ) ; } } } </s>
<s> package com . actionbarsherlock . internal . widget ; import android . content . Context ; import android . database . DataSetObserver ; import android . os . Parcelable ; import android . os . SystemClock ; import android . util . AttributeSet ; import android . util . SparseArray ; import android . view . ContextMenu ; import android . view . SoundEffectConstants ; import android . view . View ; import android . view . ViewDebug ; import android . view . ViewGroup ; import android . view . accessibility . AccessibilityEvent ; import android . view . accessibility . AccessibilityNodeInfo ; import android . widget . Adapter ; import android . widget . AdapterView . OnItemClickListener ; import android . widget . ListView ; public abstract class IcsAdapterView < T extends Adapter > extends ViewGroup { public static final int ITEM_VIEW_TYPE_IGNORE = - <NUM_LIT:1> ; public static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER = - <NUM_LIT:2> ; @ ViewDebug . ExportedProperty ( category = "<STR_LIT>" ) int mFirstPosition = <NUM_LIT:0> ; int mSpecificTop ; int mSyncPosition ; long mSyncRowId = INVALID_ROW_ID ; long mSyncHeight ; boolean mNeedSync = false ; int mSyncMode ; private int mLayoutHeight ; static final int SYNC_SELECTED_POSITION = <NUM_LIT:0> ; static final int SYNC_FIRST_POSITION = <NUM_LIT:1> ; static final int SYNC_MAX_DURATION_MILLIS = <NUM_LIT:100> ; boolean mInLayout = false ; OnItemSelectedListener mOnItemSelectedListener ; OnItemClickListener mOnItemClickListener ; OnItemLongClickListener mOnItemLongClickListener ; boolean mDataChanged ; @ ViewDebug . ExportedProperty ( category = "<STR_LIT:list>" ) int mNextSelectedPosition = INVALID_POSITION ; long mNextSelectedRowId = INVALID_ROW_ID ; @ ViewDebug . ExportedProperty ( category = "<STR_LIT:list>" ) int mSelectedPosition = INVALID_POSITION ; long mSelectedRowId = INVALID_ROW_ID ; private View mEmptyView ; @ ViewDebug . ExportedProperty ( category = "<STR_LIT:list>" ) int mItemCount ; int mOldItemCount ; public static final int INVALID_POSITION = - <NUM_LIT:1> ; public static final long INVALID_ROW_ID = Long . MIN_VALUE ; int mOldSelectedPosition = INVALID_POSITION ; long mOldSelectedRowId = INVALID_ROW_ID ; private boolean mDesiredFocusableState ; private boolean mDesiredFocusableInTouchModeState ; private SelectionNotifier mSelectionNotifier ; boolean mBlockLayoutRequests = false ; public IcsAdapterView ( Context context ) { super ( context ) ; } public IcsAdapterView ( Context context , AttributeSet attrs ) { super ( context , attrs ) ; } public IcsAdapterView ( Context context , AttributeSet attrs , int defStyle ) { super ( context , attrs , defStyle ) ; } public void setOnItemClickListener ( OnItemClickListener listener ) { mOnItemClickListener = listener ; } public final OnItemClickListener getOnItemClickListener ( ) { return mOnItemClickListener ; } public boolean performItemClick ( View view , int position , long id ) { if ( mOnItemClickListener != null ) { playSoundEffect ( SoundEffectConstants . CLICK ) ; if ( view != null ) { view . sendAccessibilityEvent ( AccessibilityEvent . TYPE_VIEW_CLICKED ) ; } mOnItemClickListener . onItemClick ( null , view , position , id ) ; return true ; } return false ; } public interface OnItemLongClickListener { boolean onItemLongClick ( IcsAdapterView < ? > parent , View view , int position , long id ) ; } public void setOnItemLongClickListener ( OnItemLongClickListener listener ) { if ( ! isLongClickable ( ) ) { setLongClickable ( true ) ; } mOnItemLongClickListener = listener ; } public final OnItemLongClickListener getOnItemLongClickListener ( ) { return mOnItemLongClickListener ; } public interface OnItemSelectedListener { void onItemSelected ( IcsAdapterView < ? > parent , View view , int position , long id ) ; void onNothingSelected ( IcsAdapterView < ? > parent ) ; } public void setOnItemSelectedListener ( OnItemSelectedListener listener ) { mOnItemSelectedListener = listener ; } public final OnItemSelectedListener getOnItemSelectedListener ( ) { return mOnItemSelectedListener ; } public static class AdapterContextMenuInfo implements ContextMenu . ContextMenuInfo { public AdapterContextMenuInfo ( View targetView , int position , long id ) { this . targetView = targetView ; this . position = position ; this . id = id ; } public View targetView ; public int position ; public long id ; } public abstract T getAdapter ( ) ; public abstract void setAdapter ( T adapter ) ; @ Override public void addView ( View child ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } @ Override public void addView ( View child , int index ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } @ Override public void addView ( View child , LayoutParams params ) { throw new UnsupportedOperationException ( "<STR_LIT>" + "<STR_LIT>" ) ; } @ Override public void addView ( View child , int index , LayoutParams params ) { throw new UnsupportedOperationException ( "<STR_LIT>" + "<STR_LIT>" ) ; } @ Override public void removeView ( View child ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } @ Override public void removeViewAt ( int index ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } @ Override public void removeAllViews ( ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } @ Override protected void onLayout ( boolean changed , int left , int top , int right , int bottom ) { mLayoutHeight = getHeight ( ) ; } @ ViewDebug . CapturedViewProperty public int getSelectedItemPosition ( ) { return mNextSelectedPosition ; } @ ViewDebug . CapturedViewProperty public long getSelectedItemId ( ) { return mNextSelectedRowId ; } public abstract View getSelectedView ( ) ; public Object getSelectedItem ( ) { T adapter = getAdapter ( ) ; int selection = getSelectedItemPosition ( ) ; if ( adapter != null && adapter . getCount ( ) > <NUM_LIT:0> && selection >= <NUM_LIT:0> ) { return adapter . getItem ( selection ) ; } else { return null ; } } @ ViewDebug . CapturedViewProperty public int getCount ( ) { return mItemCount ; } public int getPositionForView ( View view ) { View listItem = view ; try { View v ; while ( ! ( v = ( View ) listItem . getParent ( ) ) . equals ( this ) ) { listItem = v ; } } catch ( ClassCastException e ) { return INVALID_POSITION ; } final int childCount = getChildCount ( ) ; for ( int i = <NUM_LIT:0> ; i < childCount ; i ++ ) { if ( getChildAt ( i ) . equals ( listItem ) ) { return mFirstPosition + i ; } } return INVALID_POSITION ; } public int getFirstVisiblePosition ( ) { return mFirstPosition ; } public int getLastVisiblePosition ( ) { return mFirstPosition + getChildCount ( ) - <NUM_LIT:1> ; } public abstract void setSelection ( int position ) ; public void setEmptyView ( View emptyView ) { mEmptyView = emptyView ; final T adapter = getAdapter ( ) ; final boolean empty = ( ( adapter == null ) || adapter . isEmpty ( ) ) ; updateEmptyStatus ( empty ) ; } public View getEmptyView ( ) { return mEmptyView ; } boolean isInFilterMode ( ) { return false ; } @ Override public void setFocusable ( boolean focusable ) { final T adapter = getAdapter ( ) ; final boolean empty = adapter == null || adapter . getCount ( ) == <NUM_LIT:0> ; mDesiredFocusableState = focusable ; if ( ! focusable ) { mDesiredFocusableInTouchModeState = false ; } super . setFocusable ( focusable && ( ! empty || isInFilterMode ( ) ) ) ; } @ Override public void setFocusableInTouchMode ( boolean focusable ) { final T adapter = getAdapter ( ) ; final boolean empty = adapter == null || adapter . getCount ( ) == <NUM_LIT:0> ; mDesiredFocusableInTouchModeState = focusable ; if ( focusable ) { mDesiredFocusableState = true ; } super . setFocusableInTouchMode ( focusable && ( ! empty || isInFilterMode ( ) ) ) ; } void checkFocus ( ) { final T adapter = getAdapter ( ) ; final boolean empty = adapter == null || adapter . getCount ( ) == <NUM_LIT:0> ; final boolean focusable = ! empty || isInFilterMode ( ) ; super . setFocusableInTouchMode ( focusable && mDesiredFocusableInTouchModeState ) ; super . setFocusable ( focusable && mDesiredFocusableState ) ; if ( mEmptyView != null ) { updateEmptyStatus ( ( adapter == null ) || adapter . isEmpty ( ) ) ; } } private void updateEmptyStatus ( boolean empty ) { if ( isInFilterMode ( ) ) { empty = false ; } if ( empty ) { if ( mEmptyView != null ) { mEmptyView . setVisibility ( View . VISIBLE ) ; setVisibility ( View . GONE ) ; } else { setVisibility ( View . VISIBLE ) ; } if ( mDataChanged ) { this . onLayout ( false , getLeft ( ) , getTop ( ) , getRight ( ) , getBottom ( ) ) ; } } else { if ( mEmptyView != null ) mEmptyView . setVisibility ( View . GONE ) ; setVisibility ( View . VISIBLE ) ; } } public Object getItemAtPosition ( int position ) { T adapter = getAdapter ( ) ; return ( adapter == null || position < <NUM_LIT:0> ) ? null : adapter . getItem ( position ) ; } public long getItemIdAtPosition ( int position ) { T adapter = getAdapter ( ) ; return ( adapter == null || position < <NUM_LIT:0> ) ? INVALID_ROW_ID : adapter . getItemId ( position ) ; } @ Override public void setOnClickListener ( OnClickListener l ) { throw new RuntimeException ( "<STR_LIT>" + "<STR_LIT>" ) ; } @ Override protected void dispatchSaveInstanceState ( SparseArray < Parcelable > container ) { dispatchFreezeSelfOnly ( container ) ; } @ Override protected void dispatchRestoreInstanceState ( SparseArray < Parcelable > container ) { dispatchThawSelfOnly ( container ) ; } class AdapterDataSetObserver extends DataSetObserver { private Parcelable mInstanceState = null ; @ Override public void onChanged ( ) { mDataChanged = true ; mOldItemCount = mItemCount ; mItemCount = getAdapter ( ) . getCount ( ) ; if ( IcsAdapterView . this . getAdapter ( ) . hasStableIds ( ) && mInstanceState != null && mOldItemCount == <NUM_LIT:0> && mItemCount > <NUM_LIT:0> ) { IcsAdapterView . this . onRestoreInstanceState ( mInstanceState ) ; mInstanceState = null ; } else { rememberSyncState ( ) ; } checkFocus ( ) ; requestLayout ( ) ; } @ Override public void onInvalidated ( ) { mDataChanged = true ; if ( IcsAdapterView . this . getAdapter ( ) . hasStableIds ( ) ) { mInstanceState = IcsAdapterView . this . onSaveInstanceState ( ) ; } mOldItemCount = mItemCount ; mItemCount = <NUM_LIT:0> ; mSelectedPosition = INVALID_POSITION ; mSelectedRowId = INVALID_ROW_ID ; mNextSelectedPosition = INVALID_POSITION ; mNextSelectedRowId = INVALID_ROW_ID ; mNeedSync = false ; checkFocus ( ) ; requestLayout ( ) ; } public void clearSavedState ( ) { mInstanceState = null ; } } @ Override protected void onDetachedFromWindow ( ) { super . onDetachedFromWindow ( ) ; removeCallbacks ( mSelectionNotifier ) ; } private class SelectionNotifier implements Runnable { public void run ( ) { if ( mDataChanged ) { if ( getAdapter ( ) != null ) { post ( this ) ; } } else { fireOnSelected ( ) ; } } } void selectionChanged ( ) { if ( mOnItemSelectedListener != null ) { if ( mInLayout || mBlockLayoutRequests ) { if ( mSelectionNotifier == null ) { mSelectionNotifier = new SelectionNotifier ( ) ; } post ( mSelectionNotifier ) ; } else { fireOnSelected ( ) ; } } if ( mSelectedPosition != ListView . INVALID_POSITION && isShown ( ) && ! isInTouchMode ( ) ) { sendAccessibilityEvent ( AccessibilityEvent . TYPE_VIEW_SELECTED ) ; } } private void fireOnSelected ( ) { if ( mOnItemSelectedListener == null ) return ; int selection = this . getSelectedItemPosition ( ) ; if ( selection >= <NUM_LIT:0> ) { View v = getSelectedView ( ) ; mOnItemSelectedListener . onItemSelected ( this , v , selection , getAdapter ( ) . getItemId ( selection ) ) ; } else { mOnItemSelectedListener . onNothingSelected ( this ) ; } } @ Override public boolean dispatchPopulateAccessibilityEvent ( AccessibilityEvent event ) { View selectedView = getSelectedView ( ) ; if ( selectedView != null && selectedView . getVisibility ( ) == VISIBLE && selectedView . dispatchPopulateAccessibilityEvent ( event ) ) { return true ; } return false ; } @ Override public boolean onRequestSendAccessibilityEvent ( View child , AccessibilityEvent event ) { if ( super . onRequestSendAccessibilityEvent ( child , event ) ) { AccessibilityEvent record = AccessibilityEvent . obtain ( ) ; onInitializeAccessibilityEvent ( record ) ; child . dispatchPopulateAccessibilityEvent ( record ) ; event . appendRecord ( record ) ; return true ; } return false ; } @ Override public void onInitializeAccessibilityNodeInfo ( AccessibilityNodeInfo info ) { super . onInitializeAccessibilityNodeInfo ( info ) ; info . setScrollable ( isScrollableForAccessibility ( ) ) ; View selectedView = getSelectedView ( ) ; if ( selectedView != null ) { info . setEnabled ( selectedView . isEnabled ( ) ) ; } } @ Override public void onInitializeAccessibilityEvent ( AccessibilityEvent event ) { super . onInitializeAccessibilityEvent ( event ) ; event . setScrollable ( isScrollableForAccessibility ( ) ) ; View selectedView = getSelectedView ( ) ; if ( selectedView != null ) { event . setEnabled ( selectedView . isEnabled ( ) ) ; } event . setCurrentItemIndex ( getSelectedItemPosition ( ) ) ; event . setFromIndex ( getFirstVisiblePosition ( ) ) ; event . setToIndex ( getLastVisiblePosition ( ) ) ; event . setItemCount ( getCount ( ) ) ; } private boolean isScrollableForAccessibility ( ) { T adapter = getAdapter ( ) ; if ( adapter != null ) { final int itemCount = adapter . getCount ( ) ; return itemCount > <NUM_LIT:0> && ( getFirstVisiblePosition ( ) > <NUM_LIT:0> || getLastVisiblePosition ( ) < itemCount - <NUM_LIT:1> ) ; } return false ; } @ Override protected boolean canAnimate ( ) { return super . canAnimate ( ) && mItemCount > <NUM_LIT:0> ; } void handleDataChanged ( ) { final int count = mItemCount ; boolean found = false ; if ( count > <NUM_LIT:0> ) { int newPos ; if ( mNeedSync ) { mNeedSync = false ; newPos = findSyncPosition ( ) ; if ( newPos >= <NUM_LIT:0> ) { int selectablePos = lookForSelectablePosition ( newPos , true ) ; if ( selectablePos == newPos ) { setNextSelectedPositionInt ( newPos ) ; found = true ; } } } if ( ! found ) { newPos = getSelectedItemPosition ( ) ; if ( newPos >= count ) { newPos = count - <NUM_LIT:1> ; } if ( newPos < <NUM_LIT:0> ) { newPos = <NUM_LIT:0> ; } int selectablePos = lookForSelectablePosition ( newPos , true ) ; if ( selectablePos < <NUM_LIT:0> ) { selectablePos = lookForSelectablePosition ( newPos , false ) ; } if ( selectablePos >= <NUM_LIT:0> ) { setNextSelectedPositionInt ( selectablePos ) ; checkSelectionChanged ( ) ; found = true ; } } } if ( ! found ) { mSelectedPosition = INVALID_POSITION ; mSelectedRowId = INVALID_ROW_ID ; mNextSelectedPosition = INVALID_POSITION ; mNextSelectedRowId = INVALID_ROW_ID ; mNeedSync = false ; checkSelectionChanged ( ) ; } } void checkSelectionChanged ( ) { if ( ( mSelectedPosition != mOldSelectedPosition ) || ( mSelectedRowId != mOldSelectedRowId ) ) { selectionChanged ( ) ; mOldSelectedPosition = mSelectedPosition ; mOldSelectedRowId = mSelectedRowId ; } } int findSyncPosition ( ) { int count = mItemCount ; if ( count == <NUM_LIT:0> ) { return INVALID_POSITION ; } long idToMatch = mSyncRowId ; int seed = mSyncPosition ; if ( idToMatch == INVALID_ROW_ID ) { return INVALID_POSITION ; } seed = Math . max ( <NUM_LIT:0> , seed ) ; seed = Math . min ( count - <NUM_LIT:1> , seed ) ; long endTime = SystemClock . uptimeMillis ( ) + SYNC_MAX_DURATION_MILLIS ; long rowId ; int first = seed ; int last = seed ; boolean next = false ; boolean hitFirst ; boolean hitLast ; T adapter = getAdapter ( ) ; if ( adapter == null ) { return INVALID_POSITION ; } while ( SystemClock . uptimeMillis ( ) <= endTime ) { rowId = adapter . getItemId ( seed ) ; if ( rowId == idToMatch ) { return seed ; } hitLast = last == count - <NUM_LIT:1> ; hitFirst = first == <NUM_LIT:0> ; if ( hitLast && hitFirst ) { break ; } if ( hitFirst || ( next && ! hitLast ) ) { last ++ ; seed = last ; next = false ; } else if ( hitLast || ( ! next && ! hitFirst ) ) { first -- ; seed = first ; next = true ; } } return INVALID_POSITION ; } int lookForSelectablePosition ( int position , boolean lookDown ) { return position ; } void setSelectedPositionInt ( int position ) { mSelectedPosition = position ; mSelectedRowId = getItemIdAtPosition ( position ) ; } void setNextSelectedPositionInt ( int position ) { mNextSelectedPosition = position ; mNextSelectedRowId = getItemIdAtPosition ( position ) ; if ( mNeedSync && mSyncMode == SYNC_SELECTED_POSITION && position >= <NUM_LIT:0> ) { mSyncPosition = position ; mSyncRowId = mNextSelectedRowId ; } } void rememberSyncState ( ) { if ( getChildCount ( ) > <NUM_LIT:0> ) { mNeedSync = true ; mSyncHeight = mLayoutHeight ; if ( mSelectedPosition >= <NUM_LIT:0> ) { View v = getChildAt ( mSelectedPosition - mFirstPosition ) ; mSyncRowId = mNextSelectedRowId ; mSyncPosition = mNextSelectedPosition ; if ( v != null ) { mSpecificTop = v . getTop ( ) ; } mSyncMode = SYNC_SELECTED_POSITION ; } else { View v = getChildAt ( <NUM_LIT:0> ) ; T adapter = getAdapter ( ) ; if ( mFirstPosition >= <NUM_LIT:0> && mFirstPosition < adapter . getCount ( ) ) { mSyncRowId = adapter . getItemId ( mFirstPosition ) ; } else { mSyncRowId = NO_ID ; } mSyncPosition = mFirstPosition ; if ( v != null ) { mSpecificTop = v . getTop ( ) ; } mSyncMode = SYNC_FIRST_POSITION ; } } } } </s>