text:
module m_cmlw

  use flib_wxml
  use m_stmw

  private

  integer, private, parameter ::  sp = selected_real_kind(6,30)
  integer, private, parameter ::  dp = selected_real_kind(14,100)

! CMLUnits
  character(len=40), parameter :: U_ANGSTR = 'units:angstrom'
  character(len=40), parameter :: U_PMETER = 'units:pm'
  character(len=40), parameter :: U_DEGREE = 'units:degree'
  character(len=40), parameter :: U_RADIAN = 'units:radian'
  character(len=40), parameter :: U_INVCM  = 'units:cm-1'
  character(len=40), parameter :: U_KCALMO = 'units:kcal-mole'
  character(len=40), parameter :: U_EVOLT  = 'units:ev'
  character(len=40), parameter :: U_SECOND = 'units:second'
  character(len=40), parameter :: U_VOLT   = 'units:volt'

! CMLCore
  PUBLIC :: cmlAddCoordinates
  PUBLIC :: cmlAddCrystal
  PUBLIC :: cmlAddAngle
  PUBLIC :: cmlAddLength
  PUBLIC :: cmlAddEigenvalue
  PUBLIC :: cmlAddProperty
  PUBLIC :: cmlAddPropertyList
  PUBLIC :: cmlAddMolecule
  PUBLIC :: cmlAddMetadata

! CMLComp
  PUBLIC :: cmlAddLattice
  PUBLIC :: cmlAddLatticeVector
  PUBLIC :: cmlAddParameter

! CMLCore
  INTERFACE cmlAddCoordinates
     MODULE PROCEDURE cmlAddCoordinatesSP, cmlAddCoordinatesDP
  END INTERFACE

  INTERFACE cmlAddCrystal
     MODULE PROCEDURE cmlAddCrystalSP, cmlAddCrystalDP
  END INTERFACE

  INTERFACE cmlAddAngle
     MODULE PROCEDURE cmlAddAngleSP, cmlAddAngleDP
  END INTERFACE

  INTERFACE cmlAddLength
     MODULE PROCEDURE cmlAddLengthSP, cmlAddLengthDP
  END INTERFACE

  INTERFACE cmlAddEigenvalue
     MODULE PROCEDURE cmlAddEigenvalueSP, cmlAddEigenvalueDP
  END INTERFACE

  INTERFACE cmlAddMolecule
     MODULE PROCEDURE cmlAddMoleculeSP, cmlAddMoleculeDP, cmlAddMolecule3SP, &
                      cmlAddMolecule3DP
  END INTERFACE

! CMLComa
  INTERFACE cmlAddLattice
     MODULE PROCEDURE cmlAddLatticeSP, cmlAddLatticeDP
  END INTERFACE

  INTERFACE cmlAddLatticeVector
     MODULE PROCEDURE cmlAddLatticeVectorSP, cmlAddLatticeVectorDP
  END INTERFACE

  INTERFACE cmlAddProperty
     MODULE PROCEDURE &
          cmlAddPropScalarDP, cmlAddPropScalarSP, cmlAddPropScalarI, &
          cmlAddPropMatrixDP, cmlAddPropMatrixSP, cmlAddPropMatrixI, &
          cmlAddPropArrayDP,  cmlAddPropArraySP,  cmlAddPropArrayI
  END INTERFACE

  INTERFACE cmlAddParameter
     MODULE PROCEDURE &
        cmlAddParameterCH, cmlAddParameterI, &
        cmlAddParameterSP, cmlAddParameterDP, &
        cmlAddParameterLG
  END INTERFACE

CONTAINS

  ! =================================================
  ! convenience CML routines
  ! =================================================

  ! -------------------------------------------------
  ! writes a propertyList start Tag to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropertyList(xf, id, title, conv, dictref, ref, role)

    implicit none
    type(xmlf_t) :: xf
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: role

    call xml_NewElement(xf, 'propertyList')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    if (present(role)) call xml_AddAttribute(xf, 'role', role)

  END SUBROUTINE cmlAddPropertyList

  ! -------------------------------------------------
  ! 1. writes a DP property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropScalarDP(xf, property, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)               :: property
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id))      call xml_AddAttribute(xf, 'id', id)
    if (present(title))   call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv))    call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref))    call xml_AddAttribute(xf, 'ref', ref)
    call stmAddScalar(xf=xf, value=property, units=units, fmt=fmt)
    call xml_EndElement(xf, 'property')

  END SUBROUTINE cmlAddPropScalarDP

  ! -------------------------------------------------
  ! 2. writes a Scalar SP property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropScalarSP(xf, property, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in) :: property
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddScalar(xf=xf, value=property, units=units, fmt=fmt)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropScalarSP

  ! -------------------------------------------------
  ! 3. writes a Scalar integer property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropScalarI(xf, property, id, title, conv, dictref, ref, units)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in) :: property
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddScalar(xf=xf, value=property, units=units)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropScalarI

  ! -------------------------------------------------
  ! 4. writes an Float matrix property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropMatrixDP(xf, property, nrows, ncols, dim, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)      :: nrows
    integer, intent(in)      :: ncols
    integer, intent(in)      :: dim
    real(kind=dp), intent(in) :: property(nrows,ncols)
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddMatrix(xf=xf, matrix=property, dim=dim, ncols=ncols, nrows=nrows, units=units, fmt=fmt)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropMatrixDP

  ! -------------------------------------------------
  ! 5. writes an SP Float matrix property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropMatrixSP(xf, property, nrows, ncols, dim, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)      :: nrows
    integer, intent(in)      :: ncols
    integer, intent(in)      :: dim
    real(kind=sp), intent(in) :: property(nrows,ncols)
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddMatrix(xf=xf,matrix=property, dim=dim, ncols=ncols, nrows=nrows, units=units, fmt=fmt)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropMatrixSP

  ! -------------------------------------------------
  ! 6. writes an Integer matrix property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropMatrixI(xf, property, nrows, ncols, dim, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf

    integer, intent(in)                    :: nrows
    integer, intent(in)                    :: ncols
    integer, intent(in), optional          :: dim
    integer, intent(in)                    :: property(nrows,ncols)
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(conv)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddMatrix(xf=xf, matrix=property, dim=dim, ncols=ncols, nrows=nrows, units=units)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropMatrixI

  ! -------------------------------------------------
  ! 7. writes an Array DP property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropArrayDP(xf, property, nvalue, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)               :: property(*)
    integer, intent(in)                    :: nvalue
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddArray(xf=xf, array=property, nvalue=nvalue, units=units, fmt=fmt)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropArrayDP

  ! -------------------------------------------------
  ! 8. writes an Array SP property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropArraySP(xf, property, nvalue, id, title, conv, dictref, ref, units, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)               :: property(*)
    integer, intent(in)                    :: nvalue
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddArray(xf=xf, array=property, nvalue=nvalue, units=units, fmt=fmt)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropArraySP

  ! -------------------------------------------------
  ! 9. writes an Array integer property to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddPropArrayI(xf, property, nvalue, id, title, conv, dictref, ref, units)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)                    :: property(*)
    integer, intent(in)                    :: nvalue
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: ref
    character(len=*), intent(in), optional :: units

    call xml_NewElement(xf, 'property')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    call stmAddArray(xf, array=property, nvalue=nvalue, units=units)
    call xml_EndElement(xf, 'property')
  END SUBROUTINE cmlAddPropArrayI

  !------------------------------------------------------------
  ! END OF PROPERTIES
  !------------------------------------------------------------

  ! -------------------------------------------------
  ! 1. writes complete DP molecule to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddMoleculeDP(xf, natoms, elements, coords, style, id, title, dictref, fmt)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)                    :: natoms             ! number of atoms
    real(kind=dp), intent(in)               :: coords(3, natoms)  ! atomic coordinates
    character(len=*), intent(in)           :: elements(natoms)   ! chemical element types
    character(len=*), intent(in), optional :: id                 ! id
    character(len=*), intent(in), optional :: title              ! the title
    character(len=*), intent(in), optional :: dictref            ! the dictionary reference
    character(len=*), intent(in), optional :: fmt                ! format for coords
    character(len=*), intent(in), optional :: style              ! type of coordinates

    ! 'x3' for Cartesians,
    ! 'xFrac' for fractionals
    ! default => cartesians

    ! Internal Variables
    character(len=6) :: id1, id0
    character(len=10):: formt, stylei
    integer          :: i

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(style)) then
       stylei = style
    else
       stylei = 'x3'
    endif

    call stmAddStartTag(xf, 'molecule', id, title, dictref)
    call xml_NewElement(xf, 'atomArray')
    do i = 1, natoms
       write(id0, '(i4)') i
       id0 = adjustl(id0)
       id1 = 'a'
       id1(2:) = id0
       call cmlAddAtom(xf=xf, elem=elements(i), id=id1)
       if (stylei .eq. 'x3') then
          call CMLATX39DP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       elseif (stylei .eq. 'xFrac') then
          call CMLATXF9DP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       elseif (stylei .eq. 'xyz3') then
          call CMLATXYZ39DP(xf, coords(1, i), coords (2, i), coords(3, i), formt)
       elseif (stylei .eq. 'xyzFrac') then
          call CMLATXYZFRACT9DP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       endif
       call xml_EndElement(xf, 'atom')
    enddo

    call xml_EndElement(xf, 'atomArray')
    call xml_EndElement(xf, 'molecule')

  END SUBROUTINE cmlAddMoleculeDP

  ! -------------------------------------------------
  ! 2. writes complete SP molecule to xml channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddMoleculeSP(xf, natoms, elements, coords, style, id, title, dictref, fmt)
    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)                    :: natoms          ! number of atoms
    character(len=*), intent(in)           :: elements(*)     ! chemical element types
    real(kind=sp), intent(in)               :: coords(3, *)    ! atomic coordinates
    character(len=*), intent(in), optional :: id              ! id
    character(len=*), intent(in), optional :: title           ! the title
    character(len=*), intent(in), optional :: dictref         ! the dictionary reference
    character(len=*), intent(in), optional :: fmt             ! format for coords
    character(len=*), intent(in), optional :: style           ! type of coordinates ('x3'for Cartesians, 'xFrac'
    ! for fractionals; ' ' = default => cartesians)
    ! Flush on entry and exit
    character(len=6) :: id1, id0
    integer          :: i
    character(len=10):: formt, stylei

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(style)) then
       stylei = style
    else
       stylei = 'x3'
    endif

    call stmAddStartTag(xf, 'molecule', id, title, dictref)
    call xml_NewElement(xf, 'atomArray')
    do i = 1, natoms
       write(id0, '(i4)') i
       id0 = adjustl(id0)
       id1 = 'a'
       id1(2:) = id0
       call cmlAddAtom(xf=xf, elem=elements(i), id=id1)
       if (stylei .eq. 'x3') then
          call CMLATX39SP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       elseif (stylei .eq. 'xFrac') then
          call CMLATXF9SP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       elseif (stylei .eq. 'xyz3') then
          call CMLATXYZ39SP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       elseif (stylei .eq. 'xyzFrac') then
          call CMLATXYZFRACT9SP(xf, coords(1, i), coords(2, i), coords(3, i), formt)
       endif
       call xml_EndElement(xf, 'atom')
    enddo

    call xml_EndElement(xf, 'atomArray')
    call xml_EndElement(xf, 'molecule')

  END SUBROUTINE cmlAddMoleculeSP

  ! -------------------------------------------------
  ! 1. writes complete DP molecule to xml channel (No. 2)
  ! -------------------------------------------------

  SUBROUTINE cmlAddMolecule3DP(xf, natoms, elements, x, y, z, style, id, title, dictref, fmt)
    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)                    :: natoms          ! number of atoms
    real(kind=dp), intent(in)               :: x(*)
    real(kind=dp), intent(in)               :: y(*)
    real(kind=dp), intent(in)               :: z(*)
    character(len=*), intent(in)           :: elements(*)     ! chemical element types
    character(len=*), intent(in), optional :: id              ! id
    character(len=*), intent(in), optional :: title           ! the title
    character(len=*), intent(in), optional :: dictref         ! the dictionary reference
    character(len=*), intent(in), optional :: fmt             ! format for coords
    character(len=*), intent(in), optional :: style           ! type of coordinates ('x3'for Cartesians, 'xFrac'
    ! for fractionals; ' ' = default => cartesians)
    character(len=6)  :: id1, id0
    integer           :: i, l
    character(len=10) :: formt, stylei

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(style)) then
       stylei = trim(style)
    else
       stylei = 'x3'
    endif

    call stmAddStartTag(xf=xf, name='molecule', id=id, title=title, dictref=dictref)
    call xml_NewElement(xf, 'atomArray')

    do i = 1, natoms
       write(id0, '(i4)') i
       id0 = adjustl(id0)
       id1 = 'a'
       id1(2:) = id0
       call cmlAddAtom(xf=xf, elem=elements(i), id=id1)
       if (trim(stylei) .eq. 'x3') then
          call CMLATX39DP(xf, x(i), y(i), z(i), formt)
       elseif (stylei .eq. 'xFrac') then
          call CMLATXF9DP(xf, x(i), y(i), z(i), formt)
       elseif (stylei .eq. 'xyz3') then
          call CMLATXYZ39DP(xf, x(i), y(i), z(i), formt)
       elseif (stylei .eq. 'xyzFrac') then
          call CMLATXYZFRACT9DP(xf, x(i), y(i), z(i), formt)
       endif
       call xml_EndElement(xf, 'atom')
    enddo

    call xml_EndElement(xf, 'atomArray')
    call xml_EndElement(xf, 'molecule')

  END SUBROUTINE cmlAddMolecule3DP

  ! -------------------------------------------------
  ! 2. writes complete SP molecule to xml channel (No. 2)
  ! -------------------------------------------------

  SUBROUTINE cmlAddMolecule3SP(xf, natoms, elements, x, y, z, style, id, title, dictref, fmt)

    implicit none
    type(xmlf_t) :: xf
    ! 10 Arguments
    integer, intent(in)                    :: natoms          ! number of atoms
    real(kind=sp), intent(in)               :: x(*)
    real(kind=sp), intent(in)               :: y(*)
    real(kind=sp), intent(in)               :: z(*)
    character(len=*), intent(in)           :: elements(*)      ! chemical element types
    character(len=*), intent(in), optional :: id               ! id
    character(len=*), intent(in), optional :: title            ! the title
    character(len=*), intent(in), optional :: dictref          ! the dictionary reference
    character(len=*), intent(in), optional :: fmt              ! format for coords
    character(len=*), intent(in), optional :: style            ! type of coordinates ('x3' for Cartesians, 'xFrac'
    ! for fractionals; ' ' = default => cartesians)
    ! Internal variables
    character(len=6)  :: id1, id0
    integer           :: i, l
    character(len=10) :: formt, stylei

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(style)) then
       stylei = style
    else
       stylei = 'x3'
    endif

    call xml_NewElement(xf, 'molecule')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'title', title)
    call xml_AddAttribute(xf, 'dictref', dictref)
    call xml_NewElement(xf, 'atomArray')
    do i = 1, natoms
       write(id0, '(i4)') i
       id0 = adjustl(id0)
       id1 = 'a'
       id1(2:) = id0
       call cmlAddAtom(xf=xf, elem=elements(i), id=id1)
       if (stylei .eq. 'x3') then
          call CMLATX39SP(xf, x(i), y(i), z(i), formt)
       else if (stylei .eq. 'xFrac') then
          call CMLATXF9SP(xf, x(i), y(i), z(i), formt)
       else if (stylei .eq. 'xyz3') then
          call CMLATXYZ39SP(xf, x(i), y(i), z(i), formt)
       else if (stylei .eq. 'xyzFrac') then
          call CMLATXYZFRACT9SP(xf, x(i), y(i), z(i), formt)
       endif
           call xml_EndElement(xf, 'atom')
    enddo

    call xml_EndElement(xf, 'atomArray')
    call xml_EndElement(xf, 'molecule')

  END SUBROUTINE cmlAddMolecule3SP

  ! -------------------------------------------------
  ! writes an <atom> start tag
  ! -------------------------------------------------

  SUBROUTINE cmlAddAtom(xf, elem, id, charge, hCount, occupancy, fmt)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in), optional           :: charge     ! formalCharge
    integer, intent(in), optional           :: hCount     ! hydrogenCount
    real(kind=sp), intent(in), optional      :: occupancy  ! hydrogenCount
    character(len=*), intent(in), optional  :: elem       ! chemical element name
    character(len=*), intent(in), optional  :: id         ! atom id
    character(len=*), intent(in), optional  :: fmt        ! format

    ! internal Variable
    character(len=10):: formt
    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'atom')
    if (present(elem))      call xml_AddAttribute(xf, 'elementType', elem)
    if (present(id))        call xml_AddAttribute(xf, 'id', id)
    if (present(charge))    call xml_AddAttribute(xf, 'formalCharge', str(charge))
    if (present(hCount))    call xml_AddAttribute(xf, 'hydrogenCount', str(hCount))
    if (present(occupancy)) call xml_AddAttribute(xf, 'occupancy', str(occupancy,formt))

  END SUBROUTINE cmlAddAtom

  ! -------------------------------------------------
  ! 1. append SP coordinates to atom tag
  ! -------------------------------------------------

  SUBROUTINE cmlAddCoordinatesSP(xf, x, y, z, style, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)               :: x, y
    real(kind=sp), intent(in), optional     :: z
    character(len=*), intent(in), optional :: style
    character(len=*), intent(in), optional :: fmt

    ! Internal variable
    character(len=10):: formt
    character(len=10):: stylei
    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(style)) then
       stylei = style
    else
       stylei = 'x3'
    endif

    if (present(z) .and. stylei .eq. 'x3') then
       call CMLATX39SP(xf, x, y, z, formt)
    else if (present(z) .and. stylei .eq. 'xFrac') then
       call CMLATXF9SP(xf, x, y, z, formt)
    else if (present(z) .and. stylei .eq. 'xyz3') then
       call CMLATXYZ39SP(xf, x, y, z, formt)
    else if (present(z) .and. stylei .eq. 'xyzFrac') then
       call CMLATXYZFRACT9SP(xf, x, y, z, formt)
    elseif (.not. present(z) .and. stylei .eq. 'xy2') then
       call CMLATXY9SP(xf, x, y, formt)
    endif

  END SUBROUTINE cmlAddCoordinatesSP

  ! -------------------------------------------------
  ! 2. append DP coordinates to atom tag
  ! -------------------------------------------------

  SUBROUTINE cmlAddCoordinatesDP(xf, x, y, z, style, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)               :: x, y
    real(kind=dp), intent(in), optional     :: z
    character(len=*), intent(in), optional :: style
    character(len=*), intent(in), optional :: fmt

    ! Internal variable
    character(len=10):: formt
    character(len=10):: stylei
    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(style)) then
       stylei = style
    else
       stylei = 'x3'
    endif

    if (present(z) .and. stylei .eq. 'x3') then
       call CMLATX39DP(xf, x, y, z, formt)
    else if (present(z) .and. stylei .eq. 'xFrac') then
       call CMLATXF9DP(xf, x, y, z, formt)
    else if (present(z) .and. stylei .eq. 'xyz3') then
       call CMLATXYZ39DP(xf, x, y, z, formt)
    else if (present(z) .and. stylei .eq. 'xyzFrac') then
       call CMLATXYZFRACT9DP(xf, x, y, z, formt)
    else if (.not. present(z) .and. stylei .eq. 'xy2') then
       call CMLATXY9DP(xf, x, y, formt)
    endif

  END SUBROUTINE cmlAddCoordinatesDP

  ! -------------------------------------------------
  ! 1. writes a DP <length> element to output channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddLengthDP(xf, length, id, atomRef1, atomRef2, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)     :: length     ! length
    character(len=*), intent(in) :: id         ! length id
    character(len=*), intent(in) :: atomRef1   ! ref to first atom
    character(len=*), intent(in) :: atomRef2   ! ref to second atom
    character(len=*), intent(in) :: fmt        ! format

    optional         :: fmt
    character(len=10):: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call CMLLEN9DP(xf, id, atomRef1, atomRef2, length, formt)
  END SUBROUTINE cmlAddLengthDP

  ! -------------------------------------------------
  ! 2. writes a SP <length> element to output channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddLengthSP(xf, length, id, atomRef1, atomRef2, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)     :: length     ! the length
    character(len=*), intent(in) :: id         ! length id
    character(len=*), intent(in) :: atomRef1   ! ref to first atom
    character(len=*), intent(in) :: atomRef2   ! ref to second atom
    character(len=*), intent(in) :: fmt        ! format

    optional         :: fmt
    character(len=10):: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call CMLLEN9SP(xf, id, atomRef1, atomRef2, length, formt)
  END SUBROUTINE cmlAddLengthSP

  ! -------------------------------------------------
  ! 1. writes an DP <angle> element to output channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddAngleDP(xf, angle, id, atomRef1, atomRef2, atomRef3, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)     :: angle        ! the angle
    character(len=*), intent(in) :: id           ! angle id
    character(len=*), intent(in) :: atomRef1     ! ref to first atom
    character(len=*), intent(in) :: atomRef2     ! ref to second atom
    character(len=*), intent(in) :: atomRef3     ! ref to third atom
    character(len=*), intent(in) :: fmt          ! format

    optional         :: fmt
    character(len=10):: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call CMLANG9DP(xf, id, atomRef1, atomRef2, atomRef3, angle, formt)
  END SUBROUTINE cmlAddAngleDP

  ! -------------------------------------------------
  ! 2. writes an SP <angle> element to output channel
  ! -------------------------------------------------

  SUBROUTINE cmlAddAngleSP(xf, angle, id, atomRef1, atomRef2, atomRef3, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)     :: angle        ! the angle
    character(len=*), intent(in) :: id           ! angle id
    character(len=*), intent(in) :: atomRef1     ! ref to first atom
    character(len=*), intent(in) :: atomRef2     ! ref to second atom
    character(len=*), intent(in) :: atomRef3     ! ref to third atom
    character(len=*), intent(in) :: fmt          ! format

    optional         :: fmt
    character(len=10):: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call CMLANG9SP(xf, id, atomRef1, atomRef2, atomRef3, angle, formt)
  END SUBROUTINE cmlAddAngleSP

  ! -------------------------------------------------
  ! 1. creates and writes a DP <torsion> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddTorsionDP(xf, torsion, id, atomRef1, atomRef2, atomRef3, atomRef4, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)     :: torsion         ! the torsion
    character(len=*), intent(in) :: id              ! torsion id
    character(len=*), intent(in) :: atomRef1        ! ref to first atom
    character(len=*), intent(in) :: atomRef2        ! ref to second atom
    character(len=*), intent(in) :: atomRef3        ! ref to third atom
    character(len=*), intent(in) :: atomRef4        ! ref to fourth atom
    character(len=*), intent(in) :: fmt             ! format

    optional         :: fmt
    character(len=10):: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call CMLTOR9DP(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, formt)
  END SUBROUTINE cmlAddTorsionDP

  ! -------------------------------------------------
  ! 2. creates and writes a SP <torsion> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddTorsionSP(xf, torsion, id, atomRef1, atomRef2, atomRef3, atomRef4, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)     :: torsion         ! the torsion
    character(len=*), intent(in) :: id              ! torsion id
    character(len=*), intent(in) :: atomRef1        ! ref to first atom
    character(len=*), intent(in) :: atomRef2        ! ref to second atom
    character(len=*), intent(in) :: atomRef3        ! ref to third atom
    character(len=*), intent(in) :: atomRef4        ! ref to fourth atom
    character(len=*), intent(in) :: fmt             ! format

    optional         :: fmt
    character(len=10):: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call CMLTOR9SP(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, formt)
  END SUBROUTINE cmlAddTorsionSP

  ! -------------------------------------------------
  ! 1. creates and writes an SP Lattice element
  ! -------------------------------------------------

  SUBROUTINE cmlAddLatticeSP(xf, cell, units, title, id, dictref, conv, lattType, spaceType, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)               :: cell(3,3)
    character(len=*), intent(in), optional :: units
    character(len=*), intent(in), optional :: id           ! id
    character(len=*), intent(in), optional :: title        ! title
    character(len=*), intent(in), optional :: dictref      ! dictref
    character(len=*), intent(in), optional :: conv         ! format
    character(len=*), intent(in), optional :: lattType     !
    character(len=*), intent(in), optional :: spaceType    !
    character(len=*), intent(in), optional :: fmt

    ! Internal Variables
    integer           :: i
    character(len=10) :: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'lattice')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(lattType)) call xml_AddAttribute(xf, 'latticeType', lattType)
    if (present(spaceType)) call xml_AddAttribute(xf, 'spaceType', spaceType)

    do i = 1,3
       call xml_NewElement(xf, 'latticeVector')
       if (present(units)) call xml_AddAttribute(xf, 'units', units)
       call xml_AddAttribute(xf, 'dictRef', 'cml:latticeVector')
       call xml_AddPcdata(xf, str(cell(1,i), formt))
       call xml_AddPcdata(xf, str(cell(2,i), formt))
       call xml_AddPcdata(xf, str(cell(3,i), formt))
    call xml_EndElement(xf, 'latticeVector')
    enddo
    call xml_EndElement(xf, 'lattice')

  END SUBROUTINE cmlAddLatticeSP

  ! -------------------------------------------------
  ! 2. creates and writes DP Lattice element
  ! -------------------------------------------------

  SUBROUTINE cmlAddLatticeDP(xf, cell, units, title, id, dictref, conv, lattType, spaceType, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)               :: cell(3,3)
    character(len=*), intent(in), optional :: units
    character(len=*), intent(in), optional :: id           ! id
    character(len=*), intent(in), optional :: title        ! title
    character(len=*), intent(in), optional :: dictref      ! dictref
    character(len=*), intent(in), optional :: conv         ! format
    character(len=*), intent(in), optional :: lattType     !
    character(len=*), intent(in), optional :: spaceType    !
    character(len=*), intent(in), optional :: fmt

    ! Internal Variables
    integer           :: i
    character(len=10) :: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'lattice')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(lattType)) call xml_AddAttribute(xf, 'latticeType', lattType)
    if (present(spaceType)) call xml_AddAttribute(xf, 'spaceType', spaceType)

    do i = 1,3
       call xml_NewElement(xf, 'latticeVector')
       if (present(units)) call xml_AddAttribute(xf, 'units', units)
       call xml_AddAttribute(xf, 'dictRef', 'cml:latticeVector')
       call xml_AddPcdata(xf, str(cell(1,i), formt))
       call xml_AddPcdata(xf, str(cell(2,i), formt))
       call xml_AddPcdata(xf, str(cell(3,i), formt))
       call xml_EndElement(xf, 'latticeVector')
    enddo

    call xml_EndElement(xf, 'lattice')

  END SUBROUTINE cmlAddLatticeDP

  ! -------------------------------------------------
  ! 1. creates a DP Lattice Vector element
  ! -------------------------------------------------

  SUBROUTINE cmlAddLatticeVectorDP(xf, vector, title, id, dictref, conv, units, periodic, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in) :: vector(3)
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: units
    character(len=*), intent(in), optional :: periodic
    character(len=*), intent(in), optional :: fmt

    ! Deal with optional things
    ! that have defaults
    character(len=10) :: formt
    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'latticeVector')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(units)) call xml_AddAttribute(xf, 'units', units)
    if (present(periodic)) call xml_AddAttribute(xf, 'periodic', periodic)
    call xml_AddPcdata(xf, str(vector(1), formt))
    call xml_AddPcdata(xf, str(vector(2), formt))
    call xml_AddPcdata(xf, str(vector(3), formt))
    call xml_EndElement(xf, 'latticeVector')

  END SUBROUTINE cmlAddLatticeVectorDP

  ! -------------------------------------------------
  ! 2. creates a SP Lattice Vector element
  ! -------------------------------------------------

  SUBROUTINE cmlAddLatticeVectorSP(xf, vector, title, id, dictref, conv, units, periodic, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in) :: vector(3)
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: id
    character(len=*), intent(in), optional :: dictref
    character(len=*), intent(in), optional :: conv
    character(len=*), intent(in), optional :: units       ! should this be optional
    character(len=*), intent(in), optional :: periodic
    character(len=*), intent(in), optional :: fmt

    ! Deal with optional things
    ! that have defaults
    character(len=10) :: formt
    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'latticeVector')
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(dictref)) call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(units)) call xml_AddAttribute(xf, 'units', units)
    if (present(units)) call xml_AddAttribute(xf, 'periodic', periodic)
    call xml_AddPcdata(xf, str(vector(1), formt))
    call xml_AddPcdata(xf, str(vector(2), formt))
    call xml_AddPcdata(xf, str(vector(3), formt))
    call xml_EndElement(xf, 'latticeVector')

  END SUBROUTINE cmlAddLatticeVectorSP

  ! -------------------------------------------------
  ! 1. creates and writes a DP <cell> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddCrystalDP(xf, a, b, c, alpha, beta, gamma, id, title, dictref, lenunits, angunits, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)               :: a, b, c      ! cell parameters
    real(kind=dp), intent(in)               :: alpha        ! alpha cell parameter
    real(kind=dp), intent(in)               :: beta         ! beta cell parameter
    real(kind=dp), intent(in)               :: gamma        ! gamma cell parameter
    character(len=*), intent(in), optional :: id           ! id
    character(len=*), intent(in), optional :: title        ! title
    character(len=*), intent(in), optional :: dictref      ! dictref
    character(len=*), intent(in), optional :: lenunits     ! units for length (default = angstrom)
    character(len=*), intent(in), optional :: angunits     ! units for angles (default = degree)
    character(len=*), intent(in), optional :: fmt          ! format

    ! Flush on entry and exit
    character(len=30) ::  lunits, aunits
    character(len=10) :: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(lenunits)) then
       lunits = lenunits
    else
       lunits = 'units:angstrom'
    endif
    if (present(angunits)) then
       aunits = angunits
    else
       aunits = 'units:degree'
    endif

    call stmAddStartTag(xf=xf, name='crystal', id=id, title=title, dictref=dictref)
    call stmAddScalar(xf=xf, value=a, title='a', dictref='cml:a', units=lunits, fmt=formt)
    call stmAddScalar(xf=xf, value=b, title='b', dictref='cml:b', units=lunits, fmt=formt)
    call stmAddScalar(xf=xf, value=c, title='c', dictref='cml:c', units=lunits, fmt=formt)
    call stmAddScalar(xf=xf, value=alpha, title='alpha', dictref='cml:alpha', units=aunits, fmt=formt)
    call stmAddScalar(xf=xf, value=beta,  title='beta',  dictref='cml:beta',  units=aunits, fmt=formt)
    call stmAddScalar(xf=xf, value=gamma, title='gamma', dictref='cml:gamma', units=aunits, fmt=formt)
    call xml_EndElement(xf, 'crystal')

  END SUBROUTINE cmlAddCrystalDP

  ! -------------------------------------------------
  ! 2. creates and writes a SP <cell> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddCrystalSP(xf, a, b, c, alpha, beta, gamma, id, title, dictref, lenunits, angunits, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)     :: a, b, c      ! cell parameters
    real(kind=sp), intent(in)     :: alpha        ! alpha cell parameter
    real(kind=sp), intent(in)     :: beta         ! beta cell parameter
    real(kind=sp), intent(in)     :: gamma        ! gamma cell parameter
    character(len=*), intent(in), optional :: id           ! id
    character(len=*), intent(in), optional :: title        ! title
    character(len=*), intent(in), optional :: dictref      ! dictref
    character(len=*), intent(in), optional :: lenunits     ! units for length (' ' = angstrom)
    character(len=*), intent(in), optional :: angunits     ! units for angles (' ' = degree)
    character(len=*), intent(in), optional :: fmt          ! format

    ! Flush on entry and exit
    character(len=30) :: lunits, aunits
    character(len=10) :: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif
    if (present(lenunits)) then
       lunits = lenunits
    else
       lunits = U_ANGSTR
    endif
    if (present(angunits)) then
       aunits = angunits
    else
       aunits = U_DEGREE
    endif

    call stmAddStartTag(xf, 'crystal', id, title, dictref)
    call stmAddScalar(xf, a, ' ', 'a', 'cml:a', lunits, formt)
    call stmAddScalar(xf, b, ' ', 'b', 'cml:b', lunits, formt)
    call stmAddScalar(xf, c, ' ', 'c', 'cml:c', lunits, formt)
    call stmAddScalar(xf, alpha, ' ', 'alpha', 'cml:alpha', aunits, formt)
    call stmAddScalar(xf, beta, ' ', 'beta', 'cml:beta', aunits, formt)
    call stmAddScalar(xf, gamma, ' ', 'gamma', 'cml:gamma', aunits, formt)
    call xml_EndElement(xf, 'crystal')

  END SUBROUTINE cmlAddCrystalSP

  ! -------------------------------------------------
  ! 1. creates and writes an DP <eigen> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddEigenvalueDP(xf, n, dim, eigvec, eigval, id, title, dictref, fmt)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)          :: n              ! number of elements
    integer, intent(in)          :: dim            ! dimension of matrix
    real(kind=dp), intent(in)     :: eigvec(dim, *) ! eigenvectors
    real(kind=dp), intent(in)     :: eigval(*)      ! eigenvalues
    character(len=*), intent(in), optional :: id             ! id
    character(len=*), intent(in), optional :: title          ! title
    character(len=*), intent(in), optional :: dictref        ! dictionary reference
    character(len=*), intent(in), optional :: fmt            ! format
    character(len=10):: formt
    integer ::  i, j

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call xml_NewElement(xf, 'eigen')
    if (present(id))      call xml_AddAttribute(xf, 'id', id)
    if (present(title))   call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(dictref)) call xml_AddAttribute(xf, 'title', title)
    call stmAddArray(xf=xf, nvalue=n, array=eigval, title='eigenvalues', dictref=dictRef, fmt=fmt)
    call stmAddMatrix(xf=xf, ncols=n, nrows=n, dim=dim, matrix=eigvec, title='eigenvectors', fmt=fmt)
    call xml_EndElement(xf, 'eigen')

  END SUBROUTINE cmlAddEigenvalueDP

  ! -------------------------------------------------
  ! 2. creates and writes an SP <eigen> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddEigenvalueSP(xf, n, dim, eigvec, eigval, id, title, dictref, fmt)

    implicit none
    type(xmlf_t) :: xf
    integer, intent(in)          :: n              ! number of elements
    integer, intent(in)          :: dim            ! dimension of matrix
    real(kind=sp), intent(in)     :: eigvec(dim, *) ! eigenvectors
    real(kind=sp), intent(in)     :: eigval(*)      ! eigenvalues
    character(len=*), intent(in), optional :: id             ! id
    character(len=*), intent(in), optional :: title          ! title
    character(len=*), intent(in), optional :: dictref        ! dictionary reference
    character(len=*), intent(in), optional :: fmt            ! format
    character(len=10):: formt
    integer ::  i, j

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    ! Flush on entry and exit
    call xml_NewElement(xf, 'eigen')
    if (present(id))      call xml_AddAttribute(xf, 'id', id)
    if (present(title))   call xml_AddAttribute(xf, 'dictRef', dictref)
    if (present(dictref)) call xml_AddAttribute(xf, 'title', title)
    call stmAddArray(xf=xf, nvalue=n, array=eigval, title='eigenvalues', dictref=dictRef, fmt=fmt)
    call stmAddMatrix(xf=xf, ncols=n, nrows=n, dim=dim, matrix=eigvec, title='eigenvectors', fmt=fmt)
    call xml_EndElement(xf, 'eigen')

  END SUBROUTINE cmlAddEigenvalueSP

  SUBROUTINE cmlAddMetadata(xf, name, content, conv)

    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: name
    character(len=*) :: content
    character(len=*), optional :: conv

    call xml_NewElement(xf, 'metadata')
    call xml_AddAttribute(xf, 'name', name)
    call xml_AddAttribute(xf, 'content', content)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    call xml_EndElement(xf, 'metadata')

  END SUBROUTINE cmlAddMetadata

  ! -------------------------------------------------
  ! 1. creates and writes an Char <parameter> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddParameterCh(xf, value, ref, id, title, conv, &
       cons, units, name, role)

    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: value
    character(len=*), optional :: ref
    character(len=*), optional :: title
    character(len=*), optional :: id
    character(len=*), optional :: conv
    character(len=*), optional :: cons
    character(len=*), optional :: units
    character(len=*), optional :: name
    character(len=*), optional :: role

    call xml_NewElement(xf, 'parameter')
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(cons)) call xml_AddAttribute(xf, 'constraint', cons)
    if (present(name)) call xml_AddAttribute(xf, 'name', name)
    if (present(role)) call xml_AddAttribute(xf, 'role', role)
    if (present(units)) then
       call xml_NewElement(xf, 'scalar')
       call xml_AddAttribute(xf, 'units', units)
       call xml_AddPcdata(xf, value)
       call xml_EndElement(xf, 'scalar')
    else
       call xml_AddAttribute(xf, 'value', value)
    endif
    call xml_EndElement(xf, 'parameter')

  END SUBROUTINE CMLADDPARAMETERCH

  ! -------------------------------------------------
  ! 2. creates and writes an SP <parameter> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddParameterSP(xf, value, ref, title, id, conv, &
       cons, units, name, role, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=sp) :: value
    character(len=*), optional :: ref
    character(len=*), optional :: title
    character(len=*), optional :: id
    character(len=*), optional :: conv
    character(len=*), optional :: cons
    character(len=*), optional :: units
    character(len=*), optional :: name
    character(len=*), optional :: role
    character(len=*), optional :: fmt

    character(len=10) :: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'parameter')
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(cons)) call xml_AddAttribute(xf, 'constraint', cons)
    if (present(name)) call xml_AddAttribute(xf, 'name', name)
    if (present(role)) call xml_AddAttribute(xf, 'role', role)
    if (present(units)) then
       call xml_NewElement(xf, 'scalar')
       call xml_AddAttribute(xf, 'units', units)
       call xml_AddPcdata(xf, str(value))
       call xml_EndElement(xf, 'scalar')
    else
       call xml_AddAttribute(xf, 'value', str(value,formt))
    endif
    call xml_EndElement(xf, 'parameter')

  END SUBROUTINE CMLADDPARAMETERSP

  ! -------------------------------------------------
  ! 3. creates and writes an DP <parameter> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddParameterDP(xf, value, ref, title, id, conv, &
       cons, units, name, role, fmt)

    implicit none
    type(xmlf_t) :: xf
    real(kind=dp) :: value
    character(len=*), optional :: ref
    character(len=*), optional :: title
    character(len=*), optional :: id
    character(len=*), optional :: conv
    character(len=*), optional :: cons
    character(len=*), optional :: units
    character(len=*), optional :: name
    character(len=*), optional :: role
    character(len=*), optional :: fmt

    character(len=10) :: formt

    if (present(fmt)) then
       formt = fmt
    else
       formt = '(f8.3)'
    endif

    call xml_NewElement(xf, 'parameter')
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(cons)) call xml_AddAttribute(xf, 'constraint', cons)
    if (present(name)) call xml_AddAttribute(xf, 'name', name)
    if (present(role)) call xml_AddAttribute(xf, 'role', role)
    if (present(units)) then
       call xml_NewElement(xf, 'scalar')
       call xml_AddAttribute(xf, 'units', units)
       call xml_AddPcdata(xf, str(value))
       call xml_EndElement(xf, 'scalar')
    else
       call xml_AddAttribute(xf, 'value', str(value))
    endif
    call xml_EndElement(xf, 'parameter')

  END SUBROUTINE CMLADDPARAMETERDP

  ! -------------------------------------------------
  ! 4. creates and writes an Integer <parameter> element
  ! -------------------------------------------------

  SUBROUTINE cmlAddParameterI(xf, value, ref, id, title, conv, &
       cons, units, name, role)

    implicit none
    type(xmlf_t) :: xf
    integer :: value
    character(len=*), optional :: ref
    character(len=*), optional :: title
    character(len=*), optional :: id
    character(len=*), optional :: conv
    character(len=*), optional :: cons
    character(len=*), optional :: units
    character(len=*), optional :: name
    character(len=*), optional :: role

    call xml_NewElement(xf, 'parameter')
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(cons)) call xml_AddAttribute(xf, 'constraint', cons)
    if (present(name)) call xml_AddAttribute(xf, 'name', name)
    if (present(role)) call xml_AddAttribute(xf, 'role', role)
    if (present(units)) then
       call xml_NewElement(xf, 'scalar')
       call xml_AddAttribute(xf, 'units', units)
       call xml_AddPcdata(xf, str(value))
       call xml_EndElement(xf, 'scalar')
    else
       call xml_AddAttribute(xf, 'value', str(value))
    endif
    call xml_EndElement(xf, 'parameter')

  END SUBROUTINE CMLADDPARAMETERI

  SUBROUTINE cmlAddParameterLG(xf, value, ref, id, title, conv, &
       cons, units, name, role)

    implicit none
    type(xmlf_t) :: xf
    logical      :: value
    character(len=*), optional :: ref
    character(len=*), optional :: title
    character(len=*), optional :: id
    character(len=*), optional :: conv
    character(len=*), optional :: cons
    character(len=*), optional :: units
    character(len=*), optional :: name
    character(len=*), optional :: role

    call xml_NewElement(xf, 'parameter')
    if (present(ref)) call xml_AddAttribute(xf, 'ref', ref)
    if (present(title)) call xml_AddAttribute(xf, 'title', title)
    if (present(id)) call xml_AddAttribute(xf, 'id', id)
    if (present(conv)) call xml_AddAttribute(xf, 'convention', conv)
    if (present(cons)) call xml_AddAttribute(xf, 'constraint', cons)
    if (present(name)) call xml_AddAttribute(xf, 'name', name)
    if (present(role)) call xml_AddAttribute(xf, 'role', role)
    if (present(units)) then
       call xml_NewElement(xf, 'scalar')
       call xml_AddAttribute(xf, 'units', units)
       call xml_AddPcdata(xf, str(value))
       call xml_EndElement(xf, 'scalar')
    else
       call xml_AddAttribute(xf, 'value', str(value))
    endif
    call xml_EndElement(xf, 'parameter')

  END SUBROUTINE CMLADDPARAMETERLG

! =================================================
! basic CML routines
! =================================================

  ! -------------------------------------------------
  ! 1. adds DP xyz3 to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXYZ39DP(xf, x3, y3, z3, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp)      :: x3, y3, z3 ! coordinates
    character(len=*)  :: fmt        ! format (default '(f8.3)')
    character(len=45) :: x, y, z

    write(x,fmt) x3
    write(y,fmt) y3
    write(z,fmt) z3

    call xml_AddAttribute(xf, 'xyz3', trim(x)//' '//trim(adjustl(y))//' '//trim(adjustl(z)) )

  END SUBROUTINE CMLATXYZ39DP

  ! -------------------------------------------------
  ! 2. adds SP xyz3 to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXYZ39SP(xf, x3, y3, z3, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp)      :: x3, y3, z3 ! coordinates
    character(len=*)  :: fmt        ! format (default '(f8.3)')

    character(len=45) :: x, y, z

    write(x,fmt) x3
    write(y,fmt) y3
    write(z,fmt) z3

    call xml_AddAttribute(xf, 'xyz3', trim(x)//' '//trim(adjustl(y))//' '//trim(adjustl(z)) )

  END SUBROUTINE CMLATXYZ39SP

  ! -------------------------------------------------
  ! 1. adds DP xyzFrac to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXYZFRACT9DP(xf, x3, y3, z3, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp)      :: x3, y3, z3 ! coordinates
    character(len=*)  :: fmt        ! format (default '(f8.3)')

    character(len=45) :: x, y, z

    write(x,fmt) x3
    write(y,fmt) y3
    write(z,fmt) z3

    call xml_AddAttribute(xf, 'xyzFrac', trim(x)//' '//trim(adjustl(y))//' '//trim(adjustl(z)) )

  END SUBROUTINE CMLATXYZFRACT9DP

  ! -------------------------------------------------
  ! 2. adds SP xyzFrac to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXYZFRACT9SP(xf, x3, y3, z3, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)     :: x3, y3, z3 ! coordinates
    character(len=*), intent(in) :: fmt        ! format (default '(f8.3)')

    character(len=45) :: x, y, z

    write(x,fmt) x3
    write(y,fmt) y3
    write(z,fmt) z3

    call xml_AddAttribute(xf, 'xyzFrac', trim(x)//' '//trim(y)//' '//trim(z))

  END SUBROUTINE CMLATXYZFRACT9SP

  ! -------------------------------------------------
  ! 1. adds DP x3, y3, z3 to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATX39DP(xf, x3, y3, z3, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)     :: x3, y3, z3 ! coordinates
    character(len=*), intent(in) :: fmt        ! format (default '(f8.3)')

    call xml_AddAttribute(xf, 'x3', str(x3, fmt))
    call xml_AddAttribute(xf, 'y3', str(y3, fmt))
    call xml_AddAttribute(xf, 'z3', str(z3, fmt))

  END SUBROUTINE CMLATX39DP

  ! -------------------------------------------------
  ! 2. adds SP x3, y3, z3 to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATX39SP(xf, x3, y3, z3, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp), intent(in)     :: x3, y3, z3 ! coordinates
    character(len=*), intent(in) :: fmt        ! format (default '(f8.3)')

    call xml_AddAttribute(xf, 'x3', str(x3, fmt))
    call xml_AddAttribute(xf, 'y3', str(y3, fmt))
    call xml_AddAttribute(xf, 'z3', str(z3, fmt))

  END SUBROUTINE CMLATX39SP

  ! -------------------------------------------------
  ! 1. adds DP xFract, yFract, zFract to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXF9DP(xf, xFract, yFract, zFract, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp), intent(in)     :: xFract, yFract, zFract ! coordinates
    character(len=*), intent(in) :: fmt                    ! format (default '(f8.3)')

    call xml_AddAttribute(xf, 'xFract', str(xFract, fmt))
    call xml_AddAttribute(xf, 'yFract', str(yFract, fmt))
    call xml_AddAttribute(xf, 'zFract', str(zFract, fmt))

  END SUBROUTINE CMLATXF9DP

  ! -------------------------------------------------
  ! 2. adds SP xfrac, yFractractrac, zFractrac to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXF9SP(xf, xFract, yFract, zFract, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp)     :: xFract, yFract, zFract   ! fractional coordinates
    character(len=*) :: fmt                      ! format (default '(f8.3)')

    call xml_AddAttribute(xf, 'xFract', str(xFract, fmt))
    call xml_AddAttribute(xf, 'yFract', str(yFract, fmt))
    call xml_AddAttribute(xf, 'zFract', str(zFract, fmt))

  END SUBROUTINE CMLATXF9SP

  ! -------------------------------------------------
  ! 1. adds DP x2, y2 to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXY9DP(xf, x2, y2, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=dp)     :: x2, y2   ! coordinates
    character(len=*) :: fmt      ! format (default f8.3)

    call xml_AddAttribute(xf, 'x2', str(x2, fmt))
    call xml_AddAttribute(xf, 'y2', str(y2, fmt))
    call xml_AddPcdata(xf, '>')                   !!! AG****

  END SUBROUTINE CMLATXY9DP

  ! -------------------------------------------------
  ! 2. adds SP x2, y2 to start tag
  ! -------------------------------------------------

  SUBROUTINE CMLATXY9SP(xf, x2, y2, fmt)
    implicit none
    type(xmlf_t) :: xf
    real(kind=sp)     :: x2, y2   ! coordinates
    character(len=*) :: fmt      ! format (default f8.3)

    call xml_AddAttribute(xf, 'x2', str(x2, fmt))
    call xml_AddAttribute(xf, 'y2', str(y2, fmt))
    call xml_AddPcdata(xf, '>')                      !!AG***

  END SUBROUTINE CMLATXY9SP

  ! -------------------------------------------------
  ! 1. creates a DP <length> element
  ! -------------------------------------------------

  SUBROUTINE CMLLEN9DP(xf, id, atomRef1, atomRef2, length, fmt)
    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: id           ! length id
    character(len=*) :: atomRef1     ! ref to first atom
    character(len=*) :: atomRef2     ! ref to second atom
    real(kind=dp)     :: length       ! the length
    character(len=*) :: fmt          ! format
    character(len=20) :: temp

    temp = atomRef1//' '//adjustl(atomRef2)

    call xml_NewElement(xf, 'length')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'atomRefs2', temp)
    call xml_AddPcdata(xf, str(length, fmt))
    call xml_EndElement(xf, 'length')

  END SUBROUTINE CMLLEN9DP

  ! -------------------------------------------------
  ! 2. creates a SP <length> element
  ! -------------------------------------------------

  SUBROUTINE CMLLEN9SP(xf, id, atomRef1, atomRef2, length, fmt)
    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: id           ! length id
    character(len=*) :: atomRef1     ! ref to first atom
    character(len=*) :: atomRef2     ! ref to second atom
    real(kind=sp)     :: length       ! the length
    character(len=*) :: fmt          ! format
    character(len=20) :: temp

    temp = atomRef1//' '//adjustl(atomRef2)

    call xml_NewElement(xf, 'length')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'atomRefs2', temp)
    call xml_AddPcdata(xf, str(length, fmt))
    call xml_EndElement(xf, 'length')

  END SUBROUTINE CMLLEN9SP

  ! -------------------------------------------------
  ! 1. creates a DP <angle> element
  ! -------------------------------------------------

  SUBROUTINE CMLANG9DP(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)
    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: id              ! angle id
    character(len=*) :: atomRef1        ! ref to first atom
    character(len=*) :: atomRef2        ! ref to second atom
    character(len=*) :: atomRef3        ! ref to third atom
    real(kind=dp)     :: angle           ! the angle
    character(len=*) :: fmt             ! format
    character(len=20) :: temp

    temp = atomRef1//' '//adjustl(atomRef2)//' '//adjustl(atomRef3)

    call xml_NewElement(xf, 'angle')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'atomRefs3', temp)
    call xml_AddPcdata(xf, str(angle, fmt))
    call xml_EndElement(xf, 'angle')

  END SUBROUTINE CMLANG9DP

  ! -------------------------------------------------
  ! 2. creates a SP <angle> element
  ! -------------------------------------------------

  SUBROUTINE CMLANG9SP(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)
    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: id              ! angle id
    character(len=*) :: atomRef1        ! ref to first atom
    character(len=*) :: atomRef2        ! ref to second atom
    character(len=*) :: atomRef3        ! ref to third atom
    real(kind=sp)     :: angle           ! the angle
    character(len=*) :: fmt             ! format
    character(len=20) :: temp

    temp = atomRef1//' '//adjustl(atomRef2)//' '//adjustl(atomRef3)

    call xml_NewElement(xf, 'angle')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'atomRefs3', temp)
    call xml_AddPcdata(xf, str(angle, fmt))
    call xml_EndElement(xf, 'angle')

  END SUBROUTINE CMLANG9SP

  ! -------------------------------------------------
  ! 1. creates a DP <torsion> element
  ! -------------------------------------------------

  SUBROUTINE CMLTOR9DP(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, fmt)
    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: id              ! torsion id
    character(len=*) :: atomRef1        ! ref to first atom
    character(len=*) :: atomRef2        ! ref to second atom
    character(len=*) :: atomRef3        ! ref to third atom
    character(len=*) :: atomRef4        ! ref to fourth atom
    real(kind=dp)     :: torsion         ! the torsion
    character(len=*) :: fmt             ! format
    character(len=20) :: temp

    temp = atomRef1//' '//adjustl(atomRef2)//' '//adjustl(atomRef3)//' '//adjustl(atomRef4)

    call xml_NewElement(xf, 'torsion')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'atomRefs4', temp)
    call xml_AddPcdata(xf, str(torsion, fmt))
    call xml_EndElement(xf, 'torsion')

  END SUBROUTINE CMLTOR9DP

  ! -------------------------------------------------
  ! 2. creates a SP <torsion> element
  ! -------------------------------------------------

  SUBROUTINE CMLTOR9SP(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, fmt)
    implicit none
    type(xmlf_t) :: xf
    character(len=*) :: id              ! torsion id
    character(len=*) :: atomRef1        ! ref to first atom
    character(len=*) :: atomRef2        ! ref to second atom
    character(len=*) :: atomRef3        ! ref to third atom
    character(len=*) :: atomRef4        ! ref to fourth atom
    real(kind=sp)     :: torsion         ! the torsion
    character(len=*) :: fmt             ! format
    character(len=20) :: temp

    temp = atomRef1//' '//adjustl(atomRef2)//' '//adjustl(atomRef3)//' '//adjustl(atomRef4)

    call xml_NewElement(xf, 'torsion')
    call xml_AddAttribute(xf, 'id', id)
    call xml_AddAttribute(xf, 'atomRefs4', temp)
    call xml_AddPcdata(xf, str(torsion, fmt))
    call xml_EndElement(xf, 'torsion')

  END SUBROUTINE CMLTOR9SP

