| /** |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Florian Pirchner - Initial implementation |
| */ |
| |
| package org.eclipse.osbp.runtime.common.session; |
| |
| import java.util.regex.Pattern; |
| |
| public class SessionUtil { |
| |
| private SessionUtil(){ |
| |
| } |
| |
| /** |
| * Splits the fragment by ISession.PARAMETER_SEPARATOR and returns the encoded info. Returns null, if no fragment available. |
| * @param fragment |
| * @return |
| */ |
| public static Info getFragmentInfo(String fragment){ |
| if(fragment == null){ |
| return null; |
| } |
| String[] masterPara = fragment.split(Pattern.quote(ISession.PARAMETER_SEPARATOR)); |
| String masterId = masterPara[0]; |
| String displayId = null; |
| String languageTag = "en-US"; |
| String[] parameters = masterPara[1].split(Pattern.quote(ISession.SUBSEQUENT_PARAMETER)); |
| for(String parameter:parameters) { |
| String[] keyValue = parameter.split("="); |
| if("display".equalsIgnoreCase(keyValue[0].trim())) { |
| displayId = keyValue[1].trim(); |
| } else if("locale".equalsIgnoreCase(keyValue[0].trim())) { |
| languageTag = keyValue[1].trim(); |
| } |
| } |
| return new Info(masterId, displayId, languageTag); |
| } |
| |
| public static class Info { |
| public final String host; |
| public final String ui; |
| public final String languageTag; |
| public Info(String host, String ui, String languageTag) { |
| super(); |
| this.host = host; |
| this.ui = ui; |
| this.languageTag = languageTag; |
| } |
| } |
| } |