Uploaded image for project: 'Sesame'
  1. SES-2049

Literal gyear with value 1 calendarValue bugs

    Details

    • Sprint:

      Description

      The following test currently fails.

      @Test
      public void testGYear1()
      	throws Exception
      {
      	assertEquals(new LiteralImpl("1", XMLSchema.GYEAR).calendarValue().getYear(), 1);
      }
      

      This can be fixed in the LiteralImpl class using the following workarround.

      public XMLGregorianCalendar calendarValue() {
      	if (XMLSchema.GYEAR.equals(datatype)) {
      		return XMLDatatypeUtil.parseGYear(getLabel());
      	} else {
      		return XMLDatatypeUtil.parseCalendar(getLabel());
      	}
      }
      

      And then adding the following method in the XMLDatatypeUtil

      /**
       * Parses the supplied gyear value string and returns its value.
       * This is a work around for gyears 1
       * @param s
       *        A string representation of an xsd:gYear value.
       * @return The calendar value represented by the supplied string argument.
       * @throws NumberFormatException
       *         If the supplied string is not a valid calendar value.
       */
      public static XMLGregorianCalendar parseGYear(String s) {
      	final XMLGregorianCalendar newXMLGregorianCalendar = dtFactory.newXMLGregorianCalendar();
      	newXMLGregorianCalendar.setYear(Integer.parseInt(s));
      	return newXMLGregorianCalendar;
      }
      

        Attachments

          Activity

            People

            • Assignee:
              jeenbroekstra Jeen Broekstra
              Reporter:
              jervenbolleman Jerven Bolleman
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Who's Looking?