net.java.dev.webdav.jaxrs.xml.elements.Status Maven / Gradle / Ivy
/*
* #%L
* WebDAV Support for JAX-RS
* %%
* Copyright (C) 2008 - 2014 The java.net WebDAV Project
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
package net.java.dev.webdav.jaxrs.xml.elements;
import static javax.xml.bind.annotation.XmlAccessType.NONE;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import net.java.dev.webdav.jaxrs.ResponseStatus;
import net.java.dev.webdav.util.Utilities;
/**
* WebDAV status XML Element.
*
* @author Markus KARG ([email protected])
*
* @see Chapter 14.28 "status XML Element" of RFC 4918
* "HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)"
*/
@XmlAccessorType(NONE)
@XmlRootElement
public final class Status {
@XmlValue
private String statusLine;
public final String getStatus() {
return this.statusLine;
}
/**
* @deprecated Since 1.2. Construct immutable instance instead.
*/
@Deprecated
public void setStatus(final String status) {
this.statusLine = status;
}
@SuppressWarnings("unused")
private Status() {
// For unmarshalling only.
}
private Status(final int statusCode, final String reasonPhrase) {
this.statusLine = String.format("HTTP/1.1 %d %s", statusCode, reasonPhrase);
}
/**
* @deprecated Since 1.1. Use {@link #Status(javax.ws.rs.core.Response.StatusType)} instead.
*/
@Deprecated
public Status(final ResponseStatus responseStatus) {
this(responseStatus.getStatusCode(), responseStatus.toString());
}
/**
* @deprecated Since 1.1. Use {@link #Status(javax.ws.rs.core.Response.StatusType)} instead.
*/
@Deprecated
public Status(final Response.Status responseStatus) {
this(responseStatus.getStatusCode(), responseStatus.toString());
}
public Status(final Response.StatusType responseStatus) {
this(responseStatus.getStatusCode(), responseStatus.getReasonPhrase());
}
@Override
public final boolean equals(final Object object) {
if (object == this)
return true;
if (!(object instanceof Status))
return false;
final Status that = (Status) object;
return this.statusLine.equals(that.statusLine);
}
@Override
public final int hashCode() {
return this.statusLine.hashCode();
}
@Override
public final String toString() {
return Utilities.toString(this, this.statusLine);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy