/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   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 org.bodington.server.resources;

import org.bodington.database.PrimaryKey;
import org.bodington.server.BuildingServerException;

/**
 * Uses the description field to store the block of user text.
 */

public class TextBlockResource extends Resource
{
    private static final int DISPLAY_TITLE = 1;
    private int textblock_flags;

    public int getResourceType()
    {
        return RESOURCE_TEXTBLOCK;
    }
    
    public PrimaryKey getTextBlockId()
    {
        return getResourceId();
    }
    
    public void setTextBlockId(PrimaryKey key)
    {
        setResourceId(key);
    }
    
    public boolean isDisplayTitle()
    {
        return (textblock_flags & DISPLAY_TITLE) != 0;
    }
    
    public void setDisplayTitle(boolean b)
    {
        if (b == isDisplayTitle())
            return;
        
        setTextBlockFlags(textblock_flags ^ DISPLAY_TITLE);
    }
    
    public int getTextBlockFlags()
    {
        return textblock_flags;
    }
    
    public void setTextBlockFlags( int f )
    {
        if ( f==textblock_flags ) return;
        textblock_flags=f;
        setUnsaved();
    }
}
