org.apache.maven.plugin.doap
Class DoapUtil

java.lang.Object
  extended by org.apache.maven.plugin.doap.DoapUtil

public class DoapUtil
extends Object

Utility class for DoapMojo class.

Since:
1.0
Version:
$Id: DoapUtil.html 815337 2012-05-01 21:52:10Z hboutemy $
Author:
Vincent Siveton

Nested Class Summary
static class DoapUtil.Organization
          Utility class for keeping track of DOAP organizations in the DoaP mojo.
 
Field Summary
static int DEFAULT_TIMEOUT
          The default timeout used when fetching url, i.e. 2000.
protected static String RDF_NODE_ID
          RDF nodeID attribute
protected static String RDF_RESOURCE
          RDF resource attribute
 
Constructor Summary
DoapUtil()
           
 
Method Summary
static DoapUtil.Organization addOrganization(String name, String url)
          put an organization from the pom file in the organization list.
static void fetchURL(org.apache.maven.settings.Settings settings, URL url)
          Fetch an URL
static List<org.apache.maven.model.Contributor> getContributorsWithDeveloperRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static List<org.apache.maven.model.Contributor> getContributorsWithDocumenterRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static List<org.apache.maven.model.Contributor> getContributorsWithHelperRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static List<org.apache.maven.model.Contributor> getContributorsWithMaintainerRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static List<org.apache.maven.model.Contributor> getContributorsWithTesterRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static List<org.apache.maven.model.Contributor> getContributorsWithTranslatorRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static List<org.apache.maven.model.Contributor> getContributorsWithUnknownRole(org.codehaus.plexus.i18n.I18N i18n, List<org.apache.maven.model.Contributor> developersOrContributors)
           
static String getNodeId()
          get a unique (within the DoaP file) RDF blank node ID
static Set<Map.Entry<String,DoapUtil.Organization>> getOrganizations()
          get the set of Organizations that people are members of
static String interpolate(String value, org.apache.maven.project.MavenProject project, org.apache.maven.settings.Settings settings)
          Interpolate a string with project and settings.
static boolean isValidEmail(String str)
           
static List<String> validate(File doapFile)
          Validate the given DOAP file.
static void writeComment(XMLWriter writer, String comment)
          Write comment.
static void writeElement(XMLWriter writer, String xmlnsPrefix, String name, String value)
           
static void writeElement(XMLWriter writer, String xmlnsPrefix, String name, String value, String lang)
           
static void writeHeader(XMLWriter writer)
          Write comments in the DOAP file header
static void writeRdfNodeIdElement(XMLWriter writer, String xmlnsPrefix, String name, String value)
           
static void writeRdfResourceElement(XMLWriter writer, String xmlnsPrefix, String name, String value)
           
