List of usage examples for java.util HashMap clear
public void clear()
From source file:pl.otros.logview.parser.log4j.Log4jPatternMultilineLogParser.java
/** * Construct a logging event from currentMap and additionalLines (additionalLines contains multiple message lines and any exception lines) * <p>//from w w w .j a va2s . co m * CurrentMap and additionalLines are cleared in the process * * @return event */ private LoggingEvent buildEvent(ParsingContext ctx) { HashMap<String, Object> logEventParsingProperitesMap = (HashMap<String, Object>) ctx .getCustomConextProperties().get(PROPERTY_LOG_EVENT_PROPERTIES); if (logEventParsingProperitesMap.size() == 0) { String[] additionalLines = ctx.getUnmatchedLog().toString().split("\n"); for (String line : additionalLines) { LOG.finest(String.format("found non-matching (file %s) line: \"%s\"", ctx.getLogSource(), line)); } ctx.getUnmatchedLog().setLength(0); return null; } // the current map contains fields - build an event int exceptionLine = getExceptionLine(ctx); String[] exception = buildException(exceptionLine, ctx); String[] additionalLines = ctx.getUnmatchedLog().toString().split("\n"); // messages are listed before exceptions in additional lines if (additionalLines.length > 0 && exception.length > 0) { logEventParsingProperitesMap.put(MESSAGE, buildMessage((String) logEventParsingProperitesMap.get(MESSAGE), exceptionLine, ctx)); } DateFormat dateFormat = ctx.getDateFormat(); LoggingEvent event = convertToEvent(logEventParsingProperitesMap, exception, dateFormat); logEventParsingProperitesMap.clear(); ctx.getUnmatchedLog().setLength(0); return event; }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testMultipleContentTypes() throws IOException { String methodName = "testMultipleContentTypes"; LOGGER.debug("*************** START: " + methodName + " *****************"); String type1 = "type1"; String version1 = "version1"; String type2 = "type2"; String version2 = "version2"; String type3 = "type3"; String version4 = "version4"; MetacardImpl metacard = new MetacardImpl(); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); List<MockTypeVersionsExtension> extensions = createContentTypeVersionList( "type1,version1|type2,version2|type3,|,version4"); MockQuery query = new MockQuery(); query.addTypeFilter(extensions);/*w w w . j a v a 2s.c o m*/ SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate pred = (Predicate) query.getFilter().accept(visitor, null); LOGGER.debug("Resulting Predicate: " + pred); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1 + "," + version1); Event testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type2 + "," + version2); testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type2 + "," + version1); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1 + "," + version2); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type3 + "," + "random_version"); testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "random_type" + "," + "random_version"); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "random_type" + "," + version4); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testContentTypeEvaluation() throws IOException { String methodName = "testContentTypeEvaluation"; LOGGER.debug("*************** START: " + methodName + " *****************"); // test input that has type1:version1 matches // test input that has type1:version2 doesn't match // TODO: tests input that has type2:version1 doesn't match // TODO: test input that has type1:"" // TODO: test input that has "":"" // TODO: test input that has "":version1 // TODO: test UNKNOWN for entire contentType String MetacardImpl metacard = new MetacardImpl(); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); ContentTypePredicate ctp = new ContentTypePredicate("type1", "version1"); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "type1,version1"); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl Event testEvent = new Event("topic", properties); assertTrue(ctp.matches(testEvent));/* w w w . j av a2 s .co m*/ properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "type1,version2"); Event testEvent1 = new Event("topic1", properties); assertFalse(ctp.matches(testEvent1)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, ",version2"); testEvent1 = new Event("topic1", properties); assertFalse(ctp.matches(testEvent1)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "type1,"); testEvent1 = new Event("topic1", properties); assertFalse(ctp.matches(testEvent1)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, ","); testEvent1 = new Event("topic1", properties); assertFalse(ctp.matches(testEvent1)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "UNKNOWN"); testEvent1 = new Event("topic1", properties); assertFalse(ctp.matches(testEvent1)); // TODO: test input type1:version1 matches // TODO: test input type1:someversion matches // TODO: test input type2:version1 doesn't match ContentTypePredicate ctp2 = new ContentTypePredicate("type1", null); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "type1,version1"); Event testEvent2 = new Event("topic", properties); assertTrue(ctp2.matches(testEvent2)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "type1,someversion"); Event testEvent3 = new Event("topic", properties); assertTrue(ctp2.matches(testEvent3)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "type2,someversion"); Event testEvent4 = new Event("topic", properties); assertFalse(ctp2.matches(testEvent4)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:org.rhq.enterprise.server.installer.ServerInstallUtil.java
private static void createNewDatasources_Postgres(ModelControllerClient mcc) throws Exception { final HashMap<String, String> props = new HashMap<String, String>(4); final DatasourceJBossASClient client = new DatasourceJBossASClient(mcc); ModelNode noTxDsRequest = null;/*from w w w. j av a2s . co m*/ ModelNode xaDsRequest = null; if (!client.isDatasource(RHQ_DATASOURCE_NAME_NOTX)) { props.put("char.encoding", "UTF-8"); noTxDsRequest = client.createNewDatasourceRequest(RHQ_DATASOURCE_NAME_NOTX, 30000, "${rhq.server.database.connection-url:jdbc:postgresql://127.0.0.1:5432/rhq}", JDBC_DRIVER_POSTGRES, "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter", 15, false, 2, 5, 75, RHQ_DS_SECURITY_DOMAIN_NOTX, "-unused-stale-conn-checker-", "TRANSACTION_READ_COMMITTED", "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker", true, props); noTxDsRequest.get("steps").get(0).remove("stale-connection-checker-class-name"); // we don't have one of these for postgres } else { LOG.info("Postgres datasource [" + RHQ_DATASOURCE_NAME_NOTX + "] already exists"); } if (!client.isXADatasource(RHQ_DATASOURCE_NAME_XA)) { props.clear(); props.put("ServerName", "${rhq.server.database.server-name:127.0.0.1}"); props.put("PortNumber", "${rhq.server.database.port:5432}"); props.put("DatabaseName", "${rhq.server.database.db-name:rhq}"); xaDsRequest = client.createNewXADatasourceRequest(RHQ_DATASOURCE_NAME_XA, 30000, JDBC_DRIVER_POSTGRES, XA_DATASOURCE_CLASS_POSTGRES, "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter", 15, 5, 50, (Boolean) null, (Boolean) null, 75, (String) null, RHQ_DS_SECURITY_DOMAIN_XA, (String) null, "TRANSACTION_READ_COMMITTED", "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker", props); } else { LOG.info("Postgres XA datasource [" + RHQ_DATASOURCE_NAME_XA + "] already exists"); } if (noTxDsRequest != null || xaDsRequest != null) { ModelNode batch = DatasourceJBossASClient.createBatchRequest(noTxDsRequest, xaDsRequest); ModelNode results = client.execute(batch); if (!DatasourceJBossASClient.isSuccess(results)) { throw new FailureException(results, "Failed to create Postgres datasources"); } } }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testContentTypeFilter() throws Exception { String methodName = "testContentTypeFilter"; LOGGER.debug("*************** START: " + methodName + " *****************"); MetacardImpl metacard = new MetacardImpl(); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); String type = "type_1"; String version = "v1"; List<MockTypeVersionsExtension> extensions = new ArrayList<>(); MockTypeVersionsExtension ext1 = new MockTypeVersionsExtension(); List<String> ext1Versions = ext1.getVersions(); ext1Versions.add(version);/* w w w . jav a 2s . co m*/ ext1.setExtensionTypeName(type); extensions.add(ext1); MockQuery query = new MockQuery(); query.addTypeFilter(extensions); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate pred = (Predicate) query.getFilter().accept(visitor, null); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type + "," + version); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); // Below Pulled from PubSubProviderImpl Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl Event testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type + "," + "unmatching_version"); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "unmatchingtype" + "," + version); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "unmatchingtype" + "," + "unmatchingversion"); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testContentTypesWildcard() throws IOException { String methodName = "testContentTypesWildcard"; LOGGER.debug("*************** START: " + methodName + " *****************"); String type1 = "type1*"; String type1Input = "type1"; String version1 = "version1"; String type2 = "type2"; String version2 = "version2*"; String version2Input = "version2abc"; String type3 = "ty*pe3"; String type3Input = "type3"; String version4 = "version4"; MetacardImpl metacard = new MetacardImpl(); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); List<MockTypeVersionsExtension> extensions = new ArrayList<>(); MockTypeVersionsExtension ext1 = new MockTypeVersionsExtension(); List<String> ext1Versions = ext1.getVersions(); ext1Versions.add(version1);//from w ww . j a v a 2 s. co m ext1.setExtensionTypeName(type1); extensions.add(ext1); MockTypeVersionsExtension ext2 = new MockTypeVersionsExtension(); List<String> ext2Versions = ext2.getVersions(); ext2Versions.add(version2); ext2.setExtensionTypeName(type2); extensions.add(ext2); // No version MockTypeVersionsExtension ext3 = new MockTypeVersionsExtension(); ext3.setExtensionTypeName(type3); extensions.add(ext3); // No type, only version(s) MockTypeVersionsExtension ext4 = new MockTypeVersionsExtension(); List<String> ext4Versions = ext4.getVersions(); ext4Versions.add(version4); extensions.add(ext4); MockQuery query = new MockQuery(); query.addTypeFilter(extensions); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate pred = (Predicate) query.getFilter().accept(visitor, null); LOGGER.debug("Resulting Predicate: " + pred); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1Input + "," + version1); Event testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type2 + "," + version2Input); testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type2 + "," + version1); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1 + "," + version2); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type3Input + "," + "random_version"); testEvent = new Event("topic", properties); assertTrue(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "random_type" + "," + "random_version"); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "random_type" + "," + version4); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testContextualQuery() throws Exception { String methodName = "testContextualQuery"; LOGGER.debug("*************** START: " + methodName + " *****************"); String searchPhrase = "serengeti event"; MockQuery query = new MockQuery(); query.addContextualFilter(searchPhrase, null); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate predicate = (Predicate) query.getFilter().accept(visitor, null); MetacardImpl metacard = new MetacardImpl(); metacard.setId("ABC123"); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_ID_KEY, metacard.getId()); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl Event testEvent = new Event("topic", properties); assertTrue(predicate.matches(testEvent)); contextualMap.clear();/*from w w w .j a v a2 s . com*/ properties.clear(); metacard.setMetadata(TestDataLibrary.getDogEntry()); Directory index1 = ContextualEvaluator.buildIndex(metacard.getMetadata()); contextualMap.put("DEFAULT_INDEX", index1); contextualMap.put("METADATA", metacard.getMetadata()); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_ID_KEY, metacard.getId()); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); testEvent = new Event("topic", properties); assertFalse(predicate.matches(testEvent)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:com.knowbout.epg.processor.Parser.java
/** * Field # Field Name Min Max Field Description Field Example * 1 tf_database_key[3] 12 12 Unique description identifier, necessary to reference movies, shows, episodes, sports from description file. MV1234560000; SH0123450000 * 2 tf_title 1 120 Official name by which a movie, show, episode or sports event is known. In the Heat of the Night * 3 tf_reduced_title 70 Shortened version of a program's original title. In the Heat of Night * 4 tf_reduced_title 40 Shortened version of a program's original title. Heat of the Night * 5 tf_reduced_title 20 Shortened version of a program's original title. Heat of Night * 6 tf_reduced_title 10 Shortened version of a program's original title. Heat * 7 tf_alt_title 120 Alias name for program title; the title Paid Programming is stored here. Feed the Children * 8 tf_reduced_desc 100 Shorter version of a program's original description. Pete and Berg tell Bill the story of how they met Sharon in college. * 9 tf_reduced_desc 60 Shorter version of a program's original description. Pete and Berg tell Bill how they met Sharon in college. * 10 tf_reduced_desc 40 Shorter version of a program's original description. Pete and Berg recall how they met Sharon. * 11 tf_advisory_desc 30 Notation of adult content in movies, shows and episodes. Adult Situations * 12 tf_advisory_desc 30 Notation of explicit language in movies, shows and episodes. Graphic Language * 13 tf_advisory_desc 30 Notation of nudity in movies, shows and episodes. Brief Nudity * 14 tf_advisory_desc 30 Notation of violence in movies, shows and episodes. Graphic Violence * 15 tf_advisory_desc 30 Notation of sexual content in movies, shows and episodes. Strong Sexual Content * 16 tf_advisory_desc 30 Notation of rape in movies, shows and episodes. Rape * 17,20- 74 tf_cast_first_name 20 First name of an actor listed in the cast of a show, episode or movie. Tom * 18,21- 75 tf_cast_last_name 20 Last name of an actor listed in the cast of a show, episode or movie. Hanks * 19,22-76 tf_cast_role_desc 30 Designates actor or guest star. Actor * 77,80-134 tf_credits_first_name 20 First name of a host, director, producer, executive producer or writer of a show, episode or movie. Cameron * 78,81-135 tf_credits_last_name 20 Last name of a host, director, producer, executive producer or writer of a show, episode or movie. Crowe * 79,82-136 tf_credits_role_desc 30 Describes programming credits of a show or movie. Director * 137-142 tf_genre_desc (See Appendix A) 30 Word or group of words that classifies a show, episode, movie or sports event. Cooking * 143 tf_desc 255 Word string that describes the show, episode or movie content. Roseanne buys a shiny new 1998 Chevy Camaro. * 144 tf_year 4 The year in which a feature film was released; yyyy format; for movies only. 1998 * 145 tf_mpaa_rating 5 Rating supplied by the Motion Picture Association of America; for movies only. PG-13 * 146 tf_star_rating 5 In movies, an arbitrary critical rating from 1/2 to 4 stars. ***+ * 147 tf_run_time 4 Actual length of time any programming airs. Not the same as duration; hhmm format; for movies only. 0059 is fifty-nine minutes; 0125 is one hour and twenty five minutes * 148 tf_color_code 20 Designates whether a program was produced in color or black/white. Colorized * 149 tf_program_language 10 Language of the copy (description) of a program. Spanish * 150 tf_org_country 15 Used in movies to distinguish between domestic and foreign films. Also known as country of origin. United States * 151 tf_made_for_tv 1 Designator for a film that was made specifically for television. Y or N * 152 tf_source_type 10 Specifies network, local, syndicated or multiple-block programming. Syndicated * 153 tf_show_type 30 Distinguishes how a program was originally produced and/or distributed. Paid Programming; Series * 154 tf_holiday 30 Description of a recognized or traditional holiday. Christmas * 155 tf_syn_epi_num 20 Distributor-designated number corresponding to an episode of a specific show. 16 * 156 tf_alt_syn_epi_num 20 Alternate numbering system for syndicated programming. Can differ from syndicated numbering system. 809 * 157 tf_epi_title 150 Also known as the subtitle; descriptive title within an episode; team vs. team can be located here. The Puffy Shirt; Super Bowl XXXIII: Atlanta Falcons vs. Denver Broncos * 158 tf_net_syn_source 10 Originating network. Fox * 159 tf_net_syn_type 21 Specifies broadcast network, first run syndicated, cash barter or off-network programming. First run syndicated * 160 tf_desc 255 Word string that describes the show, episode or movie content and includes embedded actors within the description. A tornado whisks Kansas farm girl Dorothy (Judy Garland) and her dog, Toto, to a magical land populated by odd characters (Ray Bolger)(Bert Lahr). * 161 tf_reduced_desc 100 Shorter version of a program's original description which includes embedded actors within the description. A tornado whisks Kansas farm girl Dorothy (Judy Garland) into a magical land. * 162 tf_org_studio 25 Name of company responsible for the distribution of a movie. 20th Century Fox * 163 tf_game_date 8 Game date as reported by league or station schedule; yyyymmdd format. 19991025 * 164 tf_game_time 4 Game time as reported by league or station schedule; hhmm format. 1700 * 165 tf_game_time_zone 30 Time zone of tf_game_time, not necessarily the time zone of the event. Eastern D.S. * 166 tf_org_air_date 8 Original air date for the program. 19960914 * 167 tf_unique_id 8 Unique hexadecimal ID for the program. 15b9275a * 168-180 tf_user_data reserved/* w ww . j a v a 2 s . co m*/ * @param stream * @throws IOException */ private void parseProgram(InputStream stream) throws IOException { HashMap<String, Program> programs = new HashMap<String, Program>(); HashMap<Long, Credit> credits = new HashMap<Long, Credit>(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy"); SimpleDateFormat yearMonthDayFormat = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat hourMinutesFormat = new SimpleDateFormat("HHmm"); BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "Cp850")); String line = reader.readLine(); Date lastModified = new Date(); int count = 1; while (line != null) { if (count++ % programTransaction == 0) { log.debug("Committing transaction for programs, count=" + count); if (TransactionManager.currentTransaction().isActive()) { log.debug("it is an active transaction"); } else { log.debug("it is NOT an active transaction"); } TransactionManager.commitTransaction(); TransactionManager.beginTransaction(); log.debug("Begun another transaction for programs"); if (TransactionManager.currentTransaction().isActive()) { log.debug("it is an active transaction"); } else { log.debug("it is NOT an active transaction"); } programs.clear(); credits.clear(); } String[] parts = line.split("\\|", -1); String programId = parts[0]; if (programId.trim().length() == 0) { line = reader.readLine(); continue; } Program program = programs.get(programId); if (program == null) { program = Program.selectById(programId); if (program == null) { program = new Program(); program.setProgramId(programId); program.setLastModified(lastModified); program.insert(); programs.put(programId, program); parseCredits(program, parts, credits); } } else { log.debug(" Found duplicate program for : " + programId + " in line " + Arrays.asList(parts)); } //PENDING(CE): Always set last modified so the file can be checked for updates to //the schedule and/or other fields. program.setLastModified(lastModified); String oldTitle = program.getProgramTitle(); if ((oldTitle == null && parts[1].length() > 0) || (oldTitle != null && !oldTitle.equals(parts[1]))) { program.setLastModified(lastModified); } program.setProgramTitle(parts[1]); program.setReducedTitle70(parts[2]); program.setReducedTitle40(parts[3]); program.setReducedTitle20(parts[4]); program.setReducedTitle10(parts[5]); program.setAltTitle(parts[6]); program.setReducedDescription120(parts[7]); program.setReducedDescription60(parts[8]); program.setReducedDescription40(parts[9]); program.setAdultSituationsAdvisory(parts[10]); program.setGraphicLanguageAdvisory(parts[11]); program.setBriefNudityAdvisory(parts[12]); program.setGraphicViolenceAdvisory(parts[13]); program.setSscAdvisory(parts[14]); program.setRapeAdvisory(parts[15]); //TODO need to address Genre StringBuilder genre = new StringBuilder(); for (int g = 136; g < 142; g++) { if (parts[g].length() > 0) { if (genre.length() > 0) { genre.append(", "); } genre.append(parts[g]); } } String genreDescription = genre.toString(); if (genreDescription.length() > 99) { genreDescription = genreDescription.substring(0, 100); } program.setGenreDescription(genreDescription); String oldDescription = program.getDescription(); if ((oldDescription == null && parts[142].length() > 0) || (oldDescription != null && !oldDescription.equals(parts[142]))) { program.setLastModified(lastModified); } program.setDescription(parts[142]); if (parts[143].length() > 0) { try { program.setYear(dateFormat.parse(parts[143])); } catch (ParseException e) { log.error("Parse exception", e); } } program.setMpaaRating(parts[144]); String rating = parts[145]; if (rating.length() > 0) { if (rating.indexOf("+") > 0) { program.setStarRating((float) rating.length() - .5f); } else { program.setStarRating(rating.length()); } } String runtime = parts[146]; if (runtime.length() == 4) { int hours = Integer.parseInt(runtime.substring(0, 2)); int minutes = Integer.parseInt(runtime.substring(2, 4)); program.setRunTime(hours * 60 + minutes); } else if (runtime.length() == 2) { program.setRunTime(Integer.parseInt(runtime)); } program.setColorCode(parts[147]); program.setProgramLanguage(parts[149]); program.setOrgCountry(parts[149]); program.setMadeForTv(parts[150].length() > 0 ? parts[150].equalsIgnoreCase("Y") : false); program.setSourceType(parts[151]); program.setShowType(parts[152]); program.setHoliday(parts[153]); program.setSynEpiNum(parts[154]); program.setAltSynEpiNum(parts[155]); program.setEpisodeTitle(parts[156]); program.setNetSynSource(parts[157]); program.setNetSynType(parts[158]); program.setDescriptionActors(parts[159]); program.setReducedDescriptionActors(parts[160]); program.setOrgStudio(parts[161]); if (parts[162].length() > 0) { try { program.setGameDate(yearMonthDayFormat.parse(parts[162])); } catch (ParseException e) { log.error("Parse exception", e); } } if (parts[163].length() > 0) { try { program.setGameTime(hourMinutesFormat.parse(parts[163])); } catch (ParseException e) { log.error("Parse exception", e); } } program.setGameTimeZone(parts[164]); if (parts[165].length() > 0) { try { program.setOrginalAirDate(yearMonthDayFormat.parse(parts[165])); } catch (ParseException e) { log.error("Parse exception", e); } } program.setUniqueId(parts[166]); line = reader.readLine(); } reader.close(); }
From source file:de.xirp.ui.widgets.ApplicationSplashScreen.java
/** * Runs the splash screen and starts the loading of the * application.//from w w w .j a v a2 s. c om */ private void start() { XShell shell = new XShell(display, SWT.NO_TRIM | SWT.DOUBLE_BUFFERED | (Version.DEVELOPMENT ? SWT.NONE : SWT.ON_TOP)); shell.setText("Loading..."); //$NON-NLS-1$ shell.setImage(ImageManager.getSystemImage(SystemImage.TRAY)); // Font to use final Font TEXT = FontManager.getFont("Arial", 10, SWT.NORMAL); //$NON-NLS-1$ // Colors to use final Color DARK_GREEN = ColorManager.getColor(29, 114, 36); final Color GREY_GREEN = ColorManager.getColor(170, 178, 144); // load the image into memory Image image = ImageManager.getFullPathImageCopy(Constants.IMAGE_DIR + File.separator + "splash.png"); //$NON-NLS-1$ // get the image data ImageData imdata = image.getImageData(); // set the shell just large enough to hold the image shell.setSize(imdata.width, imdata.height); // get the bounds of the display to centre the shell on the // screen Rectangle r = display.getBounds(); int shellX = (r.width - imdata.width) / 2; int shellY = (r.height - imdata.height) / 2; shell.setLocation(shellX, shellY); // open the shell, and draw the image shell.open(); shell.forceFocus(); shell.forceActive(); // ProgressBar to show the loading status final ProgressBar pg = new ProgressBar(shell, SWT.HORIZONTAL); final int base = 100000; pg.setSize(shell.getSize().x - 10, 18); pg.setLocation(5, shell.getSize().y - pg.getSize().y - 5); pg.setForeground(DARK_GREEN); pg.setMinimum(0); pg.setMaximum(base); // Label that shows the version number Label version = new Label(shell, SWT.NONE); version.setSize(shell.getSize().x - 10, 17); version.setLocation(pg.getLocation().x, pg.getLocation().y - version.getSize().y - 25); version.setBackground(GREY_GREEN); version.setForeground(DARK_GREEN); version.setFont(TEXT); version.setText(Constants.BASE_NAME + " Version " + Version.MAJOR_VERSION + "." //$NON-NLS-1$ //$NON-NLS-2$ + Version.MINOR_VERSION + "." + Version.PATCH_LEVEL //$NON-NLS-1$ + " Revision " + Version.REVISION);//$NON-NLS-1$ // Label that shows what is loaded at the moment mesg = new Label(shell, SWT.NONE); mesg.setSize(shell.getSize().x - 10, 17); mesg.setLocation(pg.getLocation().x, pg.getLocation().y - mesg.getSize().y - 5); mesg.setBackground(GREY_GREEN); mesg.setForeground(DARK_GREEN); mesg.setFont(TEXT); // Draw Application Start image GC gc = new GC(shell); gc.drawImage(image, 0, 0); /* * Load data in the background and update progress bar and * message. */ HashMap<String, Double> percents = new HashMap<String, Double>(); try { percents = ObjectDeSerializer.<HashMap<String, Double>>getObject(startUpFile); } catch (IOException e) { logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); } catch (SerializationException e) { logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); } long overAllStart = System.nanoTime(); long start = System.nanoTime(); createDirectories(); mesg.setText(I18n.getString("ApplicationSplashScreen.gui.loadingApplication")); app = new Application(); double percentage = 0.006799464; if (percents.containsKey(LOADING_APP_KEY)) { percentage = percents.get(LOADING_APP_KEY); } pg.setSelection((int) (pg.getMaximum() * percentage)); long end = System.nanoTime(); long diffLoadingApp = end - start; start = System.nanoTime(); mesg.setText(I18n.getString("ApplicationSplashScreen.gui.loadingProperties")); percentage = 0.493550042; if (percents.containsKey(MANAGER_KEY)) { percentage = percents.get(MANAGER_KEY); } ManagerFactory.start(pg, mesg, percentage); pg.setSelection((int) (pg.getMaximum() * percentage)); end = System.nanoTime(); long diffManager = end - start; mesg.setText(I18n.getString("ApplicationSplashScreen.gui.loadUI")); app.runApp();// 0.499650494 pg.setSelection(pg.getMaximum()); mesg.setText(I18n.getString("ApplicationSplashScreen.gui.loadCompleted")); long overAllEnd = System.nanoTime(); long overAllDiff = overAllEnd - overAllStart; double percentLoadingApp = diffLoadingApp / (double) overAllDiff; double percentLoadingManager = diffManager / (double) overAllDiff; percents.clear(); percents.put(LOADING_APP_KEY, percentLoadingApp); percents.put(MANAGER_KEY, percentLoadingManager); try { ObjectSerializer.<HashMap<String, Double>>writeToDisk(percents, startUpFile); } catch (IOException e) { logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); } // Wait to show the user the 100% ProgressBar try { Thread.sleep(150); } catch (InterruptedException e) { logClass.error(e); } // dispose of the image, font, colors and shell gc.dispose(); image.dispose(); shell.dispose(); // Show the Application app.show(); }
From source file:org.shareok.data.sagedata.SageSourceDataHandlerImpl.java
/** * Organize the raw data in order to retrieve the necessary information to * request the metadata Note: this method is closely depending on the excel * file format// www . ja va2s . com */ @Override public void processSourceData() { if (null == data || data.isEmpty()) { readSourceData(); if (null == data || data.isEmpty()) { return; } } try { Set keys = data.keySet(); Iterator it = keys.iterator(); int rowPre = 0; HashMap articleData = new HashMap(); while (it.hasNext()) { String key = (String) it.next(); String value = (String) data.get(key); // the values is composed of "val--datatype": for example, Tom--Str or 0.50--num String[] values = value.split("--"); if (null == values || values.length != 2) { continue; } value = values[0]; String[] rowCol = key.split("-"); if (null == rowCol || rowCol.length != 2) { throw new Exception("The row and column are not specifid!"); } int row = Integer.parseInt(rowCol[0]); int col = Integer.parseInt(rowCol[1]); if (row != rowPre) { rowPre = row; if (null != articleData && !articleData.isEmpty()) { if (null == itemData) { itemData = new ArrayList<HashMap>(); } Object articleDataCopy = articleData.clone(); itemData.add((HashMap) articleDataCopy); articleData.clear(); } } if (0 != row) { switch (col) { case 0: articleData.put("journal", value); break; case 2: articleData.put("title", value); break; case 3: articleData.put("volume", value); break; case 4: articleData.put("issue", value); break; case 5: articleData.put("pages", value); break; case 6: articleData.put("year", value); break; case 7: articleData.put("citation", value); break; case 8: articleData.put("pubdate", value); break; case 9: articleData.put("doi", value); break; case 10: articleData.put("url", value); break; default: break; } } } // Put the last article into itemData: if (null != articleData && !articleData.isEmpty()) { if (null == itemData) { itemData = new ArrayList<HashMap>(); } Object articleDataCopy = articleData.clone(); itemData.add((HashMap) articleDataCopy); articleData.clear(); } } catch (Exception e) { e.printStackTrace(); } }