001/** 002 * Copyright (C) 2016 Gary Gregory. All rights reserved. 003 * 004 * See the NOTICE.txt file distributed with this work for additional 005 * information regarding copyright ownership. 006 * 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020package com.garygregory.jcommander.converters.xml.namespace; 021 022import javax.xml.namespace.QName; 023 024import com.garygregory.jcommander.converters.AbstractBaseConverter; 025 026/** 027 * Converts a {@link String} into a {@link QName}. 028 * <p> 029 * For a description of the format, see {@link QName#valueOf(String)}. 030 * 031 * <p> 032 * Example: 033 * </p> 034 * 035 * <pre class="prettyprint"> 036 * <code class="language-java">@Parameter(names = { "--qName" }, converter = QNameConverter.class) 037 * private QName qName;</code> 038 * </pre> 039 * <p> 040 * 041 * @see QName 042 * @see QName#valueOf(String) 043 * 044 * @since 1.0.0 045 * @author <a href="mailto:ggregory@garygregory.com">Gary Gregory</a> 046 */ 047public class QNameConverter extends AbstractBaseConverter<QName> { 048 049 /** 050 * Constructs a converter. 051 * 052 * @param optionName 053 * The option name, may be null. 054 */ 055 public QNameConverter(final String optionName) { 056 super(optionName, QName.class); 057 } 058 059 @Override 060 protected QName convertImpl(final String value) { 061 return QName.valueOf(value); 062 } 063 064}