Here you can find the source of extractParamsFromUriTemplateFragment(String value)
Parameter | Description |
---|---|
value | the given value |
public static List<String> extractParamsFromUriTemplateFragment(String value)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 - 2014 Red Hat, Inc. and others. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * //from www . ja va 2 s . c om * Contributors: * Xavier Coulon - Initial API and implementation ******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { /** * Extracts all the character sequences inside of curly braces ('{' and '}') * and returns them as a list of strings * * @param value * the given value * @return the list of character sequences, or an empty list */ public static List<String> extractParamsFromUriTemplateFragment(String value) { List<String> params = new ArrayList<String>(); int beginIndex = -1; while ((beginIndex = value.indexOf("{", beginIndex + 1)) != -1) { int semicolonIndex = value.indexOf(":", beginIndex); int closingCurlyBraketIndex = value.indexOf("}", beginIndex); int endIndex = (semicolonIndex != -1) ? Math.min(semicolonIndex, closingCurlyBraketIndex) : closingCurlyBraketIndex; if (endIndex == -1) { // missing end bracket break; } params.add(value.substring(beginIndex + 1, endIndex).trim()); } return params; } }