/** * Initiates an OpenId Connection authorization code flow using the specified request identifier to maintain state. * * @param oidcRequestIdentifier request identifier * @return state */ public State createState(final String oidcRequestIdentifier) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); final State state = new State(generateStateValue()); try { synchronized (stateLookupForPendingRequests) { final State cachedState = stateLookupForPendingRequests.get(oidcRequestIdentifierKey, () -> state); if (!timeConstantEqualityCheck(state.getValue(), cachedState.getValue())) { throw new IllegalStateException("An existing login request is already in progress."); } } } catch (ExecutionException e) { throw new IllegalStateException("Unable to store the login request state."); } return state; }
public void addState() { try { State state=new State(); state.setStateName("Delhi"); stateDao.create(state); addCity(); addCustomer(); } catch(Exception e) { e.printStackTrace(); } }
// Step 1: Locate our spinner control and save it to the class for convenience // You could get it every time, I'm just being lazy... :-) spinner = (Spinner)this.findViewById(R.id.Spinner01); // Step 2: Create and fill an ArrayAdapter with a bunch of "State" objects ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, new State[] { new State( 1, "Minnesota", "MN" ), new State( 99, "Wisconsin", "WI" ), new State( 53, "Utah", "UT" ), new State( 153, "Texas", "TX" ) }); // Step 3: Tell the spinner about our adapter spinner.setAdapter(spinnerArrayAdapter);
public void play() { State s=new State(3); Scanner in = new Scanner (System.in); while (s.isGameOver().equals("Not Gameover")) { int[] options = s.getAvailableMoves(); s.dump(); System.out.println ("Your options are " + Arrays.toString(options)); int move = in.nextInt(); s.setX(move); int [] ScoreAndRecommendedMove=new int[2]; ScoreAndRecommendedMove=s.newminimax47(0); System.out.println("Score: "+ScoreAndRecommendedMove[0]+" Position: "+ ScoreAndRecommendedMove[1]); s.setO(ScoreAndRecommendedMove[1]); } s.dump(); }
int limit = initialState.getManhattanDistance() + 2 * initialState.getLinearConflicts(); for(State s : current.findNext()) { if(s.equals(GOAL)) { s.setParent(current); return s; s.setPathCost(current.getPathCost() + 1); s.setParent(current); int currentCost = s.getManhattanDistance() + 2 * s.getLinearConflicts() + s.getPathCost(); if(currentCost <= limit) { visitedStates.add(s); State solution = limitedSearch(s, limit); if(solution != null && (bestSolution == null || solution.getPathCost() < bestSolution.getPathCost()))
/** * Validates the proposed state with the given request identifier. Will return false if the * state does not match or if entry for this request identifier has expired. * * @param oidcRequestIdentifier request identifier * @param proposedState proposed state * @return whether the state is valid or not */ public boolean isStateValid(final String oidcRequestIdentifier, final State proposedState) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } if (proposedState == null) { throw new IllegalArgumentException("Proposed state must be specified."); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); synchronized (stateLookupForPendingRequests) { final State state = stateLookupForPendingRequests.getIfPresent(oidcRequestIdentifierKey); if (state != null) { stateLookupForPendingRequests.invalidate(oidcRequestIdentifierKey); } return state != null && timeConstantEqualityCheck(state.getValue(), proposedState.getValue()); } }
State initialState = new State(); // empty board, no moves Stack<State> stack = new Stack<State>(); stack.add(initialState); while ( ! stack.isEmpty()) { State current = stack.pop(); for (State next : current.getSuccesorStates()) { if (next.isLegal()) { stack.add(next); } } }
State philippines = new State("Philippines"); philippines.setCapital("Manila"); philippines.getPresidents().add(new President("Aguinaldo", 1)); philippines.getPresidents().add(new President("Marcos", 10)); philippines.getPresidents().add(new President("Quezon", 2)); Collections.sort(philippines.getPresidents(), new President()); for(President p: philippines.getPresidents()) System.out.print(p.getPresName());
Transaction t = s.beginTransaction(); State state = new State(); System.out.println(state.getClass().getName()); state.setStateCode("NE");
state = new State(); arrCities = new ArrayList<City>(); state.setStateId(xpp.getAttributeValue(null, TAGS.ID)); state.setStateName(VALUE); state.setArrCities(arrCities); arrStates.add(state);
State newState = new State(newLine); arrPopulation[3] = new int[col]; int stateRegion = newState.getRegionNum(); arrPopulation[0][col] = newState.getStatePop(); System.out.println("Population added:" + arrPopulation[0][col]);//test if col was created case 2: arrPopulation[1][col] = newState.getStatePop(); arrPopulation[2][col] = newState.getStatePop(); col++; break; case 6: arrPopulation[3][col] = newState.getStatePop(); System.out.println("Population added:" + arrPopulation[3][col]);
State state = new State(); state.setStatName("London"); state.setCityList(createCity()); states.add(state); return states;
if (state2.validateState(userInputState)) { state = state2; break; taxPrice = state.getTaxPrice(); totalPrice = (1 + taxPrice) * menu.getPrice(); System.out.print("That means that the total price of your item is "); stateList.add(new State("North Dakota", 0.05, "The sales tax in userInputState is ")); stateList.add(new State("Arizona", 0.05, "The sales tax in userInputState is ")); stateList.add(new State("Maine", 0.05, "The sales tax in userInputState is "));
public class CustomPageParser extends HTMLPageParser { @Override protected void addUserDefinedRules(State html, PageBuilder page) { super.addUserDefinedRules(html, page); // Ensure that while in <textarea> tag, none of the other rules kick in. State textarea = new State(); html.addRule(new StateTransitionRule("textarea", textarea)); } }
public Response saveStateRules(@Context HttpServletRequest request,StatePojo statePojo) { ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(statePojo); State state = new State(); state.setRulejson(json); }
private State state; public void setState(State newstate){ if (!newstate.equals(state)){ if (state.equals(State.INACTIVE)){ timeInactive = 0; timeStarted = System.currentTimeMillis(); } else if (state.equals(State.ACTIVE)){ timeInactive = System.currentTimeMillis()-timeStarted; } } state = newstate; }