Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed 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.
 
 package com.helger.webbasics.userdata;
 
 import java.io.File;
 
 
Represents a single web accessible object, that was provided by the user. Think of this as a file descriptor. A UserDataObject lies directly within a web application and can be accessed by regular file IO.

Author(s):
Philip Helger
 
 public class UserDataObject implements Serializable
 {
   private final String m_sPath;
 
   public UserDataObject (@Nonnull @Nonempty final String sPath)
   {
     ValueEnforcer.notEmpty (sPath"Path");
     // Ensure only forward slashes
      = FilenameHelper.getPathUsingUnixSeparator (FilenameHelper.ensurePathStartingWithSeparator (sPath));
   }

  

Returns:
The path of the object, relative to the user data directory. Always starting with a "/". This method does not contain any server specific context path!
 
   @Nonnull
   @Nonempty
   public String getPath ()
   {
     return ;
   }

  

Parameters:
aRequestScope The request web scope to be used. Required for cookie-less handling. May not be null.
Returns:
The path to the user data object as an URL, including the context path. Always starting with a "/". E.g. /context/user/file.txt if this object points to /file.txt.
 
   @Nonnull
   @Nonempty
   public String getAsURLPath (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
   {
     return UserDataManager.getURLPath (aRequestScopethis);
   }

  

Parameters:
aRequestScope The request web scope to be used. Required for cookie-less handling. May not be null.
Returns:
The path to the user data object as an URL, including the context path. Always starting with a "/". E.g. /context/user/file.txt if this object points to /file.txt.
 
   @Nonnull
   public SimpleURL getAsURL (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
   {
     return UserDataManager.getURL (aRequestScopethis);
   }

  

Returns:
The file system resource underlying this object. Never null but potentially not existing.
 
  {
    return UserDataManager.getResource (this);
  }

  
Get the File of this UDO object.

Returns:
The matching File. No check is performed, whether the file exists or not!
  public File getAsFile ()
  {
    return UserDataManager.getFile (this);
  }
  public boolean equals (final Object o)
  {
    if (o == this)
      return true;
    if (!(o instanceof UserDataObject))
      return false;
    final UserDataObject rhs = (UserDataObjecto;
    return .equals (rhs.m_sPath);
  }
  public int hashCode ()
  {
    return new HashCodeGenerator (this).append ().getHashCode ();
  }
  public String toString ()
  {
    return new ToStringGenerator (this).append ("path").toString ();
  }
  public static UserDataObject createConditional (@Nullable final String sPath)
  {
    if (StringHelper.hasNoText (sPath))
      return null;
    return new UserDataObject (sPath);
  }
New to GrepCode? Check out our FAQ X