This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch nomdo in repository https://gitbox.apache.org/repos/asf/maven-doxia-linkcheck.git
commit 6ef64f51afb1348ef7b137ec2b50c76d776bfd47 Author: Elliotte Rusty Harold <[email protected]> AuthorDate: Mon May 31 06:54:03 2021 -0400 remove dependency on Modello --- pom.xml | 36 - .../org/apache/maven/doxia/linkcheck/HttpBean.java | 484 ++++++++++++ .../maven/doxia/linkcheck/model/LinkcheckFile.java | 340 ++++++++ .../doxia/linkcheck/model/LinkcheckFileResult.java | 246 ++++++ .../doxia/linkcheck/model/LinkcheckModel.java | 173 +++++ .../model/io/xpp3/LinkcheckModelXpp3Reader.java | 859 +++++++++++++++++++++ .../model/io/xpp3/LinkcheckModelXpp3Writer.java | 200 +++++ src/main/mdo/httpbean.mdo | 173 ----- src/main/mdo/linkcheck.mdo | 274 ------- 9 files changed, 2302 insertions(+), 483 deletions(-) diff --git a/pom.xml b/pom.xml index 205bcaf..3942b8b 100644 --- a/pom.xml +++ b/pom.xml @@ -112,41 +112,5 @@ under the License. </plugin> </plugins> </pluginManagement> - <plugins> - <plugin> - <groupId>org.codehaus.modello</groupId> - <artifactId>modello-maven-plugin</artifactId> - <executions> - <execution> - <id>linkcheck</id> - <phase>generate-sources</phase> - <goals> - <goal>java</goal> - <goal>xpp3-reader</goal> - <goal>xpp3-writer</goal> - </goals> - <configuration> - <models> - <model>src/main/mdo/linkcheck.mdo</model> - </models> - <version>1.0.0</version> - </configuration> - </execution> - <execution> - <id>httpbean</id> - <phase>generate-sources</phase> - <goals> - <goal>java</goal> - </goals> - <configuration> - <models> - <model>src/main/mdo/httpbean.mdo</model> - </models> - <version>1.0.0</version> - </configuration> - </execution> - </executions> - </plugin> - </plugins> </build> </project> \ No newline at end of file diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/HttpBean.java b/src/main/java/org/apache/maven/doxia/linkcheck/HttpBean.java new file mode 100644 index 0000000..21112fc --- /dev/null +++ b/src/main/java/org/apache/maven/doxia/linkcheck/HttpBean.java @@ -0,0 +1,484 @@ +package org.apache.maven.doxia.linkcheck; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Http bean to encapsulate the supported HTTP parameters. + * @see org.apache.commons.httpclient.HttpMethod. + * + * @version $Revision$ $Date$ + */ +@SuppressWarnings( "all" ) +public class HttpBean + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * + * The HTTP method to use. Currently supported are "GET" + * and "HEAD". + * <dl> + * <dt>HTTP GET</dt> + * <dd> + * The HTTP GET method is defined in section 9.3 of + * <a + * HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: + * <blockquote> + * The GET method means retrieve whatever information (in + * the form of an + * entity) is identified by the Request-URI. + * </blockquote> + * </dd> + * <dt>HTTP HEAD</dt> + * <dd> + * The HTTP HEAD method is defined in section 9.4 of + * <a + * HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: + * <blockquote> + * The HEAD method is identical to GET except that the + * server MUST NOT + * return a message-body in the response. + * </blockquote> + * </dd> + * </dl> + */ + private String method = "head"; + + /** + * + * if the HTTP method should automatically follow HTTP + * redirects + * (status code 302, etc.), <tt>false</tt> otherwise. + */ + private boolean followRedirects = false; + + /** + * The proxy host. + */ + private String proxyHost; + + /** + * The proxy port. + */ + private int proxyPort = 0; + + /** + * The proxy user. + */ + private String proxyUser; + + /** + * The proxy password. + */ + private String proxyPassword; + + /** + * The proxy NTLM (NT Lan Manager) host. + */ + private String proxyNtlmHost; + + /** + * The proxy NTLM (NT Lan Manager) domain. + */ + private String proxyNtlmDomain; + + /** + * The timeout to be used. A value of zero means the timeout is + * not used. + * Default value is 2000. + */ + private int timeout = 2000; + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method equals. + * + * @param other + * @return boolean + */ + public boolean equals( Object other ) + { + if ( this == other ) + { + return true; + } + + if ( !( other instanceof HttpBean ) ) + { + return false; + } + + HttpBean that = (HttpBean) other; + boolean result = true; + + result = result && ( getMethod() == null ? that.getMethod() == null : getMethod().equals( that.getMethod() ) ); + result = result && followRedirects == that.followRedirects; + result = result && ( getProxyHost() == null ? that.getProxyHost() == null : getProxyHost().equals( that.getProxyHost() ) ); + result = result && proxyPort == that.proxyPort; + result = result && ( getProxyUser() == null ? that.getProxyUser() == null : getProxyUser().equals( that.getProxyUser() ) ); + result = result && ( getProxyPassword() == null ? that.getProxyPassword() == null : getProxyPassword().equals( that.getProxyPassword() ) ); + result = result && ( getProxyNtlmHost() == null ? that.getProxyNtlmHost() == null : getProxyNtlmHost().equals( that.getProxyNtlmHost() ) ); + result = result && ( getProxyNtlmDomain() == null ? that.getProxyNtlmDomain() == null : getProxyNtlmDomain().equals( that.getProxyNtlmDomain() ) ); + result = result && timeout == that.timeout; + + return result; + } //-- boolean equals( Object ) + + /** + * Get the HTTP method to use. Currently supported are "GET" + * and "HEAD". + * <dl> + * <dt>HTTP GET</dt> + * <dd> + * The HTTP GET method is defined in section 9.3 of + * <a + * HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: + * <blockquote> + * The GET method means retrieve whatever information (in + * the form of an + * entity) is identified by the Request-URI. + * </blockquote> + * </dd> + * <dt>HTTP HEAD</dt> + * <dd> + * The HTTP HEAD method is defined in section 9.4 of + * <a + * HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: + * <blockquote> + * The HEAD method is identical to GET except that the + * server MUST NOT + * return a message-body in the response. + * </blockquote> + * </dd> + * </dl> + * + * @return String + */ + public String getMethod() + { + return this.method; + } //-- String getMethod() + + /** + * Get the proxy host. + * + * @return String + */ + public String getProxyHost() + { + return this.proxyHost; + } //-- String getProxyHost() + + /** + * Get the proxy NTLM (NT Lan Manager) domain. + * + * @return String + */ + public String getProxyNtlmDomain() + { + return this.proxyNtlmDomain; + } //-- String getProxyNtlmDomain() + + /** + * Get the proxy NTLM (NT Lan Manager) host. + * + * @return String + */ + public String getProxyNtlmHost() + { + return this.proxyNtlmHost; + } //-- String getProxyNtlmHost() + + /** + * Get the proxy password. + * + * @return String + */ + public String getProxyPassword() + { + return this.proxyPassword; + } //-- String getProxyPassword() + + /** + * Get the proxy port. + * + * @return int + */ + public int getProxyPort() + { + return this.proxyPort; + } //-- int getProxyPort() + + /** + * Get the proxy user. + * + * @return String + */ + public String getProxyUser() + { + return this.proxyUser; + } //-- String getProxyUser() + + /** + * Get the timeout to be used. A value of zero means the + * timeout is not used. + * Default value is 2000. + * + * @return int + */ + public int getTimeout() + { + return this.timeout; + } //-- int getTimeout() + + /** + * Method hashCode. + * + * @return int + */ + public int hashCode() + { + int result = 17; + + result = 37 * result + ( method != null ? method.hashCode() : 0 ); + result = 37 * result + ( followRedirects ? 0 : 1 ); + result = 37 * result + ( proxyHost != null ? proxyHost.hashCode() : 0 ); + result = 37 * result + (int) proxyPort; + result = 37 * result + ( proxyUser != null ? proxyUser.hashCode() : 0 ); + result = 37 * result + ( proxyPassword != null ? proxyPassword.hashCode() : 0 ); + result = 37 * result + ( proxyNtlmHost != null ? proxyNtlmHost.hashCode() : 0 ); + result = 37 * result + ( proxyNtlmDomain != null ? proxyNtlmDomain.hashCode() : 0 ); + result = 37 * result + (int) timeout; + + return result; + } //-- int hashCode() + + /** + * Get if the HTTP method should automatically follow HTTP + * redirects + * (status code 302, etc.), <tt>false</tt> otherwise. + * + * @return boolean + */ + public boolean isFollowRedirects() + { + return this.followRedirects; + } //-- boolean isFollowRedirects() + + /** + * Set if the HTTP method should automatically follow HTTP + * redirects + * (status code 302, etc.), <tt>false</tt> otherwise. + * + * @param followRedirects + */ + public void setFollowRedirects( boolean followRedirects ) + { + this.followRedirects = followRedirects; + } //-- void setFollowRedirects( boolean ) + + /** + * Set the HTTP method to use. Currently supported are "GET" + * and "HEAD". + * <dl> + * <dt>HTTP GET</dt> + * <dd> + * The HTTP GET method is defined in section 9.3 of + * <a + * HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: + * <blockquote> + * The GET method means retrieve whatever information (in + * the form of an + * entity) is identified by the Request-URI. + * </blockquote> + * </dd> + * <dt>HTTP HEAD</dt> + * <dd> + * The HTTP HEAD method is defined in section 9.4 of + * <a + * HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: + * <blockquote> + * The HEAD method is identical to GET except that the + * server MUST NOT + * return a message-body in the response. + * </blockquote> + * </dd> + * </dl> + * + * @param method + */ + public void setMethod( String method ) + { + this.method = method; + } //-- void setMethod( String ) + + /** + * Set the proxy host. + * + * @param proxyHost + */ + public void setProxyHost( String proxyHost ) + { + this.proxyHost = proxyHost; + } //-- void setProxyHost( String ) + + /** + * Set the proxy NTLM (NT Lan Manager) domain. + * + * @param proxyNtlmDomain + */ + public void setProxyNtlmDomain( String proxyNtlmDomain ) + { + this.proxyNtlmDomain = proxyNtlmDomain; + } //-- void setProxyNtlmDomain( String ) + + /** + * Set the proxy NTLM (NT Lan Manager) host. + * + * @param proxyNtlmHost + */ + public void setProxyNtlmHost( String proxyNtlmHost ) + { + this.proxyNtlmHost = proxyNtlmHost; + } //-- void setProxyNtlmHost( String ) + + /** + * Set the proxy password. + * + * @param proxyPassword + */ + public void setProxyPassword( String proxyPassword ) + { + this.proxyPassword = proxyPassword; + } //-- void setProxyPassword( String ) + + /** + * Set the proxy port. + * + * @param proxyPort + */ + public void setProxyPort( int proxyPort ) + { + this.proxyPort = proxyPort; + } //-- void setProxyPort( int ) + + /** + * Set the proxy user. + * + * @param proxyUser + */ + public void setProxyUser( String proxyUser ) + { + this.proxyUser = proxyUser; + } //-- void setProxyUser( String ) + + /** + * Method toString. + * + * @return String + */ + public java.lang.String toString() + { + StringBuilder buf = new StringBuilder( 128 ); + + buf.append( "method = '" ); + buf.append( getMethod() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "followRedirects = '" ); + buf.append( isFollowRedirects() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "proxyHost = '" ); + buf.append( getProxyHost() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "proxyPort = '" ); + buf.append( getProxyPort() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "proxyUser = '" ); + buf.append( getProxyUser() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "proxyPassword = '" ); + buf.append( getProxyPassword() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "proxyNtlmHost = '" ); + buf.append( getProxyNtlmHost() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "proxyNtlmDomain = '" ); + buf.append( getProxyNtlmDomain() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "timeout = '" ); + buf.append( getTimeout() ); + buf.append( "'" ); + + return buf.toString(); + } //-- java.lang.String toString() + + + + /** + * Set the timeout to be used. A value of zero means the timeout is not used. + * + * @param timeout positive int + */ + public void setTimeout( int timeout ) + { + if ( timeout < 0 ) + { + throw new IllegalArgumentException( timeout + " should be 0 or positive." ); + } + this.timeout = timeout; + } + + private java.util.Properties httpClientParameters; + + /** + * @return the extra HttpClient parameters + * @see http://hc.apache.org/httpclient-3.x/preference-api.html + */ + public java.util.Properties getHttpClientParameters() + { + return httpClientParameters; + } + + /** + * @param httpClientParameters the extra HttpClient parameters to set + * @see http://hc.apache.org/httpclient-3.x/preference-api.html + */ + public void setHttpClientParameters( java.util.Properties httpClientParameters ) + { + this.httpClientParameters = httpClientParameters; + } + +} diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckFile.java b/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckFile.java new file mode 100644 index 0000000..dba2213 --- /dev/null +++ b/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckFile.java @@ -0,0 +1,340 @@ +package org.apache.maven.doxia.linkcheck.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * + * The <code><file></code> to be checked. + * + * + * @version $Revision$ $Date$ + */ +@SuppressWarnings( "all" ) +public class LinkcheckFile + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * + * The file to check as String Object. + * + */ + private String absolutePath; + + /** + * + * The relative path of the file. + * + */ + private String relativePath; + + /** + * + * The number of successful links in this file. + * + */ + private int successful = -1; + + /** + * + * The number of unsuccessful links in this file. + * + */ + private int unsuccessful = -1; + + /** + * Field results. + */ + private java.util.List<LinkcheckFileResult> results; + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addResult. + * + * @param linkcheckFileResult + */ + public void addResult( LinkcheckFileResult linkcheckFileResult ) + { + getResults().add( linkcheckFileResult ); + } //-- void addResult( LinkcheckFileResult ) + + /** + * Method equals. + * + * @param other + * @return boolean + */ + public boolean equals( Object other ) + { + if ( this == other ) + { + return true; + } + + if ( !( other instanceof LinkcheckFile ) ) + { + return false; + } + + LinkcheckFile that = (LinkcheckFile) other; + boolean result = true; + + result = result && ( getAbsolutePath() == null ? that.getAbsolutePath() == null : getAbsolutePath().equals( that.getAbsolutePath() ) ); + result = result && ( getRelativePath() == null ? that.getRelativePath() == null : getRelativePath().equals( that.getRelativePath() ) ); + result = result && successful == that.successful; + result = result && unsuccessful == that.unsuccessful; + result = result && ( getResults() == null ? that.getResults() == null : getResults().equals( that.getResults() ) ); + + return result; + } //-- boolean equals( Object ) + + /** + * Get the file to check as String Object. + * + * @return String + */ + public String getAbsolutePath() + { + return this.absolutePath; + } //-- String getAbsolutePath() + + /** + * Get the relative path of the file. + * + * @return String + */ + public String getRelativePath() + { + return this.relativePath; + } //-- String getRelativePath() + + /** + * Method getResults. + * + * @return List + */ + public java.util.List<LinkcheckFileResult> getResults() + { + if ( this.results == null ) + { + this.results = new java.util.ArrayList<LinkcheckFileResult>(); + } + + return this.results; + } //-- java.util.List<LinkcheckFileResult> getResults() + + /** + * Get the number of successful links in this file. + * + * @return int + */ + public int getSuccessful() + { + return this.successful; + } //-- int getSuccessful() + + /** + * Get the number of unsuccessful links in this file. + * + * @return int + */ + public int getUnsuccessful() + { + return this.unsuccessful; + } //-- int getUnsuccessful() + + /** + * Method hashCode. + * + * @return int + */ + public int hashCode() + { + int result = 17; + + result = 37 * result + ( absolutePath != null ? absolutePath.hashCode() : 0 ); + result = 37 * result + ( relativePath != null ? relativePath.hashCode() : 0 ); + result = 37 * result + (int) successful; + result = 37 * result + (int) unsuccessful; + result = 37 * result + ( results != null ? results.hashCode() : 0 ); + + return result; + } //-- int hashCode() + + /** + * Method removeResult. + * + * @param linkcheckFileResult + */ + public void removeResult( LinkcheckFileResult linkcheckFileResult ) + { + getResults().remove( linkcheckFileResult ); + } //-- void removeResult( LinkcheckFileResult ) + + /** + * Set the file to check as String Object. + * + * @param absolutePath + */ + public void setAbsolutePath( String absolutePath ) + { + this.absolutePath = absolutePath; + } //-- void setAbsolutePath( String ) + + /** + * Set the relative path of the file. + * + * @param relativePath + */ + public void setRelativePath( String relativePath ) + { + this.relativePath = relativePath; + } //-- void setRelativePath( String ) + + /** + * Set all error details in this file. + * + * @param results + */ + public void setResults( java.util.List<LinkcheckFileResult> results ) + { + this.results = results; + } //-- void setResults( java.util.List ) + + /** + * Set the number of successful links in this file. + * + * @param successful + */ + public void setSuccessful( int successful ) + { + this.successful = successful; + } //-- void setSuccessful( int ) + + /** + * Set the number of unsuccessful links in this file. + * + * @param unsuccessful + */ + public void setUnsuccessful( int unsuccessful ) + { + this.unsuccessful = unsuccessful; + } //-- void setUnsuccessful( int ) + + /** + * Method toString. + * + * @return String + */ + public java.lang.String toString() + { + StringBuilder buf = new StringBuilder( 128 ); + + buf.append( "absolutePath = '" ); + buf.append( getAbsolutePath() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "relativePath = '" ); + buf.append( getRelativePath() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "successful = '" ); + buf.append( getSuccessful() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "unsuccessful = '" ); + buf.append( getUnsuccessful() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "results = '" ); + buf.append( getResults() ); + buf.append( "'" ); + + return buf.toString(); + } //-- java.lang.String toString() + + + + /** + * Get the number of links for this file depending the level wanted. + * + * {@link LinkcheckFileResult#ERROR_LEVEL} + * {@link LinkcheckFileResult#UNKNOWN_LEVEL} + * {@link LinkcheckFileResult#VALID_LEVEL} + * {@link LinkcheckFileResult#WARNING_LEVEL} + * + * @param level the restricted level + * @return the number of links for the restrict level, -1 if the level is not a valid one + * or no results was found. + * @throws UnsupportedOperationException if the level is unsupported. + */ + public int getNumberOfLinks( int level ) + { + if ( results == null ) + { + return -1; + } + + if ( !( level == LinkcheckFileResult.ERROR_LEVEL || level == LinkcheckFileResult.WARNING_LEVEL + || level == LinkcheckFileResult.VALID_LEVEL || level == LinkcheckFileResult.UNKNOWN_LEVEL ) ) + { + throw new UnsupportedOperationException( "This level [" + level + "] is unsupported." ); + } + + int number = 0; + for ( java.util.Iterator it = results.iterator(); it.hasNext(); ) + { + LinkcheckFileResult linkcheckFileResult = (LinkcheckFileResult) it.next(); + + if ( linkcheckFileResult.getStatusLevel() == level ) + { + number++; + } + } + + return number; + } + + /** + * Get the number of links for this file. + * + * @param level + * @return + */ + public int getNumberOfLinks() + { + if ( results == null ) + { + return -1; + } + + return results.size(); + } + + +} diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckFileResult.java b/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckFileResult.java new file mode 100644 index 0000000..f7c1b30 --- /dev/null +++ b/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckFileResult.java @@ -0,0 +1,246 @@ +package org.apache.maven.doxia.linkcheck.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * + * A class containing the results of a single check of a link. + * + * @version $Revision$ $Date$ + */ +@SuppressWarnings( "all" ) +public class LinkcheckFileResult + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * + * The target URL. + * + */ + private String target; + + /** + * + * The status. + * + */ + private String status; + + /** + * + * The error message. + * + */ + private String errorMessage; + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method equals. + * + * @param other + * @return boolean + */ + public boolean equals( Object other ) + { + if ( this == other ) + { + return true; + } + + if ( !( other instanceof LinkcheckFileResult ) ) + { + return false; + } + + LinkcheckFileResult that = (LinkcheckFileResult) other; + boolean result = true; + + result = result && ( getTarget() == null ? that.getTarget() == null : getTarget().equals( that.getTarget() ) ); + result = result && ( getStatus() == null ? that.getStatus() == null : getStatus().equals( that.getStatus() ) ); + result = result && ( getErrorMessage() == null ? that.getErrorMessage() == null : getErrorMessage().equals( that.getErrorMessage() ) ); + + return result; + } //-- boolean equals( Object ) + + /** + * Get the error message. + * + * @return String + */ + public String getErrorMessage() + { + return this.errorMessage; + } //-- String getErrorMessage() + + /** + * Get the status. + * + * @return String + */ + public String getStatus() + { + return this.status; + } //-- String getStatus() + + /** + * Get the target URL. + * + * @return String + */ + public String getTarget() + { + return this.target; + } //-- String getTarget() + + /** + * Method hashCode. + * + * @return int + */ + public int hashCode() + { + int result = 17; + + result = 37 * result + ( target != null ? target.hashCode() : 0 ); + result = 37 * result + ( status != null ? status.hashCode() : 0 ); + result = 37 * result + ( errorMessage != null ? errorMessage.hashCode() : 0 ); + + return result; + } //-- int hashCode() + + /** + * Set the error message. + * + * @param errorMessage + */ + public void setErrorMessage( String errorMessage ) + { + this.errorMessage = errorMessage; + } //-- void setErrorMessage( String ) + + /** + * Set the status. + * + * @param status + */ + public void setStatus( String status ) + { + this.status = status; + } //-- void setStatus( String ) + + /** + * Set the target URL. + * + * @param target + */ + public void setTarget( String target ) + { + this.target = target; + } //-- void setTarget( String ) + + /** + * Method toString. + * + * @return String + */ + public java.lang.String toString() + { + StringBuilder buf = new StringBuilder( 128 ); + + buf.append( "target = '" ); + buf.append( getTarget() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "status = '" ); + buf.append( getStatus() ); + buf.append( "'" ); + buf.append( "\n" ); + buf.append( "errorMessage = '" ); + buf.append( getErrorMessage() ); + buf.append( "'" ); + + return buf.toString(); + } //-- java.lang.String toString() + + + + /** The vm line separator. */ + private static final String EOL = System.getProperty( "line.separator" ); + + /** Validation result level: error. */ + public static final int ERROR_LEVEL = 1; + + /** Validation result level: warning. */ + public static final int WARNING_LEVEL = 2; + + /** Validation result level: valid. */ + public static final int VALID_LEVEL = 3; + + /** Validation result level: unknown. */ + public static final int UNKNOWN_LEVEL = 4; + + /** Validation result: error. */ + public static final String ERROR = "error"; + + /** Validation result: warning. */ + public static final String WARNING = "warning"; + + /** Validation result: valid. */ + public static final String VALID = "valid"; + + /** Validation result: unknown. */ + public static final String UNKNOWN = "unknown"; + + /** + * Returns the status as an integer. + * + * @return One of ERROR, WARNING, VALID or UNKNOWN. + */ + public int getStatusLevel() + { + int level = UNKNOWN_LEVEL; + + if ( VALID.equals( getStatus() ) ) + { + level = VALID_LEVEL; + } + else if ( WARNING.equals( getStatus() ) ) + { + level = WARNING_LEVEL; + } + else if ( ERROR.equals( getStatus() ) ) + { + level = ERROR_LEVEL; + } + + return level; + } + + +} diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckModel.java b/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckModel.java new file mode 100644 index 0000000..19c9a8b --- /dev/null +++ b/src/main/java/org/apache/maven/doxia/linkcheck/model/LinkcheckModel.java @@ -0,0 +1,173 @@ +package org.apache.maven.doxia.linkcheck.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * + * The <code><linkcheck></code> element is the root of the linkcheck descriptor. + * + * @version $Revision$ $Date$ + */ +@SuppressWarnings( "all" ) +public class LinkcheckModel + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field files. + */ + private java.util.List<LinkcheckFile> files; + + /** + * Field modelEncoding. + */ + private String modelEncoding = "UTF-8"; + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addFile. + * + * @param linkcheckFile + */ + public void addFile( LinkcheckFile linkcheckFile ) + { + getFiles().add( linkcheckFile ); + } //-- void addFile( LinkcheckFile ) + + /** + * Method equals. + * + * @param other + * @return boolean + */ + public boolean equals( Object other ) + { + if ( this == other ) + { + return true; + } + + if ( !( other instanceof LinkcheckModel ) ) + { + return false; + } + + LinkcheckModel that = (LinkcheckModel) other; + boolean result = true; + + result = result && ( getFiles() == null ? that.getFiles() == null : getFiles().equals( that.getFiles() ) ); + + return result; + } //-- boolean equals( Object ) + + /** + * Method getFiles. + * + * @return List + */ + public java.util.List<LinkcheckFile> getFiles() + { + if ( this.files == null ) + { + this.files = new java.util.ArrayList<LinkcheckFile>(); + } + + return this.files; + } //-- java.util.List<LinkcheckFile> getFiles() + + /** + * Get the modelEncoding field. + * + * @return String + */ + public String getModelEncoding() + { + return this.modelEncoding; + } //-- String getModelEncoding() + + /** + * Method hashCode. + * + * @return int + */ + public int hashCode() + { + int result = 17; + + result = 37 * result + ( files != null ? files.hashCode() : 0 ); + + return result; + } //-- int hashCode() + + /** + * Method removeFile. + * + * @param linkcheckFile + */ + public void removeFile( LinkcheckFile linkcheckFile ) + { + getFiles().remove( linkcheckFile ); + } //-- void removeFile( LinkcheckFile ) + + /** + * Set list of <code><file></code> elements. + * + * @param files + */ + public void setFiles( java.util.List<LinkcheckFile> files ) + { + this.files = files; + } //-- void setFiles( java.util.List ) + + /** + * Set the modelEncoding field. + * + * @param modelEncoding + */ + public void setModelEncoding( String modelEncoding ) + { + this.modelEncoding = modelEncoding; + } //-- void setModelEncoding( String ) + + /** + * Method toString. + * + * @return String + */ + public java.lang.String toString() + { + StringBuilder buf = new StringBuilder( 128 ); + + buf.append( "files = '" ); + buf.append( getFiles() ); + buf.append( "'" ); + + return buf.toString(); + } //-- java.lang.String toString() + +} diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/model/io/xpp3/LinkcheckModelXpp3Reader.java b/src/main/java/org/apache/maven/doxia/linkcheck/model/io/xpp3/LinkcheckModelXpp3Reader.java new file mode 100644 index 0000000..831c576 --- /dev/null +++ b/src/main/java/org/apache/maven/doxia/linkcheck/model/io/xpp3/LinkcheckModelXpp3Reader.java @@ -0,0 +1,859 @@ +package org.apache.maven.doxia.linkcheck.model.io.xpp3; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.text.DateFormat; +import org.apache.maven.doxia.linkcheck.model.LinkcheckFile; +import org.apache.maven.doxia.linkcheck.model.LinkcheckFileResult; +import org.apache.maven.doxia.linkcheck.model.LinkcheckModel; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; +import org.codehaus.plexus.util.xml.pull.MXParser; +import org.codehaus.plexus.util.xml.pull.XmlPullParser; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +/** + * Class LinkcheckModelXpp3Reader. + * + * @version $Revision$ $Date$ + */ +@SuppressWarnings( "all" ) +public class LinkcheckModelXpp3Reader +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * If set the parser will be loaded with all single characters + * from the XHTML specification. + * The entities used: + * <ul> + * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li> + * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li> + * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li> + * </ul> + */ + private boolean addDefaultEntities = true; + + /** + * Field contentTransformer. + */ + public final ContentTransformer contentTransformer; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public LinkcheckModelXpp3Reader() + { + this( new ContentTransformer() + { + public String transform( String source, String fieldName ) + { + return source; + } + } ); + } //-- org.apache.maven.doxia.linkcheck.model.io.xpp3.LinkcheckModelXpp3Reader() + + public LinkcheckModelXpp3Reader(ContentTransformer contentTransformer) + { + this.contentTransformer = contentTransformer; + } //-- org.apache.maven.doxia.linkcheck.model.io.xpp3.LinkcheckModelXpp3Reader(ContentTransformer) + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method checkFieldWithDuplicate. + * + * @param parser + * @param parsed + * @param alias + * @param tagName + * @throws XmlPullParserException + * @return boolean + */ + private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) + throws XmlPullParserException + { + if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) + { + return false; + } + if ( !parsed.add( tagName ) ) + { + throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); + } + return true; + } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set ) + + /** + * Method checkUnknownAttribute. + * + * @param parser + * @param strict + * @param tagName + * @param attribute + * @throws XmlPullParserException + * @throws IOException + */ + private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) + throws XmlPullParserException, IOException + { + // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too + if ( strict ) + { + throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); + } + } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) + + /** + * Method checkUnknownElement. + * + * @param parser + * @param strict + * @throws XmlPullParserException + * @throws IOException + */ + private void checkUnknownElement( XmlPullParser parser, boolean strict ) + throws XmlPullParserException, IOException + { + if ( strict ) + { + throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); + } + + for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) + { + int eventType = parser.next(); + if ( eventType == XmlPullParser.START_TAG ) + { + unrecognizedTagCount++; + } + else if ( eventType == XmlPullParser.END_TAG ) + { + unrecognizedTagCount--; + } + } + } //-- void checkUnknownElement( XmlPullParser, boolean ) + + /** + * Returns the state of the "add default entities" flag. + * + * @return boolean + */ + public boolean getAddDefaultEntities() + { + return addDefaultEntities; + } //-- boolean getAddDefaultEntities() + + /** + * Method getBooleanValue. + * + * @param s + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return boolean + */ + private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) + throws XmlPullParserException + { + return getBooleanValue( s, attribute, parser, null ); + } //-- boolean getBooleanValue( String, String, XmlPullParser ) + + /** + * Method getBooleanValue. + * + * @param s + * @param defaultValue + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return boolean + */ + private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) + throws XmlPullParserException + { + if ( s != null && s.length() != 0 ) + { + return Boolean.valueOf( s ).booleanValue(); + } + if ( defaultValue != null ) + { + return Boolean.valueOf( defaultValue ).booleanValue(); + } + return false; + } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) + + /** + * Method getByteValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return byte + */ + private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s != null ) + { + try + { + return Byte.valueOf( s ).byteValue(); + } + catch ( NumberFormatException nfe ) + { + if ( strict ) + { + throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); + } + } + } + return 0; + } //-- byte getByteValue( String, String, XmlPullParser, boolean ) + + /** + * Method getCharacterValue. + * + * @param s + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return char + */ + private char getCharacterValue( String s, String attribute, XmlPullParser parser ) + throws XmlPullParserException + { + if ( s != null ) + { + return s.charAt( 0 ); + } + return 0; + } //-- char getCharacterValue( String, String, XmlPullParser ) + + /** + * Method getDateValue. + * + * @param s + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return Date + */ + private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) + throws XmlPullParserException + { + return getDateValue( s, attribute, null, parser ); + } //-- java.util.Date getDateValue( String, String, XmlPullParser ) + + /** + * Method getDateValue. + * + * @param s + * @param parser + * @param dateFormat + * @param attribute + * @throws XmlPullParserException + * @return Date + */ + private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) + throws XmlPullParserException + { + if ( s != null ) + { + String effectiveDateFormat = dateFormat; + if ( dateFormat == null ) + { + effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; + } + if ( "long".equals( effectiveDateFormat ) ) + { + try + { + return new java.util.Date( Long.parseLong( s ) ); + } + catch ( NumberFormatException e ) + { + throw new XmlPullParserException( e.getMessage(), parser, e ); + } + } + else + { + try + { + DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US ); + return dateParser.parse( s ); + } + catch ( java.text.ParseException e ) + { + throw new XmlPullParserException( e.getMessage(), parser, e ); + } + } + } + return null; + } //-- java.util.Date getDateValue( String, String, String, XmlPullParser ) + + /** + * Method getDoubleValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return double + */ + private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s != null ) + { + try + { + return Double.valueOf( s ).doubleValue(); + } + catch ( NumberFormatException nfe ) + { + if ( strict ) + { + throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); + } + } + } + return 0; + } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) + + /** + * Method getFloatValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return float + */ + private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s != null ) + { + try + { + return Float.valueOf( s ).floatValue(); + } + catch ( NumberFormatException nfe ) + { + if ( strict ) + { + throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); + } + } + } + return 0; + } //-- float getFloatValue( String, String, XmlPullParser, boolean ) + + /** + * Method getIntegerValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return int + */ + private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s != null ) + { + try + { + return Integer.valueOf( s ).intValue(); + } + catch ( NumberFormatException nfe ) + { + if ( strict ) + { + throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); + } + } + } + return 0; + } //-- int getIntegerValue( String, String, XmlPullParser, boolean ) + + /** + * Method getLongValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return long + */ + private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s != null ) + { + try + { + return Long.valueOf( s ).longValue(); + } + catch ( NumberFormatException nfe ) + { + if ( strict ) + { + throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); + } + } + } + return 0; + } //-- long getLongValue( String, String, XmlPullParser, boolean ) + + /** + * Method getRequiredAttributeValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return String + */ + private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s == null ) + { + if ( strict ) + { + throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); + } + } + return s; + } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) + + /** + * Method getShortValue. + * + * @param s + * @param strict + * @param parser + * @param attribute + * @throws XmlPullParserException + * @return short + */ + private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) + throws XmlPullParserException + { + if ( s != null ) + { + try + { + return Short.valueOf( s ).shortValue(); + } + catch ( NumberFormatException nfe ) + { + if ( strict ) + { + throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); + } + } + } + return 0; + } //-- short getShortValue( String, String, XmlPullParser, boolean ) + + /** + * Method getTrimmedValue. + * + * @param s + * @return String + */ + private String getTrimmedValue( String s ) + { + if ( s != null ) + { + s = s.trim(); + } + return s; + } //-- String getTrimmedValue( String ) + + /** + * Method interpolatedTrimmed. + * + * @param value + * @param context + * @return String + */ + private String interpolatedTrimmed( String value, String context ) + { + return getTrimmedValue( contentTransformer.transform( value, context ) ); + } //-- String interpolatedTrimmed( String, String ) + + /** + * Method nextTag. + * + * @param parser + * @throws IOException + * @throws XmlPullParserException + * @return int + */ + private int nextTag( XmlPullParser parser ) + throws IOException, XmlPullParserException + { + int eventType = parser.next(); + if ( eventType == XmlPullParser.TEXT ) + { + eventType = parser.next(); + } + if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) + { + throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); + } + return eventType; + } //-- int nextTag( XmlPullParser ) + + /** + * @see ReaderFactory#newXmlReader + * + * @param reader + * @param strict + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckModel + */ + public LinkcheckModel read( Reader reader, boolean strict ) + throws IOException, XmlPullParserException + { + XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( ); + + parser.setInput( reader ); + + + return read( parser, strict ); + } //-- LinkcheckModel read( Reader, boolean ) + + /** + * @see ReaderFactory#newXmlReader + * + * @param reader + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckModel + */ + public LinkcheckModel read( Reader reader ) + throws IOException, XmlPullParserException + { + return read( reader, true ); + } //-- LinkcheckModel read( Reader ) + + /** + * Method read. + * + * @param in + * @param strict + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckModel + */ + public LinkcheckModel read( InputStream in, boolean strict ) + throws IOException, XmlPullParserException + { + return read( ReaderFactory.newXmlReader( in ), strict ); + } //-- LinkcheckModel read( InputStream, boolean ) + + /** + * Method read. + * + * @param in + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckModel + */ + public LinkcheckModel read( InputStream in ) + throws IOException, XmlPullParserException + { + return read( ReaderFactory.newXmlReader( in ) ); + } //-- LinkcheckModel read( InputStream ) + + /** + * Method parseLinkcheckFile. + * + * @param parser + * @param strict + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckFile + */ + private LinkcheckFile parseLinkcheckFile( XmlPullParser parser, boolean strict ) + throws IOException, XmlPullParserException + { + String tagName = parser.getName(); + LinkcheckFile linkcheckFile = new LinkcheckFile(); + for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) + { + String name = parser.getAttributeName( i ); + String value = parser.getAttributeValue( i ); + + if ( name.indexOf( ':' ) >= 0 ) + { + // just ignore attributes with non-default namespace (for example: xmlns:xsi) + } + else + { + checkUnknownAttribute( parser, name, tagName, strict ); + } + } + java.util.Set parsed = new java.util.HashSet(); + while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) + { + if ( checkFieldWithDuplicate( parser, "absolutePath", null, parsed ) ) + { + linkcheckFile.setAbsolutePath( interpolatedTrimmed( parser.nextText(), "absolutePath" ) ); + } + else if ( checkFieldWithDuplicate( parser, "relativePath", null, parsed ) ) + { + linkcheckFile.setRelativePath( interpolatedTrimmed( parser.nextText(), "relativePath" ) ); + } + else if ( checkFieldWithDuplicate( parser, "successful", null, parsed ) ) + { + linkcheckFile.setSuccessful( getIntegerValue( interpolatedTrimmed( parser.nextText(), "successful" ), "successful", parser, strict ) ); + } + else if ( checkFieldWithDuplicate( parser, "unsuccessful", null, parsed ) ) + { + linkcheckFile.setUnsuccessful( getIntegerValue( interpolatedTrimmed( parser.nextText(), "unsuccessful" ), "unsuccessful", parser, strict ) ); + } + else if ( checkFieldWithDuplicate( parser, "results", null, parsed ) ) + { + java.util.List<LinkcheckFileResult> results = new java.util.ArrayList<LinkcheckFileResult>(); + linkcheckFile.setResults( results ); + while ( parser.nextTag() == XmlPullParser.START_TAG ) + { + if ( "result".equals( parser.getName() ) ) + { + results.add( parseLinkcheckFileResult( parser, strict ) ); + } + else + { + checkUnknownElement( parser, strict ); + } + } + } + else + { + checkUnknownElement( parser, strict ); + } + } + return linkcheckFile; + } //-- LinkcheckFile parseLinkcheckFile( XmlPullParser, boolean ) + + /** + * Method parseLinkcheckFileResult. + * + * @param parser + * @param strict + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckFileResult + */ + private LinkcheckFileResult parseLinkcheckFileResult( XmlPullParser parser, boolean strict ) + throws IOException, XmlPullParserException + { + String tagName = parser.getName(); + LinkcheckFileResult linkcheckFileResult = new LinkcheckFileResult(); + for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) + { + String name = parser.getAttributeName( i ); + String value = parser.getAttributeValue( i ); + + if ( name.indexOf( ':' ) >= 0 ) + { + // just ignore attributes with non-default namespace (for example: xmlns:xsi) + } + else + { + checkUnknownAttribute( parser, name, tagName, strict ); + } + } + java.util.Set parsed = new java.util.HashSet(); + while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) + { + if ( checkFieldWithDuplicate( parser, "target", null, parsed ) ) + { + linkcheckFileResult.setTarget( interpolatedTrimmed( parser.nextText(), "target" ) ); + } + else if ( checkFieldWithDuplicate( parser, "status", null, parsed ) ) + { + linkcheckFileResult.setStatus( interpolatedTrimmed( parser.nextText(), "status" ) ); + } + else if ( checkFieldWithDuplicate( parser, "errorMessage", null, parsed ) ) + { + linkcheckFileResult.setErrorMessage( interpolatedTrimmed( parser.nextText(), "errorMessage" ) ); + } + else + { + checkUnknownElement( parser, strict ); + } + } + return linkcheckFileResult; + } //-- LinkcheckFileResult parseLinkcheckFileResult( XmlPullParser, boolean ) + + /** + * Method parseLinkcheckModel. + * + * @param parser + * @param strict + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckModel + */ + private LinkcheckModel parseLinkcheckModel( XmlPullParser parser, boolean strict ) + throws IOException, XmlPullParserException + { + String tagName = parser.getName(); + LinkcheckModel linkcheckModel = new LinkcheckModel(); + for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) + { + String name = parser.getAttributeName( i ); + String value = parser.getAttributeValue( i ); + + if ( name.indexOf( ':' ) >= 0 ) + { + // just ignore attributes with non-default namespace (for example: xmlns:xsi) + } + else if ( "xmlns".equals( name ) ) + { + // ignore xmlns attribute in root class, which is a reserved attribute name + } + else + { + checkUnknownAttribute( parser, name, tagName, strict ); + } + } + java.util.Set parsed = new java.util.HashSet(); + while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) + { + if ( checkFieldWithDuplicate( parser, "files", null, parsed ) ) + { + java.util.List<LinkcheckFile> files = new java.util.ArrayList<LinkcheckFile>(); + linkcheckModel.setFiles( files ); + while ( parser.nextTag() == XmlPullParser.START_TAG ) + { + if ( "file".equals( parser.getName() ) ) + { + files.add( parseLinkcheckFile( parser, strict ) ); + } + else + { + checkUnknownElement( parser, strict ); + } + } + } + else + { + checkUnknownElement( parser, strict ); + } + } + return linkcheckModel; + } //-- LinkcheckModel parseLinkcheckModel( XmlPullParser, boolean ) + + /** + * Method read. + * + * @param parser + * @param strict + * @throws IOException + * @throws XmlPullParserException + * @return LinkcheckModel + */ + private LinkcheckModel read( XmlPullParser parser, boolean strict ) + throws IOException, XmlPullParserException + { + LinkcheckModel linkcheckModel = null; + int eventType = parser.getEventType(); + boolean parsed = false; + while ( eventType != XmlPullParser.END_DOCUMENT ) + { + if ( eventType == XmlPullParser.START_TAG ) + { + if ( strict && ! "linkcheckModel".equals( parser.getName() ) ) + { + throw new XmlPullParserException( "Expected root element 'linkcheckModel' but found '" + parser.getName() + "'", parser, null ); + } + else if ( parsed ) + { + // fallback, already expected a XmlPullParserException due to invalid XML + throw new XmlPullParserException( "Duplicated tag: 'linkcheckModel'", parser, null ); + } + linkcheckModel = parseLinkcheckModel( parser, strict ); + linkcheckModel.setModelEncoding( parser.getInputEncoding() ); + parsed = true; + } + eventType = parser.next(); + } + if ( parsed ) + { + return linkcheckModel; + } + throw new XmlPullParserException( "Expected root element 'linkcheckModel' but found no element at all: invalid XML document", parser, null ); + } //-- LinkcheckModel read( XmlPullParser, boolean ) + + /** + * Sets the state of the "add default entities" flag. + * + * @param addDefaultEntities + */ + public void setAddDefaultEntities( boolean addDefaultEntities ) + { + this.addDefaultEntities = addDefaultEntities; + } //-- void setAddDefaultEntities( boolean ) + + public static interface ContentTransformer +{ + /** + * Interpolate the value read from the xpp3 document + * @param source The source value + * @param fieldName A description of the field being interpolated. The implementation may use this to + * log stuff. + * @return The interpolated value. + */ + String transform( String source, String fieldName ); +} + +} diff --git a/src/main/java/org/apache/maven/doxia/linkcheck/model/io/xpp3/LinkcheckModelXpp3Writer.java b/src/main/java/org/apache/maven/doxia/linkcheck/model/io/xpp3/LinkcheckModelXpp3Writer.java new file mode 100644 index 0000000..b1e92b4 --- /dev/null +++ b/src/main/java/org/apache/maven/doxia/linkcheck/model/io/xpp3/LinkcheckModelXpp3Writer.java @@ -0,0 +1,200 @@ +package org.apache.maven.doxia.linkcheck.model.io.xpp3; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.OutputStream; +import java.io.Writer; +import java.util.Iterator; +import org.apache.maven.doxia.linkcheck.model.LinkcheckFile; +import org.apache.maven.doxia.linkcheck.model.LinkcheckFileResult; +import org.apache.maven.doxia.linkcheck.model.LinkcheckModel; +import org.codehaus.plexus.util.xml.pull.MXSerializer; +import org.codehaus.plexus.util.xml.pull.XmlSerializer; + +/** + * Class LinkcheckModelXpp3Writer. + * + * @version $Revision$ $Date$ + */ +@SuppressWarnings( "all" ) +public class LinkcheckModelXpp3Writer +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field NAMESPACE. + */ + private static final String NAMESPACE = null; + + /** + * Field fileComment. + */ + private String fileComment = null; + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method setFileComment. + * + * @param fileComment + */ + public void setFileComment( String fileComment ) + { + this.fileComment = fileComment; + } //-- void setFileComment( String ) + + /** + * Method write. + * + * @param writer + * @param linkcheckModel + * @throws java.io.IOException + */ + public void write( Writer writer, LinkcheckModel linkcheckModel ) + throws java.io.IOException + { + XmlSerializer serializer = new MXSerializer(); + serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); + serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); + serializer.setOutput( writer ); + serializer.startDocument( linkcheckModel.getModelEncoding(), null ); + writeLinkcheckModel( linkcheckModel, "linkcheckModel", serializer ); + serializer.endDocument(); + } //-- void write( Writer, LinkcheckModel ) + + /** + * Method write. + * + * @param stream + * @param linkcheckModel + * @throws java.io.IOException + */ + public void write( OutputStream stream, LinkcheckModel linkcheckModel ) + throws java.io.IOException + { + XmlSerializer serializer = new MXSerializer(); + serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); + serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); + serializer.setOutput( stream, linkcheckModel.getModelEncoding() ); + serializer.startDocument( linkcheckModel.getModelEncoding(), null ); + writeLinkcheckModel( linkcheckModel, "linkcheckModel", serializer ); + serializer.endDocument(); + } //-- void write( OutputStream, LinkcheckModel ) + + /** + * Method writeLinkcheckFile. + * + * @param linkcheckFile + * @param serializer + * @param tagName + * @throws java.io.IOException + */ + private void writeLinkcheckFile( LinkcheckFile linkcheckFile, String tagName, XmlSerializer serializer ) + throws java.io.IOException + { + serializer.startTag( NAMESPACE, tagName ); + if ( linkcheckFile.getAbsolutePath() != null ) + { + serializer.startTag( NAMESPACE, "absolutePath" ).text( linkcheckFile.getAbsolutePath() ).endTag( NAMESPACE, "absolutePath" ); + } + if ( linkcheckFile.getRelativePath() != null ) + { + serializer.startTag( NAMESPACE, "relativePath" ).text( linkcheckFile.getRelativePath() ).endTag( NAMESPACE, "relativePath" ); + } + if ( linkcheckFile.getSuccessful() != -1 ) + { + serializer.startTag( NAMESPACE, "successful" ).text( String.valueOf( linkcheckFile.getSuccessful() ) ).endTag( NAMESPACE, "successful" ); + } + if ( linkcheckFile.getUnsuccessful() != -1 ) + { + serializer.startTag( NAMESPACE, "unsuccessful" ).text( String.valueOf( linkcheckFile.getUnsuccessful() ) ).endTag( NAMESPACE, "unsuccessful" ); + } + if ( ( linkcheckFile.getResults() != null ) && ( linkcheckFile.getResults().size() > 0 ) ) + { + serializer.startTag( NAMESPACE, "results" ); + for ( Iterator iter = linkcheckFile.getResults().iterator(); iter.hasNext(); ) + { + LinkcheckFileResult o = (LinkcheckFileResult) iter.next(); + writeLinkcheckFileResult( o, "result", serializer ); + } + serializer.endTag( NAMESPACE, "results" ); + } + serializer.endTag( NAMESPACE, tagName ); + } //-- void writeLinkcheckFile( LinkcheckFile, String, XmlSerializer ) + + /** + * Method writeLinkcheckFileResult. + * + * @param linkcheckFileResult + * @param serializer + * @param tagName + * @throws java.io.IOException + */ + private void writeLinkcheckFileResult( LinkcheckFileResult linkcheckFileResult, String tagName, XmlSerializer serializer ) + throws java.io.IOException + { + serializer.startTag( NAMESPACE, tagName ); + if ( linkcheckFileResult.getTarget() != null ) + { + serializer.startTag( NAMESPACE, "target" ).text( linkcheckFileResult.getTarget() ).endTag( NAMESPACE, "target" ); + } + if ( linkcheckFileResult.getStatus() != null ) + { + serializer.startTag( NAMESPACE, "status" ).text( linkcheckFileResult.getStatus() ).endTag( NAMESPACE, "status" ); + } + if ( linkcheckFileResult.getErrorMessage() != null ) + { + serializer.startTag( NAMESPACE, "errorMessage" ).text( linkcheckFileResult.getErrorMessage() ).endTag( NAMESPACE, "errorMessage" ); + } + serializer.endTag( NAMESPACE, tagName ); + } //-- void writeLinkcheckFileResult( LinkcheckFileResult, String, XmlSerializer ) + + /** + * Method writeLinkcheckModel. + * + * @param linkcheckModel + * @param serializer + * @param tagName + * @throws java.io.IOException + */ + private void writeLinkcheckModel( LinkcheckModel linkcheckModel, String tagName, XmlSerializer serializer ) + throws java.io.IOException + { + serializer.startTag( NAMESPACE, tagName ); + if ( ( linkcheckModel.getFiles() != null ) && ( linkcheckModel.getFiles().size() > 0 ) ) + { + serializer.startTag( NAMESPACE, "files" ); + for ( Iterator iter = linkcheckModel.getFiles().iterator(); iter.hasNext(); ) + { + LinkcheckFile o = (LinkcheckFile) iter.next(); + writeLinkcheckFile( o, "file", serializer ); + } + serializer.endTag( NAMESPACE, "files" ); + } + serializer.endTag( NAMESPACE, tagName ); + } //-- void writeLinkcheckModel( LinkcheckModel, String, XmlSerializer ) + +} diff --git a/src/main/mdo/httpbean.mdo b/src/main/mdo/httpbean.mdo deleted file mode 100644 index dc9fcb0..0000000 --- a/src/main/mdo/httpbean.mdo +++ /dev/null @@ -1,173 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<model xmlns="https://codehaus-plexus.github.io/MODELLO/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://codehaus-plexus.github.io/MODELLO/1.0.0 https://codehaus-plexus.github.io/modello/xsd/modello-1.0.0.xsd"> - <id>http</id> - <name>HttpBean</name> - <description>Bean for supported HTTP parameters.</description> - <defaults> - <default> - <key>package</key> - <value>org.apache.maven.doxia.linkcheck</value> - </default> - </defaults> - <classes> - <class> - <name>HttpBean</name> - <description>Http bean to encapsulate the supported HTTP parameters. - @see org.apache.commons.httpclient.HttpMethod</description> - <version>1.0.0</version> - <fields> - <field> - <name>method</name> - <description><![CDATA[ - The HTTP method to use. Currently supported are "GET" and "HEAD". - <dl> - <dt>HTTP GET</dt> - <dd> - The HTTP GET method is defined in section 9.3 of - <a HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: - <blockquote> - The GET method means retrieve whatever information (in the form of an - entity) is identified by the Request-URI. - </blockquote> - </dd> - <dt>HTTP HEAD</dt> - <dd> - The HTTP HEAD method is defined in section 9.4 of - <a HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: - <blockquote> - The HEAD method is identical to GET except that the server MUST NOT - return a message-body in the response. - </blockquote> - </dd> - </dl>]]></description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>String</type> - <defaultValue>head</defaultValue> - </field> - <field> - <name>followRedirects</name> - <description><![CDATA[ - if the HTTP method should automatically follow HTTP redirects - (status code 302, etc.), <tt>false</tt> otherwise.]]></description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>boolean</type> - </field> - <field> - <name>proxyHost</name> - <description>The proxy host.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>String</type> - </field> - <field> - <name>proxyPort</name> - <description>The proxy port.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>int</type> - <defaultValue>0</defaultValue> - </field> - <field> - <name>proxyUser</name> - <description>The proxy user.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>String</type> - </field> - <field> - <name>proxyPassword</name> - <description>The proxy password.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>String</type> - </field> - <field> - <name>proxyNtlmHost</name> - <description>The proxy NTLM (NT Lan Manager) host.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>String</type> - </field> - <field> - <name>proxyNtlmDomain</name> - <description>The proxy NTLM (NT Lan Manager) domain.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>String</type> - </field> - <field java.setter="false"> - <name>timeout</name> - <description>The timeout to be used. A value of zero means the timeout is not used. - Default value is 2000.</description> - <version>1.0.0</version> - <identifier>true</identifier> - <type>int</type> - <defaultValue>2000</defaultValue> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0</version> - <code> - <![CDATA[ - /** - * Set the timeout to be used. A value of zero means the timeout is not used. - * - * @param timeout positive int - */ - public void setTimeout( int timeout ) - { - if ( timeout < 0 ) - { - throw new IllegalArgumentException( timeout + " should be 0 or positive." ); - } - this.timeout = timeout; - } - - private java.util.Properties httpClientParameters; - - /** - * @return the extra HttpClient parameters - * @see http://hc.apache.org/httpclient-3.x/preference-api.html - */ - public java.util.Properties getHttpClientParameters() - { - return httpClientParameters; - } - - /** - * @param httpClientParameters the extra HttpClient parameters to set - * @see http://hc.apache.org/httpclient-3.x/preference-api.html - */ - public void setHttpClientParameters( java.util.Properties httpClientParameters ) - { - this.httpClientParameters = httpClientParameters; - }]]> - </code> - </codeSegment> - </codeSegments> - </class> - </classes> -</model> diff --git a/src/main/mdo/linkcheck.mdo b/src/main/mdo/linkcheck.mdo deleted file mode 100644 index bb6bb2d..0000000 --- a/src/main/mdo/linkcheck.mdo +++ /dev/null @@ -1,274 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<model xmlns="https://codehaus-plexus.github.io/MODELLO/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://codehaus-plexus.github.io/MODELLO/1.0.0 https://codehaus-plexus.github.io/modello/xsd/modello-1.0.0.xsd"> - <id>linkcheck</id> - <name>LinkcheckModel</name> - <description>Model for the linkcheck report.</description> - <defaults> - <default> - <key>package</key> - <value>org.apache.maven.doxia.linkcheck.model</value> - </default> - </defaults> - <classes> - <class rootElement="true"> - <name>LinkcheckModel</name> - <description><![CDATA[ - The <code><linkcheck></code> element is the root of the linkcheck descriptor. - ]]></description> - <version>1.0.0</version> - <fields> - <field> - <name>files</name> - <description><![CDATA[ - List of <code><file></code> elements. - ]]></description> - <version>1.0.0</version> - <association> - <type>LinkcheckFile</type> - <multiplicity>*</multiplicity> - </association> - <identifier>true</identifier> - </field> - </fields> - </class> - <class> - <name>LinkcheckFile</name> - <description><![CDATA[ - The <code><file></code> to be checked. - ]]></description> - <version>1.0.0</version> - <fields> - <field> - <name>absolutePath</name> - <version>1.0.0</version> - <description><![CDATA[ - The file to check as String Object. - ]]></description> - <type>String</type> - <identifier>true</identifier> - </field> - <field> - <name>relativePath</name> - <version>1.0.0</version> - <description><![CDATA[ - The relative path of the file. - ]]></description> - <type>String</type> - <identifier>true</identifier> - </field> - <field> - <name>successful</name> - <version>1.0.0</version> - <description><![CDATA[ - The number of successful links in this file. - ]]></description> - <type>int</type> - <identifier>true</identifier> - <defaultValue>-1</defaultValue> - </field> - <field> - <name>unsuccessful</name> - <version>1.0.0</version> - <description><![CDATA[ - The number of unsuccessful links in this file. - ]]></description> - <type>int</type> - <identifier>true</identifier> - <defaultValue>-1</defaultValue> - </field> - <field> - <name>results</name> - <version>1.0.0</version> - <description><![CDATA[ - All error details in this file. - ]]></description> - <association> - <type>LinkcheckFileResult</type> - <multiplicity>*</multiplicity> - </association> - <identifier>true</identifier> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0</version> - <code> - <![CDATA[ - /** - * Get the number of links for this file depending the level wanted. - * - * {@link LinkcheckFileResult#ERROR_LEVEL} - * {@link LinkcheckFileResult#UNKNOWN_LEVEL} - * {@link LinkcheckFileResult#VALID_LEVEL} - * {@link LinkcheckFileResult#WARNING_LEVEL} - * - * @param level the restricted level - * @return the number of links for the restrict level, -1 if the level is not a valid one - * or no results was found. - * @throws UnsupportedOperationException if the level is unsupported. - */ - public int getNumberOfLinks( int level ) - { - if ( results == null ) - { - return -1; - } - - if ( !( level == LinkcheckFileResult.ERROR_LEVEL || level == LinkcheckFileResult.WARNING_LEVEL - || level == LinkcheckFileResult.VALID_LEVEL || level == LinkcheckFileResult.UNKNOWN_LEVEL ) ) - { - throw new UnsupportedOperationException( "This level [" + level + "] is unsupported." ); - } - - int number = 0; - for ( java.util.Iterator it = results.iterator(); it.hasNext(); ) - { - LinkcheckFileResult linkcheckFileResult = (LinkcheckFileResult) it.next(); - - if ( linkcheckFileResult.getStatusLevel() == level ) - { - number++; - } - } - - return number; - } - - /** - * Get the number of links for this file. - * - * @param level - * @return - */ - public int getNumberOfLinks() - { - if ( results == null ) - { - return -1; - } - - return results.size(); - } - ]]> - </code> - </codeSegment> - </codeSegments> - </class> - <class> - <name>LinkcheckFileResult</name> - <description><![CDATA[ - An class containing the results of a single check of a link. - ]]></description> - <version>1.0.0</version> - <fields> - <field> - <name>target</name> - <description><![CDATA[ - The target URL. - ]]></description> - <version>1.0.0</version> - <type>String</type> - <identifier>true</identifier> - </field> - <field> - <name>status</name> - <description><![CDATA[ - The status. - ]]></description> - <version>1.0.0</version> - <type>String</type> - <identifier>true</identifier> - </field> - <field> - <name>errorMessage</name> - <description><![CDATA[ - The error message. - ]]></description> - <version>1.0.0</version> - <type>String</type> - <identifier>true</identifier> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0</version> - <code> - <![CDATA[ - /** The vm line separator. */ - private static final String EOL = System.getProperty( "line.separator" ); - - /** Validation result level: error. */ - public static final int ERROR_LEVEL = 1; - - /** Validation result level: warning. */ - public static final int WARNING_LEVEL = 2; - - /** Validation result level: valid. */ - public static final int VALID_LEVEL = 3; - - /** Validation result level: unknown. */ - public static final int UNKNOWN_LEVEL = 4; - - /** Validation result: error. */ - public static final String ERROR = "error"; - - /** Validation result: warning. */ - public static final String WARNING = "warning"; - - /** Validation result: valid. */ - public static final String VALID = "valid"; - - /** Validation result: unknown. */ - public static final String UNKNOWN = "unknown"; - - /** - * Returns the status as an integer. - * - * @return One of ERROR, WARNING, VALID or UNKNOWN. - */ - public int getStatusLevel() - { - int level = UNKNOWN_LEVEL; - - if ( VALID.equals( getStatus() ) ) - { - level = VALID_LEVEL; - } - else if ( WARNING.equals( getStatus() ) ) - { - level = WARNING_LEVEL; - } - else if ( ERROR.equals( getStatus() ) ) - { - level = ERROR_LEVEL; - } - - return level; - } - ]]> - </code> - </codeSegment> - </codeSegments> - </class> - </classes> -</model>
