⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statemanagerimplementation.java

📁 ajax patterns 这是关于ajax设计模式方面的原代码
💻 JAVA
字号:
/*
    Copyright 2006 Christian Gross http://www.devspace.com
    From the book Ajax Patterns and Best Practices

   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 devspace.ajax.statenavigation;
import java.util.*;
import devspace.testDrivenDevelopment.tracer.*;

public class StateManagerImplementation implements StateManager {
    private List< State> _stateArray = new LinkedList< State>();
    public StateManagerImplementation() { }
    public State getState(String stateIdentifier) {
        GenerateOutput.Write( "StateManager.GetState", "Retrieve state identifier (" + stateIdentifier + ")");
        for( State state : _stateArray) {
            if( state.getStateIdentifier().compareTo( stateIdentifier) == 0) {
                GenerateOutput.Write( "StateManager.GetState", "returning state (" + state.toString() + ")");
                return state;
            }
        }
        GenerateOutput.Write( "StateManager.GetState", "Nothing could be found, creating new state");
        State newState;
        if( stateIdentifier.compareTo( "none") == 0) {
            newState = new StateImplementation( new Integer( _stateArray.size() + 10).toString());
        }
        else {
            newState = new StateImplementation( stateIdentifier);
        }
        _stateArray.add( newState);
        GenerateOutput.Write( "StateManager.GetState", "returning state (" + newState.toString() + ")");
        return newState;
    }
    
    public State copyState(String stateIdentifier) {
        GenerateOutput.Write( "StateManager.CopyState", "Copy state identifier (" + stateIdentifier + ")");
        State state = getState(stateIdentifier);
        State copiedState = new StateImplementation( new Integer( _stateArray.size() + 10).toString(), state.getBuffer());
        _stateArray.add( copiedState);
        return copiedState;
    }
    
    public void setState(State state) {
        _stateArray.add(state);
    }
    
    public void setState(String hashcode, String buffer) {
        State state = getState(hashcode);
        state.setBuffer( buffer);
    }
    
    public State getEmptyState() {
        State state = new StateImplementation();
        state.setStateIdentifier( new Integer( _stateArray.size() + 10).toString());
        _stateArray.add( state);
        return state;
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -