SURF Reference Implementation
GlobalMentor, Inc. provides a reference implementation of SURF in Java, with both a SURF parser and a SURF serializer included.
- Source Code
- https://bitbucket.org/globalmentor/urf-surf
- Issues
- https://globalmentor.atlassian.net/projects/URF
- Maven
io.urf:surf
SURF Parser
1. Include SURF Parser Dependency
Include the appropriate SURF dependency from Maven by adding io.urf:surf:x.x.x
to your POM.
2. Make a SURF File
Here is an example SURF file storing the definition of a user. SURF documents are stored in files using the UTF-8 charset with no BOM.
3. Use a SurfParser
Create an instance of io.urf.surf.SurfParser
and call one of its SurfParser.parse(…)
methods.
4. Access SURF Data
The returned SURF data will be one of the following, based upon the root resource in the file:
Optional.empty()
if the file was empty.- A value object (e.g.
java.lang.Integer
) if the root resource was a SURF literal. - A implementation of a collection type (e.g.
java.util.Set<>
) if the root resource was a SURF collection. - An instance of
SurfObject
if the root resource was a SURF object.
SURF Serializer
1. Include SURF Serializer Dependency
Include the appropriate SURF dependency from Maven by adding io.urf:surf:x.x.x
to your POM.
2. Create a SurfObject
Create an instance of io.urf.surf.SurfObject
to represent the object to serialize. You can optionally give the object a tag IRI and/or a type string.
3. Use a SurfSerializer
Create an instance of io.urf.surf.SurfSerializer
and call one of its SurfSerializer.serialize(…)
methods.