end module m_cmlw


text:
package com.kinvey.samples.citywatch;

import android.graphics.Bitmap;
import android.location.Location;
import com.google.api.client.json.GenericJson;
import com.google.api.client.util.Key;

import java.io.Serializable;

public class CityWatchEntity extends GenericJson {

	private static final long serialVersionUID = 6102384593846439027L;

	@Key("_geoloc")
	private double[] coords;
	@Key("_id")
	private String objectId;

	// but Facebook needs long/lat seperately
	@Key("latitude")
	private Double latitude;
	@Key("longitude")
	private Double longitude;
	@Key("title")
	private String title;
	private byte[] image;

	private transient Bitmap bitmap = null;

	// private Drawable image;
	@Key()
	private String description;
	@Key()
	private String category;
	@Key()
	private String severity;
	@Key()
	private String risk;
	@Key()
	private String address;
	@Key()
	private Integer repeat;

	public String getImageURL() {
		return imageURL;
	}

	public void setImageURL(String imageURL) {
		this.imageURL = imageURL;
	}

	@Key()
	private String imageURL;

	public Location getCoords() {
		Location geoloc = new Location(CityWatchEntity.class.getCanonicalName());
		geoloc.setLatitude(coords[1]);
		geoloc.setLongitude(coords[0]);
		return geoloc;
	}

	public void setCoords(Location coords) {
		double[] geoloc = new double[2];
		geoloc[0] = coords.getLongitude();
		geoloc[1] = coords.getLatitude();
		this.coords = geoloc;
	}

	public String getObjectId() {
		return objectId;
	}

	public void setObjectId(String objectId) {
		this.objectId = objectId;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getSeverity() {
		return severity;
	}

	public void setSeverity(String severity) {
		this.severity = severity;
	}

	public String getRisk() {
		return risk;
	}

	public void setRisk(String risk) {
		this.risk = risk;
	}

	public Integer getRepeat() {
		return repeat;
	}

	public void setRepeat(Integer repeat) {
		this.repeat = repeat;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public byte[] getImage() {
		if (image == null) {
			image = new byte[1];
		}
		return image;
	}

	public void setImage(byte[] image) {
		this.image = image;
	}

	public Bitmap getBitmap() {
		return bitmap;
	}

	public void setBitmap(Bitmap bitmap) {
		this.bitmap = bitmap;
	}

}

redpajama_set_name: RedPajamaGithub


text:
This directory maintains the Dockerfiles needed to build the tensorflow-io images.

## Building

To build a `tensorflow-io` image with CPU support:

```bash
$ docker build -f ./cpu.Dockerfile -t tfio-cpu .
```

**NOTE:** Each `.Dockerfile` has its own set of available `--build-arg`s which are documented
in the file itself.

## Running Locally Built Images

**Note for new Docker users:** the `-v` and `-u` flags share directories and
permissions between the Docker container and your machine. Without `-v`, your
work will be wiped once the container quits, and without `-u`, files created by
the container will have the wrong file permissions on your host machine. Check
out the
[Docker run documentation](https://docs.docker.com/engine/reference/run/) for
more info.

```sh
# Mount $PWD into the container and make it as the current working directory.
$ docker run -it --rm -v ${PWD}:/v -w /v tfio-cpu
```


text:
<?php
/**
 * Created by IntelliJ IDEA.
 * User: Nikolay Chervyakov
 * Date: 03.09.2014
 * Time: 18:42
 */

namespace App\Controller;

use App\Page;
use VulnModule\Config\Annotations as Vuln;

/**
 * Class Helpdesk
 * @package App\Controller
 * @Vuln\Description("GWT entry point.")
 */
class Helpdesk extends Page
{
    public function before()
    {
        parent::before();
        if (!$this->execute) {
            return;
        }
    }

    public function action_index()
    {
        $this->view->headScripts = '<script type="text/javascript" src="helpdesk.nocache.js"></script>';
        $this->view->subview = "helpdesk/index";
    }

    public function action_HelpdeskService() {
        $this->vulninjection->goUp()->goUp();
        $this->vulninjection->loadAndAddChildContext('gwt');
        $this->vulninjection->goDown('gwt');

        $servlet = $this->pixie->gwt->getServlet();
        $servlet->setRequest($this->request);
        $servlet->start();
        exit;
    }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
null

#### Original name
Paepalanthus cipoensis Silveira

### Remarks
null


text:
<archimate:Requirement
    xmlns:archimate="http://www.archimatetool.com/archimate"
    name="Audit of Software provider"
    id="57c89282-0aa7-4a5e-a514-d567a19f1481"/>


text:
#ifndef __MEMORY_H__
#define __MEMORY_H__

#include <stdint.h>

namespace mm {

void initialize(void);

#define MM_LOG_SILENT  1
#define MM_LOG_NOISY   0

void log_status(int);
void log_new(size_t, void *);
void log_delete(void *);

} /* mm */

#endif


text:
package br.com.eng3.tipo;
import java.text.DecimalFormat;
import java.util.List;

import br.com.eng3.principal.BDAcidente;
import br.com.eng3.principal.Tela;

public class Ciclista implements ImpressaoVitima {

	private BDAcidente bda;
	private Tela tela;

	public Ciclista(BDAcidente bda,Tela tela){
		this.bda = bda;
		this.tela = tela;

	}
	public void imprimirVitima(Acidente v){

		tela.imprimirCiclista(v);
	}

}


text:
package org.ovirt.engine.ui.webadmin.section.main.view.popup.vm;

import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundWidgetPopupView;
import org.ovirt.engine.ui.common.widget.uicommon.popup.vm.VmSnapshotCreatePopupWidget;
import org.ovirt.engine.ui.uicommonweb.models.vms.SnapshotModel;
import org.ovirt.engine.ui.webadmin.ApplicationConstants;
import org.ovirt.engine.ui.webadmin.ApplicationResources;
import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.vm.VmSnapshotCreatePopupPresenterWidget;

import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;

public class VmSnapshotCreatePopupView extends AbstractModelBoundWidgetPopupView<SnapshotModel> implements VmSnapshotCreatePopupPresenterWidget.ViewDef {

    @Inject
    public VmSnapshotCreatePopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) {
        super(eventBus, resources, new VmSnapshotCreatePopupWidget(constants), "410px", "200px");
    }

}


text:
<?php

namespace GooglePlus;

/**
 * Class to reques the access token
 * after you get the authorization code
 */
class AccessTokenGetter
{
    public function __construct()
    {

    }

    /**
     * [getToken description]
     * @param  [type] $params [description]
     *                $params['code']
     *                $params['client_id']
     *                $params['client_secret']
     *                $params['redirect_uri']
     *                $params['grant_type']
     *
     * @return A String that contains a json element
     *         If the json object is invalid then contains the
     *         error element inside
     */
    public function getToken($params)
    {
        if (!self::validParams($params)) {
            throw new \RuntimeException('Invalid parameter for the method get token');
        }

        $url = 'https://accounts.google.com/o/oauth2/token';

        $values = 'code=%s&client_id=%s&client_secret=%s&redirect_uri=%s&grant_type=%s';
        $values = sprintf($values, $params['code'], $params['client_id'],
            $params['client_secret'],  $params['redirect_uri'],
        $params['grant_type']);

        $ch = curl_init();
        $headers = array(
            'Accept: application/json',
            'Content-Type: application/x-www-form-urlencoded'
        );
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $values);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

        return curl_exec($ch);
    }

    public static function validParams($params)
    {
        $valid = true;

        $isArray = is_array($params);

        if ($isArray) {
            $toCheck = array('code', 'client_id', 'client_secret', 'redirect_uri',
            'grant_type');

            foreach ($toCheck as $name) {
                if (!isset($params[$name])) {
                    $valid = false;
                    break;
                }
            }
        } else {
            $valid = false;
        }
        return $valid;
    }

}


text:
const fs = require('fs').promises;
const path = require("path");

// https://github.com/octokit/rest.js
// https://octokit.github.io/rest.js/
const { Octokit } = require('@octokit/rest');

console.log("process.cwd():");
console.log(process.cwd());
console.log("path.resolve(\".\")");
console.log(path.resolve("."));

console.log("__dirname:");
console.log(__dirname);

const args = process.argv.slice(2);
console.log("args:");
console.log(args);

const envCommitSha = process.env.TRAVIS_COMMIT || process.env.APPVEYOR_REPO_COMMIT || process.env.GITHUB_SHA;

console.log("TRAVIS_COMMIT:");
console.log(envCommitSha);
if (!envCommitSha) {
    console.log("Missing TRAVIS_COMMIT! Abort.");
    process.exit(1);
    return;
}

console.log("TRAVIS_TAG:");
console.log(process.env.TRAVIS_TAG);
if (!process.env.TRAVIS_TAG) {
    console.log("Missing TRAVIS_TAG! Abort.");
    process.exit(1);
    return;
}

const ghtoken = process.env.GH_TOKEN || process.env.GITHUB_TOKEN;
if (!ghtoken) {
    console.log("Missing GH_TOKEN! Abort.");
    process.exit(1);
    return;
}

const octokit = new Octokit({
    auth: `token ${ghtoken}`
});

// !!!!!!!!!!!!!!!!
// IMPORTANT !!!!
// Make sure DEBUG is *off* in TravisCI,
// as this potentially prints console messages that contain the HTTP header:
// authorization: 'token GH_TOKEN'
// It that happens, revoke the token immediately!
// https://github.com/settings/tokens
// Example: when getReleaseByTag() return 404
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const DEBUG = false;
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

const owner_appveyor = "danielweck";
const owner = "edrlab";
const repo = "thorium-reader";
const tag = process.env.TRAVIS_TAG;

(async () => {

console.log("################################################");
console.log("################ getReleaseByTag:");
let getReleaseByTagRES = undefined;
try {
    getReleaseByTagRES = await octokit.repos.getReleaseByTag({owner, repo, tag})
} catch (err) {
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    if (DEBUG) console.log(err);
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    console.log("getReleaseByTag error! Continue.");
    // if (err.status !== 404) {
    //     console.log("getReleaseByTag error! Abort.");
    //     process.exit(1);
    //     return;
    // }
}

if (getReleaseByTagRES) {
    console.log("getReleaseByTagRES:");
    if (DEBUG) console.log(getReleaseByTagRES);

    const release_id = getReleaseByTagRES.data.id;

    console.log("################################################");
    console.log("################ deleteRelease:");
    let deleteReleaseRES = undefined;
    try {
        deleteReleaseRES = await octokit.repos.deleteRelease({owner, repo, release_id})
    } catch (err) {
        console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        if (DEBUG) console.log(err);
        console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        console.log("deleteReleaseRES error! Continue.");
        // console.log("deleteRelease error! Abort.");
        // process.exit(1);
        // return;
    }
    if (deleteReleaseRES) {
        console.log("deleteReleaseRES:");
        if (DEBUG) console.log(deleteReleaseRES);
    }
}

const ref = `tags/${process.env.TRAVIS_TAG}`;

console.log("################################################");
console.log("################ deleteRef:");
let deleteRefRES = undefined;
try {
    deleteRefRES = await octokit.git.deleteRef({owner, repo, ref})
} catch (err) {
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    if (DEBUG) console.log(err);
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    console.log("deleteRefRES error! Continue.");
    // console.log("deleteRef error! Abort.");
    // process.exit(1);
    // return;
}

if (deleteRefRES) {
    console.log("deleteRefRES:");
    if (DEBUG) console.log(deleteRefRES);
}

if (process.env.APPVEYOR_REPO_COMMIT) {
    console.log("Appveyor: skip create tag and release.");
    process.exit(0);
}

const message = process.env.TRAVIS_TAG;
const object = envCommitSha;
const type =  "commit";
const tagger = {
    name: "Daniel Weck",
    email: "daniel.weck@gmail.com",
    date: new Date().toISOString(),
};

console.log("################################################");
console.log("################ createTag:");
let createTagRES = undefined;
try {
    createTagRES = await octokit.git.createTag({owner, repo, tag, message, object, type, tagger, "tagger:name": tagger.name, "tagger:email": tagger.email, "tagger:date": tagger.date});
} catch (err) {
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    if (DEBUG) console.log(err);
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    console.log("createTag error! Continue.");
    // console.log("createTag error! Abort.");
    // process.exit(1);
    // return;
}
if (createTagRES) {
    console.log("createTagRES:");
    if (DEBUG) console.log(createTagRES);

    const ref2 = `refs/tags/${process.env.TRAVIS_TAG}`;
    const sha = createTagRES.data.sha;

    console.log("################################################");
    console.log("################ createRef:");
    let createRefRES = undefined;
    try {
        createRefRES = await octokit.git.createRef({owner, repo, ref: ref2, sha});
    } catch (err) {
        console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        if (DEBUG) console.log(err);
        console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        console.log("createRef error! Continue.");
        // console.log("createRef error! Abort.");
        // process.exit(1);
        // return;
    }

    if (createRefRES) {
        console.log("createRefRES:");
        if (DEBUG) console.log(createRefRES);
    }
}

const travisURL = process.env.TRAVIS_JOB_WEB_URL || process.env.TRAVIS_BUILD_WEB_URL || (process.env.APPVEYOR_URL ? `${process.env.APPVEYOR_URL}/project/${owner_appveyor}/${repo}/builds/${process.env.APPVEYOR_BUILD_ID}` : `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`);

const tag_name = process.env.TRAVIS_TAG;
const target_commitish = envCommitSha;
const name = `[${tag_name}] continuous test build (prerelease)`;
const body = `CI build job: ${travisURL}`; // gets replaced by Appveyor script anyway
const draft = false;
const prerelease = true;

console.log("################################################");
console.log("################ createRelease:");
let createReleaseRES = undefined;
try {
    createReleaseRES = await octokit.repos.createRelease({owner, repo, tag_name, target_commitish, name, body, draft, prerelease});
} catch (err) {
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    if (DEBUG) console.log(err);
    console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    console.log("createRelease error! Continue.");
    // console.log("createRelease error! Abort.");
    // process.exit(1);
    // return;
}

if (createReleaseRES) {
    console.log("createReleaseRES:");
    // console.log(JSON.stringify(createReleaseRES, null, 4));
    if (DEBUG) console.log(createReleaseRES);
}

if (createReleaseRES && createReleaseRES.data && createReleaseRES.data.id && process.env.GITHUB_SERVER_URL) {

    const upload = async (filename, filepath) => {

        console.log("################################################");
        console.log("################ uploadReleaseAsset: ", filename);
        let uploadReleaseAssetRES = undefined;
        try {
            uploadReleaseAssetRES = await octokit.repos.uploadReleaseAsset({
                owner,
                repo,
                release_id: createReleaseRES.data.id,
                name: filename,
                data: await fs.readFile(filepath)
            });
        } catch (err) {
            console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            if (DEBUG) console.log(err);
            console.log("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            console.log("uploadReleaseAsset error! Continue.");
            // console.log("uploadReleaseAsset error! Abort.");
            // process.exit(1);
            // return;
        }

        if (uploadReleaseAssetRES) {
            console.log("uploadReleaseAssetRES:");
            if (DEBUG) console.log(uploadReleaseAssetRES);
        }
    };

    async function* getFiles(dirpath) {
        const ents = await fs.readdir(dirpath, { withFileTypes: true });
        for (const ent of ents) {
            const fullPath = path.resolve(dirpath, ent.name);
            if (fullPath.indexOf("node_modules") >= 0) {
                continue;
            }
            if (ent.isDirectory()) {
                yield* getFiles(fullPath);
            } else {
                if (fullPath.endsWith('.exe') ||
                    fullPath.endsWith('.AppImage') ||
                    fullPath.endsWith('.deb') ||
                    fullPath.endsWith('.dmg')) {

                    yield fullPath;
                }
            }
        }
    }

    let doneEXE = false;
    let doneAPPIMAGE = false;
    let doneDEB = false;
    let doneDMG = false;
    for await (const f of getFiles('release')) {
        if (f.endsWith('.exe')) {
            if (doneEXE) {
                continue;
            } else {
                doneEXE = true;
            }
        }
        if (f.endsWith('.AppImage')) {
            if (doneAPPIMAGE) {
                continue;
            } else {
                doneAPPIMAGE = true;
            }
        }
        if (f.endsWith('.deb')) {
            if (doneDEB) {
                continue;
            } else {
                doneDEB = true;
            }
        }
        if (f.endsWith('.dmg')) {
            if (doneDMG) {
                continue;
            } else {
                doneDMG = true;
            }
        }
        await upload(path.basename(f), f);
    }
}

})();


text:
<?php

namespace app\commands;

use Curl\Curl;
use Yii;
use app\components\helpers\Battle as BattleHelper;
use app\models\Map2;
use app\models\Rule2;
use app\models\Schedule2;
use app\models\ScheduleMap2;
use app\models\ScheduleMode2;
use stdClass;
use yii\console\Controller;
use yii\helpers\ArrayHelper;
use yii\helpers\Console;
use yii\helpers\Json;

class Splapi2Controller extends Controller
{
    public function actionUpdate(): int
    {
        $json = $this->queryJson('https://splapi2.stat.ink/schedule');
        $transaction = Yii::$app->db->beginTransaction();
        foreach ($json as $modeKey => $json_) {
            if (!$mode = ScheduleMode2::findOne(['key' => $modeKey])) {
                $this->stderr("Unknown mode \"$modeKey\", skip...\n");
                continue;
            }
            $this->stderr('Process ' . $mode->name . "...\n");
            $this->importSchedules($mode, $json_);
        }
        $transaction->commit();
        return 0;
    }

    private function importSchedules(ScheduleMode2 $mode, array $list)
    {
        usort($list, function ($a, $b) {
            return $a->start->unixtime <=> $b->start->unixtime;
        });
        foreach ($list as $schedule) {
            $this->importSchedule($mode, $schedule);
        }
    }

    private function importSchedule(ScheduleMode2 $mode, stdClass $info)
    {
        static $rules; // [ 'nawabari' => 1 ]
        if (!$rules) {
            $rules = ArrayHelper::map(Rule2::find()->asArray()->all(), 'key', 'id');
        }
        static $maps; // [ 'battera' => 1 ]
        if (!$maps) {
            $maps = ArrayHelper::map(Map2::find()->asArray()->all(), 'key', 'id');
        }
        $period = BattleHelper::calcPeriod2($info->start->unixtime);
        if (!$schedule = Schedule2::findOne(['period' => $period, 'mode_id' => $mode->id])) {
            $schedule = Yii::createObject([
                'class' => Schedule2::class,
                'period' => $period,
                'mode_id' => $mode->id,
            ]);
        }
        $schedule->rule_id = $rules[$info->mode->key];
        if ($schedule->isNewRecord || $schedule->dirtyAttributes) {
            if (!$schedule->save()) {
                $this->stderr("Schedule insert/update error at line " . __LINE__ . "\n");
                throw new \Exception();
            }
            echo "Created or updated schedule " . Json::encode($schedule) . "\n";
        }

        $exists = $schedule->getScheduleMaps()->count();
        if ($exists == count($info->stages)) {
            $matches = $schedule->getScheduleMaps()
                ->andWhere(['in', 'map_id', array_map(
                    function (stdClass $stage) use ($maps): int {
                        return $maps[$stage->key];
                    },
                    $info->stages
                )])
                ->count();
            if ($exists == $matches) {
                $this->stderr("Nothing changed. " . Json::encode($schedule) . "\n");
                return;
            }
        }
        $this->stderr("Something changed (or new schedule) " . Json::encode($schedule) . "\n");
        ScheduleMap2::deleteAll(['schedule_id' => $schedule->id]);
        foreach ($info->stages as $st) {
            $stage = Yii::createObject([
                'class' => ScheduleMap2::class,
                'schedule_id' => $schedule->id,
                'map_id' => $maps[$st->key],
            ]);
            if (!$stage->save()) {
                $this->stderr('Could not insert to schedule_map2. ' . Json::encode($stage) . "\n");
                throw new \Exception();
            }
        }
        $this->stderr("  => updated\n");
    }

    private function queryJson(string $url, array $data = [])
    {
        echo "Querying {$url} ...\n";
        $curl = new Curl();
        $curl->setUserAgent(sprintf(
            '%s/%s (+%s)',
            'stat.ink',
            Yii::$app->version,
            'https://github.com/fetus-hina/stat.ink'
        ));
        $curl->get($url, $data);
        if ($curl->error) {
            throw new \Exception("Request failed: url={$url}, code={$curl->errorCode}, msg={$curl->errorMessage}");
        }
        return Json::decode($curl->rawResponse, false);
    }
}


text:
package com.gs.obevocomparer.config;

public class DatabaseConfig extends DataSourceConfig {

    private static final long serialVersionUID = -4631143656309716907L;

    private String user;

    private String password;

    private String url;

    private String query;

    public DatabaseConfig() {
        super("noname");
    }

    public DatabaseConfig(String name, String user, String password,
            String url, String query) {
        super(name);
        this.setUser(user);
        this.setPassword(password);
        this.setURL(url);
        this.setQuery(query);
    }

    public String getQuery() {
        return this.query;
    }

    public void setQuery(String query) {
        this.query = query;
    }

    public String getUser() {
        return this.user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getURL() {
        return this.url;
    }

    public void setURL(String url) {
        this.url = url;
    }

    @Override
    public String toString() {
        return "Name - " + this.getName() + ", User - " + this.user + ", URL - " + this.url + ", Query - " + this.query;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        DatabaseConfig cloneConfig = new DatabaseConfig("Copy of " + this.getName(), this.user, this.password, this.url, this.query);
        cloneConfig.setSorted(this.getSorted());
        return cloneConfig;
    }
}