001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 * 027 * This file is based on: 028 * - org.apache.catalina.servlets.DefaultServlet/Range 029 * from the Apache Tomcat project. 030 * 031 * Licensed to the Apache Software Foundation (ASF) under one or more 032 * contributor license agreements. See the NOTICE file distributed with 033 * this work for additional information regarding copyright ownership. 034 * The ASF licenses this file to You under the Apache License, Version 2.0 035 * (the "License"); you may not use this file except in compliance with 036 * the License. You may obtain a copy of the License at 037 * 038 * http://www.apache.org/licenses/LICENSE-2.0 039 * 040 * Unless required by applicable law or agreed to in writing, software 041 * distributed under the License is distributed on an "AS IS" BASIS, 042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 043 * See the License for the specific language governing permissions and 044 * limitations under the License. 045 */ 046 047package org.opencms.webdav; 048 049/** 050 * Helper class for the WebDAV servlet. Holds values for a range.<p> 051 * 052 * @since 6.5.6 053 */ 054public class CmsWebdavRange { 055 056 /** The end of the range. */ 057 private long m_end; 058 059 /** The length of the range. */ 060 private long m_length; 061 062 /** The start of the range. */ 063 private long m_start; 064 065 /** 066 * Returns the end.<p> 067 * 068 * @return the end 069 */ 070 public long getEnd() { 071 072 return m_end; 073 } 074 075 /** 076 * Returns the length.<p> 077 * 078 * @return the length 079 */ 080 public long getLength() { 081 082 return m_length; 083 } 084 085 /** 086 * Returns the start.<p> 087 * 088 * @return the start 089 */ 090 public long getStart() { 091 092 return m_start; 093 } 094 095 /** 096 * Resets this range.<p> 097 * 098 */ 099 public void recycle() { 100 101 m_start = 0; 102 m_end = 0; 103 m_length = 0; 104 } 105 106 /** 107 * Sets the end.<p> 108 * 109 * @param end the end to set 110 */ 111 public void setEnd(long end) { 112 113 m_end = end; 114 } 115 116 /** 117 * Sets the length.<p> 118 * 119 * @param length the length to set 120 */ 121 public void setLength(long length) { 122 123 m_length = length; 124 } 125 126 /** 127 * Sets the start.<p> 128 * 129 * @param start the start to set 130 */ 131 public void setStart(long start) { 132 133 m_start = start; 134 } 135 136 /** 137 * Validate range.<p> 138 * 139 * @return true if the actual range is valid otherwise false 140 */ 141 public boolean validate() { 142 143 if (m_end >= m_length) { 144 m_end = m_length - 1; 145 } 146 147 return ((m_start >= 0) && (m_end >= 0) && (m_start <= m_end) && (m_length > 0)); 148 } 149 150}