static void writeStartElement(XMLWriter writer, String xmlnsPrefix, String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
The default timeout used when fetching url, i.e. 2000.

See Also:
Constant Field Values

RDF_RESOURCE

protected static final String RDF_RESOURCE
RDF resource attribute

See Also:
Constant Field Values

RDF_NODE_ID

protected static final String RDF_NODE_ID
RDF nodeID attribute

See Also:
Constant Field Values
Constructor Detail

DoapUtil

public DoapUtil()
Method Detail

writeHeader

public static void writeHeader(XMLWriter writer)
Write comments in the DOAP file header

Parameters:
writer - not null

writeComment

public static void writeComment(XMLWriter writer,
                                String comment)
                         throws IllegalArgumentException
Write comment.

Parameters:
writer - not null
comment - not null
Throws:
IllegalArgumentException - if comment is null or empty
Since:
1.1

writeElement

public static void writeElement(XMLWriter writer,
                                String xmlnsPrefix,
                                String name,
                                String value)
                         throws IllegalArgumentException
Parameters:
writer - not null
xmlnsPrefix - could be null
name - not null
value - could be null. In this case, the element is not written.
Throws:
IllegalArgumentException - if name is null or empty

writeElement

public static void writeElement(XMLWriter writer,
                                String xmlnsPrefix,
                                String name,
                                String value,
                                String lang)
                         throws IllegalArgumentException
Parameters:
writer - not null
xmlnsPrefix - could be null
name - not null
lang - not null
value - could be null. In this case, the element is not written.
Throws:
IllegalArgumentException - if name is null or empty

writeStartElement

public static void writeStartElement(XMLWriter writer,
                                     String xmlnsPrefix,
                                     String name)
                              throws IllegalArgumentException
Parameters:
writer - not null
xmlnsPrefix - could be null
name - not null
Throws:
IllegalArgumentException - if name is null or empty
Since:
1.1

writeRdfResourceElement

public static void writeRdfResourceElement(XMLWriter writer,
                                           String xmlnsPrefix,
                                           String name,
                                           String value)
                                    throws IllegalArgumentException
Parameters:
writer - not null
xmlnsPrefix - could be null
name - not null
value - could be null. In this case, the element is not written.
Throws:
IllegalArgumentException - if name is null or empty

writeRdfNodeIdElement

public static void writeRdfNodeIdElement(XMLWriter writer,
                                         String xmlnsPrefix,
                                         String name,
                                         String value)
                                  throws IllegalArgumentException
Parameters:
writer - not null
name - not null
value - could be null. In this case, the element is not written.
Throws:
IllegalArgumentException - if name is null or empty

getContributorsWithDeveloperRole

public static List<org.apache.maven.model.Contributor> getContributorsWithDeveloperRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                        List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have a developer DOAP role.

getContributorsWithDocumenterRole

public static List<org.apache.maven.model.Contributor> getContributorsWithDocumenterRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                         List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have a documenter DOAP role.

getContributorsWithHelperRole

public static List<org.apache.maven.model.Contributor> getContributorsWithHelperRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                     List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have an helper DOAP role.

getContributorsWithMaintainerRole

public static List<org.apache.maven.model.Contributor> getContributorsWithMaintainerRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                         List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have a maintainer DOAP role.

getContributorsWithTesterRole

public static List<org.apache.maven.model.Contributor> getContributorsWithTesterRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                     List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have a tester DOAP role.

getContributorsWithTranslatorRole

public static List<org.apache.maven.model.Contributor> getContributorsWithTranslatorRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                         List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have a translator DOAP role.

getContributorsWithUnknownRole

public static List<org.apache.maven.model.Contributor> getContributorsWithUnknownRole(org.codehaus.plexus.i18n.I18N i18n,
                                                                                      List<org.apache.maven.model.Contributor> developersOrContributors)
Parameters:
i18n - the internationalization component
developersOrContributors - list of Contributor
Returns:
a none null list of Contributor which have an unknown DOAP role.

addOrganization

public static DoapUtil.Organization addOrganization(String name,
                                                    String url)
put an organization from the pom file in the organization list.

Parameters:
name - from the pom file (e.g. Yoyodyne)
url - from the pom file (e.g. http://yoyodyne.example.org/about)
Returns:
the existing organization if a duplicate, or a new one.

getNodeId

public static String getNodeId()
get a unique (within the DoaP file) RDF blank node ID

Returns:
the nodeID
See Also:
http://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-blank-nodes

getOrganizations

public static Set<Map.Entry<String,DoapUtil.Organization>> getOrganizations()
get the set of Organizations that people are members of

Returns:
Map.EntrySet of DoapUtil.Organization

validate

public static List<String> validate(File doapFile)
Validate the given DOAP file.

Parameters:
doapFile - not null and should exists.
Returns:
an empty list if the DOAP file is valid, otherwise a list of errors.
Since:
1.1

isValidEmail

public static boolean isValidEmail(String str)
Parameters:
str - not null
Returns:
true if the str parameter is a valid email, false otherwise.
Since:
1.1

fetchURL

public static void fetchURL(org.apache.maven.settings.Settings settings,
                            URL url)
                     throws IOException
Fetch an URL

Parameters:
settings - the user settings used to fetch the url with an active proxy, if defined.
url - the url to fetch
Throws:
IOException - if any
Since:
1.1
See Also:
DEFAULT_TIMEOUT

interpolate

public static String interpolate(String value,
                                 org.apache.maven.project.MavenProject project,
                                 org.apache.maven.settings.Settings settings)
Interpolate a string with project and settings.

Parameters:
value - could be null
project - not null
settings - could be null
Returns:
the value trimmed and interpolated or null if the interpolation doesn't work.
Since:
1.1


Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.