List of usage examples for java.util GregorianCalendar set
public void set(int field, int value)
From source file:org.apache.torque.generated.peer.DateTest.java
/** * Checks that a select is possible when milliseconds are used. * in databases where this is supported. * * @throws TorqueException if a problem occurs. *//*from ww w. j ava 2 s . c o m*/ public void testSelectWithMillisecondsOnTimestampExactMatch() throws TorqueException { cleanDateTimeTimestampTable(); // insert new DateTest object to db DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType(); dateTimeTimestamp.setDateValue(new Date()); dateTimeTimestamp.setTimeValue(new Date()); GregorianCalendar calendar = new GregorianCalendar(2010, 1, 23); calendar.set(GregorianCalendar.MILLISECOND, 123); dateTimeTimestamp.setTimestampValue(calendar.getTime()); dateTimeTimestamp.save(); // execute matching select Criteria criteria = new Criteria(); calendar = new GregorianCalendar(2010, 1, 23); calendar.set(GregorianCalendar.MILLISECOND, 123); criteria.where(DateTimeTimestampTypePeer.TIMESTAMP_VALUE, calendar.getTime()); List<DateTimeTimestampType> result = DateTimeTimestampTypePeer.doSelect(criteria); // verify assertEquals(1, result.size()); assertEquals(dateTimeTimestamp, result.get(0)); }
From source file:org.apache.torque.generated.peer.DateTest.java
/** * Checks that a select does not match when a timestamp to select * is a millisecond away from the timestamp saved in the database. * * @throws TorqueException if a problem occurs. *//*from w ww . j a v a 2 s .c o m*/ public void testSelectWithMillisecondsOnTimestampMillisecondMismatch() throws TorqueException { if (!timestampHasMillisecondAccuracy()) { return; } cleanDateTimeTimestampTable(); // insert new DateTest object to db DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType(); dateTimeTimestamp.setDateValue(new Date()); dateTimeTimestamp.setTimeValue(new Date()); GregorianCalendar calendar = new GregorianCalendar(2010, 1, 23); calendar.set(GregorianCalendar.MILLISECOND, 123); dateTimeTimestamp.setTimestampValue(calendar.getTime()); dateTimeTimestamp.save(); // execute matching select Criteria criteria = new Criteria(); calendar = new GregorianCalendar(2010, 1, 23); calendar.set(GregorianCalendar.MILLISECOND, 124); criteria.where(DateTimeTimestampTypePeer.TIMESTAMP_VALUE, calendar.getTime()); List<DateTimeTimestampType> result = DateTimeTimestampTypePeer.doSelect(criteria); // verify assertEquals(0, result.size()); }
From source file:TimePeriod.java
/** * Setzt die Uhr des bergebenen Kalenders auf 00:00:00:000 * /*w w w. j a va2 s .co m*/ * @param cal */ public void setMidnight(GregorianCalendar cal) { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); }
From source file:TimePeriod.java
/** * Setzt die Uhr des bergebenen Kalenders auf 23:59:59:999 * // w w w .j a v a2 s. co m * @param cal */ public void set2359(GregorianCalendar cal) { cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); }
From source file:ru.apertum.qsystem.client.forms.FBreaksChangeDialog.java
@Action public void addBreak() { final GregorianCalendar gc = new GregorianCalendar(2015, 1, 1, Integer.parseInt(cbSH.getSelectedItem().toString()), Integer.parseInt(cbSM.getSelectedItem().toString())); final Date d1 = gc.getTime(); gc.set(GregorianCalendar.HOUR_OF_DAY, Integer.parseInt(cbFH.getSelectedItem().toString())); gc.set(GregorianCalendar.MINUTE, Integer.parseInt(cbFM.getSelectedItem().toString())); if (d1.before(gc.getTime())) { breaks = (QBreak[]) ArrayUtils.add(breaks, new QBreak(d1, gc.getTime(), breaksParent)); loadBreaks(breaks);/*from ww w .j a v a2 s . c o m*/ } else { JOptionPane.showConfirmDialog(this, getLocaleMessage("add_break_dialog.err1.message"), getLocaleMessage("add_break_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } }
From source file:es.tid.fiware.rss.controller.SettlementController.java
/** * Do settlement./* w w w . j a v a 2 s. c o m*/ * * @param dateFrom * @param dateTo * @param aggregatorId * @param model * @return the model and view */ @RequestMapping(value = "/doSettlement", headers = "Accept=*/*", produces = "application/json") @ResponseBody public JsonResponse doSettlement(@QueryParam("dateFrom") String dateFrom, @QueryParam("dateTo") String dateTo, @QueryParam("aggregatorId") String aggregatorId, @QueryParam("providerId") String providerId, ModelMap model) { try { logger.debug("doSettlement - Provider: {} , aggregator: {}", providerId, aggregatorId); logger.debug("doSettlement - Start: Init" + dateFrom + ",End:" + dateTo); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat getDate = new SimpleDateFormat("MM/yyyy"); String initDate = ""; String endDate = ""; if (dateFrom != null && !"".equalsIgnoreCase(dateFrom) && dateTo != null && !"".equalsIgnoreCase(dateTo)) { Date from = getDate.parse(dateFrom); Date to = getDate.parse(dateTo); initDate = format.format(from); endDate = format.format(to); } else { // By default use the current month GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(); cal.setTime(new Date()); cal.set(Calendar.DAY_OF_MONTH, 1); initDate = format.format(cal.getTime()); cal.add(Calendar.MONTH, 1); endDate = format.format(cal.getTime()); } // Calculate settlement. settlementManager.runSettlement(initDate, endDate, aggregatorId, providerId); JsonResponse response = new JsonResponse(); response.setMessage("Settlement proccess launched correctly."); response.setSuccess(true); return response; } catch (Exception e) { logger.error(e.getMessage(), e); JsonResponse response = new JsonResponse(); response.setMessage(e.getMessage()); response.setSuccess(false); return response; } }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * Method called to convert a date field of the format of YYYYMMDD to a * GregorianCalendar object.// w w w.j a v a 2 s . co m * * @param datestr * the date to be converted, must be in YYYYMMDD format. * @return GregorianCalendar object created based on the date field. */ public static GregorianCalendar convertStringToGregorian(String datestr) { GregorianCalendar anotherDt = new GregorianCalendar(); try { anotherDt.set(Calendar.DAY_OF_MONTH, getDateElement(datestr, DateTimeConstants.DAY)); anotherDt.set(Calendar.MONTH, DateTimeUtil.getDateElement(datestr, DateTimeConstants.MONTH)); anotherDt.set(Calendar.YEAR, DateTimeUtil.getDateElement(datestr, DateTimeConstants.YEAR)); } catch (NumberFormatException e) { logger.error("encounting error while convert string to Gregorian date.", e); } return anotherDt; }
From source file:com.projity.options.CalendarOption.java
public long makeValidStart(long start, boolean force) { start = DateTime.minuteFloor(start); GregorianCalendar cal = DateTime.calendarInstance(); cal.setTimeInMillis(start);//from w w w . j a v a2 s . c o m int year = cal.get(GregorianCalendar.YEAR); int dayOfYear = cal.get(GregorianCalendar.DAY_OF_YEAR); if (force || cal.get(GregorianCalendar.HOUR_OF_DAY) == 0 && cal.get(GregorianCalendar.MINUTE) == 0) { cal.set(GregorianCalendar.HOUR_OF_DAY, getDefaultStartTime().get(GregorianCalendar.HOUR_OF_DAY)); cal.set(GregorianCalendar.MINUTE, getDefaultStartTime().get(GregorianCalendar.MINUTE)); cal.set(GregorianCalendar.YEAR, year); cal.set(GregorianCalendar.DAY_OF_YEAR, dayOfYear); } return cal.getTimeInMillis(); }
From source file:org.hyperic.hq.ui.action.resource.common.monitor.alerts.PortalAction.java
public ActionForward listAlerts(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { setResource(request, response);/*from w ww . j a v a2s. co m*/ super.setNavMapLocation(request, mapping, Constants.ALERT_LOC); // clean out the return path SessionUtils.resetReturnPath(request.getSession()); // set the return path try { setReturnPath(request, mapping); } catch (ParameterNotFoundException pne) { log.debug(pne); } GregorianCalendar cal = new GregorianCalendar(); try { Integer year = RequestUtils.getIntParameter(request, "year"); Integer month = RequestUtils.getIntParameter(request, "month"); Integer day = RequestUtils.getIntParameter(request, "day"); cal.set(Calendar.YEAR, year.intValue()); cal.set(Calendar.MONTH, month.intValue()); cal.set(Calendar.DAY_OF_MONTH, day.intValue()); request.setAttribute("date", new Long(cal.getTimeInMillis())); } catch (ParameterNotFoundException e) { request.setAttribute("date", new Long(System.currentTimeMillis())); } cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); Portal portal = Portal.createPortal(); AppdefEntityID aeid = RequestUtils.getEntityId(request); boolean canTakeAction = false; try { int sessionId = RequestUtils.getSessionId(request).intValue(); AuthzSubject subject = authzBoss.getCurrentSubject(sessionId); // ...check that the user can fix/acknowledge... alertPermissionManager.canFixAcknowledgeAlerts(subject, aeid); canTakeAction = true; } catch (PermissionException e) { // ...the user can't fix/acknowledge... } request.setAttribute(Constants.CAN_TAKE_ACTION_ON_ALERT_ATTR, canTakeAction); setTitle(aeid, portal, "alerts.alert.platform.AlertList.Title"); portal.setDialog(false); if (aeid.isGroup()) { portal.addPortlet(new Portlet(".events.group.alert.list"), 1); // Set the total alerts int sessionId = RequestUtils.getSessionId(request).intValue(); request.setAttribute("listSize", new Integer(galertBoss.countAlertLogs(sessionId, aeid.getId(), cal.getTimeInMillis(), cal.getTimeInMillis() + Constants.DAYS))); } else { portal.addPortlet(new Portlet(".events.alert.list"), 1); } request.setAttribute(Constants.PORTAL_KEY, portal); return null; }
From source file:org.apache.tika.parser.exiftool.ExifToolImageParserTest.java
public void testJPEGIPTC() throws Exception { Metadata metadata = new Metadata(); metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); InputStream stream = getClass().getResourceAsStream("/test-documents/testJPEG_IPTC_EXT.jpg"); parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); assertEquals("Washington", metadata.get(IPTC.CITY)); assertEquals("United States", metadata.get(IPTC.COUNTRY)); assertEquals("US", metadata.get(IPTC.COUNTRY_CODE)); assertEquals(/* w w w . ja v a 2s . co m*/ "A stream bank in Rock Creek Park Washington DC during a photo bike tour with ASPP DC/South chapter.", metadata.get(IPTC.DESCRIPTION)); assertEquals( "A stream bank in Rock Creek Park Washington DC during a photo bike tour with ASPP DC/South chapter.", metadata.get(Metadata.DESCRIPTION)); assertEquals("Rock Creek Park", metadata.get(IPTC.HEADLINE)); assertEquals("Downstream", metadata.get(Metadata.TITLE)); assertEquals("intellectual genre", metadata.get(IPTC.INTELLECTUAL_GENRE)); List<String> iptcKeywords = Arrays.asList(metadata.getValues(IPTC.KEYWORDS)); assertTrue(iptcKeywords.contains("stream")); assertTrue(iptcKeywords.contains("park")); assertTrue(iptcKeywords.contains("bank")); assertEquals(5, iptcKeywords.size()); List<String> tikaKeywords = Arrays.asList(metadata.getValues(Metadata.KEYWORDS)); assertTrue(Arrays.toString(tikaKeywords.toArray()).contains("stream")); assertTrue(Arrays.toString(tikaKeywords.toArray()).contains("park")); assertTrue(Arrays.toString(tikaKeywords.toArray()).contains("bank")); assertEquals(5, tikaKeywords.size()); assertEquals("DC", metadata.get(IPTC.PROVINCE_OR_STATE)); List<String> iptcSceneCode = Arrays.asList(metadata.getValues(IPTC.SCENE_CODE)); assertEquals(2, iptcSceneCode.size()); assertTrue(Arrays.toString(iptcSceneCode.toArray()).contains("iptc scene 1")); assertTrue(Arrays.toString(iptcSceneCode.toArray()).contains("iptc scene 2")); List<String> iptcSubjectCode = Arrays.asList(metadata.getValues(IPTC.SUBJECT_CODE)); assertEquals(2, iptcSubjectCode.size()); assertTrue(Arrays.toString(iptcSubjectCode.toArray()).contains("iptc subject code 1")); assertTrue(Arrays.toString(iptcSubjectCode.toArray()).contains("iptc subject code 2")); assertEquals("Rock Creek Park", metadata.get(IPTC.SUBLOCATION)); GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 2011); calendar.set(Calendar.MONTH, 7); calendar.set(Calendar.DATE, 31); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); assertEquals(calendar.getTime(), metadata.getDate(IPTC.DATE_CREATED)); assertEquals("Ray Gauss II", metadata.get(IPTC.DESCRIPTION_WRITER)); assertEquals("instructions", metadata.get(IPTC.INSTRUCTIONS)); assertEquals("job identifier", metadata.get(IPTC.JOB_ID)); assertEquals("Downstream", metadata.get(IPTC.TITLE)); assertTrue(metadata.get(IPTC.COPYRIGHT_NOTICE).contains("Ray Gauss II")); List<String> creators = Arrays.asList(metadata.getValues(IPTC.CREATOR)); assertTrue(Arrays.toString(creators.toArray()).contains("Ray Gauss II")); assertEquals("DAM Architect", metadata.get(IPTC.CREATORS_JOB_TITLE)); assertEquals("provider", metadata.get(IPTC.CREDIT_LINE)); assertEquals("rights usage terms", metadata.get(IPTC.RIGHTS_USAGE_TERMS)); assertEquals("source", metadata.get(IPTC.SOURCE)); assertEquals("1234 Some Road", metadata.get(IPTC.CONTACT_INFO_ADDRESS)); assertEquals("Atlanta", metadata.get(IPTC.CONTACT_INFO_CITY)); assertEquals("US", metadata.get(IPTC.CONTACT_INFO_COUNTRY)); List<String> ciWorkEmails = Arrays.asList(metadata.getValues(IPTC.CONTACT_INFO_EMAIL)); // Photoshop does not support true multi-value here assertTrue(Arrays.toString(ciWorkEmails.toArray()).contains("info@alfresco.com")); assertTrue(Arrays.toString(ciWorkEmails.toArray()).contains("other@example.com")); List<String> ciWorkTels = Arrays.asList(metadata.getValues(IPTC.CONTACT_INFO_PHONE)); // Photoshop does not support true multi-value here assertTrue(Arrays.toString(ciWorkTels.toArray()).contains("555-1234")); assertTrue(Arrays.toString(ciWorkTels.toArray()).contains("555-4321")); assertEquals("30339", metadata.get(IPTC.CONTACT_INFO_POSTAL_CODE)); assertEquals("GA", metadata.get(IPTC.CONTACT_INFO_STATE_PROVINCE)); List<String> ciWorkUrls = Arrays.asList(metadata.getValues(IPTC.CONTACT_INFO_WEB_URL)); // Photoshop does not support true multi-value here assertTrue(Arrays.toString(ciWorkUrls.toArray()).contains("http://alfresco.com")); assertTrue(Arrays.toString(ciWorkUrls.toArray()).contains("http://example.com")); assertEquals("rocky 1 and rocky 2 are big", metadata.get(IPTC.ADDITIONAL_MODEL_INFO)); List<String> orgCodes = Arrays.asList(metadata.getValues(IPTC.ORGANISATION_CODE)); assertEquals(2, orgCodes.size()); assertEquals("ASPP", orgCodes.get(0)); assertEquals("OTHER_ORG", orgCodes.get(1)); // List<String> cvTerms = Arrays.asList(metadata.getValues(IPTC.CONTROLLED_VOCABULARY_TERM)); List<String> modelAges = Arrays.asList(metadata.getValues(IPTC.MODEL_AGE)); assertEquals(2, modelAges.size()); assertEquals("1000", modelAges.get(0)); assertEquals("1001", modelAges.get(1)); List<String> orgNames = Arrays.asList(metadata.getValues(IPTC.ORGANISATION_NAME)); assertEquals(2, orgNames.size()); assertEquals("ASPP", orgNames.get(0)); assertEquals("Other Org", orgNames.get(1)); List<String> peopleShown = Arrays.asList(metadata.getValues(IPTC.PERSON)); assertEquals(2, peopleShown.size()); assertEquals("rocky 1", peopleShown.get(0)); assertEquals("rocky 2", peopleShown.get(1)); assertEquals("http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture", metadata.get(IPTC.DIGITAL_SOURCE_TYPE)); assertEquals("Photo Bike Tour", metadata.get(IPTC.EVENT)); assertEquals("RGAUSS", metadata.get(IPTC.IMAGE_SUPPLIER_ID)); assertEquals("Ray Gauss II", metadata.get(IPTC.IMAGE_SUPPLIER_NAME)); assertEquals("supplier image ID", metadata.get(IPTC.IMAGE_SUPPLIER_IMAGE_ID)); assertEquals("3456", metadata.get(IPTC.MAX_AVAIL_HEIGHT)); assertEquals("5184", metadata.get(IPTC.MAX_AVAIL_WIDTH)); assertEquals("1.2.0", metadata.get(IPTC.PLUS_VERSION)); List<String> copyrightOwnerIds = Arrays.asList(metadata.getValues(IPTC.COPYRIGHT_OWNER_ID)); assertEquals(1, copyrightOwnerIds.size()); assertEquals("RGAUSS", copyrightOwnerIds.get(0)); // assertEquals("", copyrightOwnerIds.get(1)); // TODO: Get ExifTool to preserve empty values List<String> copyrightOwnerNames = Arrays.asList(metadata.getValues(IPTC.COPYRIGHT_OWNER_NAME)); assertEquals(2, copyrightOwnerNames.size()); assertEquals("Ray Gauss II", copyrightOwnerNames.get(0)); assertEquals("GG", copyrightOwnerNames.get(1)); List<String> imageCreatorIds = Arrays.asList(metadata.getValues(IPTC.IMAGE_CREATOR_ID)); assertEquals(1, imageCreatorIds.size()); assertEquals("RGAUSS", imageCreatorIds.get(0)); // assertEquals("", imageCreatorIds.get(1)); // TODO: Get ExifTool to preserve empty values assertTrue(metadata.isMultiValued(IPTC.IMAGE_CREATOR_NAME)); List<String> imageCreatorNames = Arrays.asList(metadata.getValues(IPTC.IMAGE_CREATOR_NAME)); assertEquals(2, imageCreatorNames.size()); assertEquals("Ray Gauss II", imageCreatorNames.get(0)); assertEquals("GG", imageCreatorNames.get(1)); List<String> licensorIds = Arrays.asList(metadata.getValues(IPTC.LICENSOR_ID)); assertEquals("RGAUSS", licensorIds.get(0)); assertTrue(metadata.isMultiValued(IPTC.LICENSOR_NAME)); List<String> licensorNames = Arrays.asList(metadata.getValues(IPTC.LICENSOR_NAME)); assertEquals(2, licensorNames.size()); assertEquals("Ray Gauss II", licensorNames.get(0)); assertEquals("GG", licensorNames.get(1)); // Photoshop does not support licensor addresses, cities, or countries List<String> licensorEmails = Arrays.asList(metadata.getValues(IPTC.LICENSOR_EMAIL)); assertEquals("r@example.com", licensorEmails.get(0)); // assertEquals("", licensorEmails.get(1)); // TODO: Get ExifTool to preserve empty values List<String> licensorTel1 = Arrays.asList(metadata.getValues(IPTC.LICENSOR_TELEPHONE_1)); assertEquals("555-5555", licensorTel1.get(0)); // assertEquals("", licensorTel1.get(1)); // TODO: Get ExifTool to preserve empty values List<String> licensorTel2 = Arrays.asList(metadata.getValues(IPTC.LICENSOR_TELEPHONE_2)); assertEquals("555-4444", licensorTel2.get(0)); // assertEquals("", licensorTel2.get(1)); // TODO: Get ExifTool to preserve empty values List<String> licensorUrls = Arrays.asList(metadata.getValues(IPTC.LICENSOR_URL)); assertEquals("http://rgauss.com", licensorUrls.get(0)); // assertEquals("", licensorUrls.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("Age Unknown", metadata.get(IPTC.MINOR_MODEL_AGE_DISCLOSURE)); List<String> modelReleaseIds = Arrays.asList(metadata.getValues(IPTC.MODEL_RELEASE_ID)); assertEquals("model release id 1", modelReleaseIds.get(0)); assertEquals("model release id 2", modelReleaseIds.get(1)); assertEquals("Not Applicable", metadata.get(IPTC.MODEL_RELEASE_STATUS)); List<String> propertyReleaseIds = Arrays.asList(metadata.getValues(IPTC.PROPERTY_RELEASE_ID)); assertEquals("prop release id 1", propertyReleaseIds.get(0)); assertEquals("prop release id 2", propertyReleaseIds.get(1)); assertEquals("Not Applicable", metadata.get(IPTC.PROPERTY_RELEASE_STATUS)); List<String> aoCopyright = Arrays .asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_COPYRIGHT_NOTICE)); assertEquals("Ray Gauss II", aoCopyright.get(0)); // assertEquals("", aoCopyright.get(1)); // TODO: Get ExifTool to preserve empty values // assertEquals("", aoCopyright.get(2)); // TODO: Get ExifTool to preserve empty values List<String> aoCreator = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_CREATOR)); assertEquals("Mother Nature", aoCreator.get(0)); assertEquals("Man", aoCreator.get(1)); assertEquals("Mother Nature", aoCreator.get(2)); List<String> aoDateCreated = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_DATE_CREATED)); assertEquals("1890:01:01", aoDateCreated.get(0)); // assertEquals("", aoDateCreated.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("1901:02:01", aoDateCreated.get(1)); // assertEquals("", aoDateCreated.get(2)); // TODO: Get ExifTool to preserve empty values List<String> aoSource = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_SOURCE)); assertEquals("National Park Service", aoSource.get(0)); // assertEquals("", aoSource.get(1)); // TODO: Get ExifTool to preserve empty values // assertEquals("", aoSource.get(2)); // TODO: Get ExifTool to preserve empty values List<String> aoSourceInventoryNum = Arrays .asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_SOURCE_INVENTORY_NUMBER)); assertEquals("123456", aoSourceInventoryNum.get(0)); // assertEquals("", aoSourceInventoryNum.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("654321", aoSourceInventoryNum.get(1)); // This should be index 2, TODO: Get ExifTool to preserve empty values List<String> aoSourceTitles = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_TITLE)); assertEquals("Rock Creek Stream Bank", aoSourceTitles.get(0)); assertEquals("Pollution", aoSourceTitles.get(1)); assertEquals("Some Tree", aoSourceTitles.get(2)); List<String> locationShownCity = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_CITY)); assertEquals("Washington", locationShownCity.get(0)); // assertEquals("", locationShownCity.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownCountryCode = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_COUNTRY_CODE)); assertEquals("US", locationShownCountryCode.get(0)); // assertEquals("", locationShownCountryCode.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownCountryName = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_COUNTRY_NAME)); assertEquals("United States", locationShownCountryName.get(0)); // assertEquals("", locationShownCountryName.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownState = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_PROVINCE_OR_STATE)); assertEquals("D.C.", locationShownState.get(0)); // assertEquals("", locationShownState.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownSublocation = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_SUBLOCATION)); assertEquals("Rock Creek Park Sub", locationShownSublocation.get(0)); assertEquals("Stream Section", locationShownSublocation.get(1)); List<String> locationShownWorldRegion = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_WORLD_REGION)); assertEquals("North America", locationShownWorldRegion.get(0)); // assertEquals("", locationShownWorldRegion.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("Washington", metadata.get(IPTC.LOCATION_CREATED_CITY)); assertEquals("US", metadata.get(IPTC.LOCATION_CREATED_COUNTRY_CODE)); assertEquals("United States", metadata.get(IPTC.LOCATION_CREATED_COUNTRY_NAME)); assertEquals("D.C.", metadata.get(IPTC.LOCATION_CREATED_PROVINCE_OR_STATE)); assertEquals("Rock Creek Park", metadata.get(IPTC.LOCATION_CREATED_SUBLOCATION)); assertEquals("North America", metadata.get(IPTC.LOCATION_CREATED_WORLD_REGION)); assertTrue(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID.isMultiValuePermitted()); assertTrue(metadata.isMultiValued(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID)); List<String> registryEntryOrgIds = Arrays .asList(metadata.getValues(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID)); assertEquals(2, registryEntryOrgIds.size()); assertEquals("PLUS", registryEntryOrgIds.get(0)); // assertEquals("", registryEntryOrgIds.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("ORG 2", registryEntryOrgIds.get(1)); // This should be index 2, TODO: Get ExifTool to preserve empty values assertTrue(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID.isMultiValuePermitted()); assertTrue(metadata.isMultiValued(IPTC.REGISTRY_ENTRY_CREATED_ITEM_ID)); List<String> registryEntryItemIds = Arrays.asList(metadata.getValues(IPTC.REGISTRY_ENTRY_CREATED_ITEM_ID)); assertEquals(registryEntryItemIds.size(), 3); assertEquals("100-ABC-ABC-555", registryEntryItemIds.get(0)); assertEquals("11223344", registryEntryItemIds.get(1)); assertEquals("55667788", registryEntryItemIds.get(2)); }