Remove yang-test
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / mapping / attributes / fromxml / SimpleBinaryAttributeReadingStrategy.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
10
11 import com.google.common.collect.Lists;
12 import com.google.common.io.BaseEncoding;
13 import java.util.List;
14
15 public class SimpleBinaryAttributeReadingStrategy extends SimpleAttributeReadingStrategy {
16
17     public SimpleBinaryAttributeReadingStrategy(final String nullableDefault) {
18         super(nullableDefault);
19     }
20
21     @Override
22     protected Object postprocessParsedValue(final String textContent) {
23         BaseEncoding en = BaseEncoding.base64();
24         byte[] decode = en.decode(textContent);
25         List<String> parsed = Lists.newArrayListWithCapacity(decode.length);
26         for (byte b : decode) {
27             parsed.add(Byte.toString(b));
28         }
29         return parsed;
30     }
31
32     @Override
33     protected Object postprocessNullableDefault(final String nullableDefault) {
34         return nullableDefault == null ? null : postprocessParsedValue(nullableDefault);
35     }
36 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.