/** * Returns an {@link AvpRepresentation} of the AVP with the given code and given Vendor-Id, if found. * * @param avpCode the code of the AVP * @param vendorId the Vendor-Id of the AVP * @return */ private static AvpRepresentation getAvpRepresentation(int avpCode, long vendorId) { return AvpDictionary.INSTANCE.getAvp(avpCode); }
public AvpRepresentation getAvp(int code, long vendorId) { AvpRepresentation avp = avpMap.get(getMapKey(code, vendorId)); if (avp == null) { logger.warn("AVP with code " + code + " and Vendor-Id " + vendorId + " not present in dictionary!"); } return avp; }
public void parseDictionary(String filename) throws Exception { FileInputStream fis = null; try { fis = new FileInputStream(filename); parseDictionary(fis); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { logger.error("Failed to close FileInputStream", e); } fis = null; } } }
/** * Returns an {@link AvpRepresentation} of the AVP with the given code and given Vendor-Id, if found. * * @param avpCode the code of the AVP * @param vendorId the Vendor-Id of the AVP * @return */ private static AvpRepresentation getAvpRepresentation(int avpCode, long vendorId) { return AvpDictionary.INSTANCE.getAvp(avpCode); }
public void parseDictionary(String filename) throws Exception { FileInputStream fis = null; try { fis = new FileInputStream(filename); parseDictionary(fis); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { logger.error("Failed to close FileInputStream", e); } fis = null; } } }
public AvpRepresentation getAvp(int code, long vendorId) { AvpRepresentation avp = avpMap.get(getMapKey(code, vendorId)); if (avp == null) { logger.warn("AVP with code " + code + " and Vendor-Id " + vendorId + " not present in dictionary!"); } return avp; }
public AvpRepresentation getAvp(int code) { return getAvp(code, 0); }
logger.info("Parsing AVP Dictionary file..."); AvpDictionary.INSTANCE.parseDictionary(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary.xml")); if(logger.isInfoEnabled()) { logger.info("AVP Dictionary file successfuly parsed!");
public AvpRepresentation getAvp(int code) { return getAvp(code, 0); }
logger.info("Parsing AVP Dictionary file..."); AvpDictionary.INSTANCE.parseDictionary(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary.xml")); if (logger.isInfoEnabled()) { logger.info("AVP Dictionary file successfuly parsed!");
private static DiameterAvpType getAvpType(int avpCode, long vendorId) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); return avpRep != null ? DiameterAvpType.fromString(avpRep.getType()) : null; }
logger.info("Parsing AVP Dictionary file..."); AvpDictionary.INSTANCE.parseDictionary(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary.xml")); if(logger.isInfoEnabled()) { logger.info("AVP Dictionary file successfuly parsed!");
private static DiameterAvpType getAvpType(int avpCode, long vendorId) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); return avpRep != null ? DiameterAvpType.fromString(avpRep.getType()) : null; }
public static void addAvp(Object parent, String avpName, AvpSet set, Object avp) { AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpName); if(rep != null) { addAvp(parent, rep.getCode(), rep.getVendorId(), set, avp); } else { throw new IllegalArgumentException("Unknown AVP with name '" + avpName + "'. Unable to add it."); } }
public static void addAvp(Object parent, String avpName, AvpSet set, Object avp) { AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpName); if(rep != null) { addAvp(parent, rep.getCode(), rep.getVendorId(), set, avp); } else { throw new IllegalArgumentException("Unknown AVP with name '" + avpName + "'. Unable to add it."); } }
public static Object getAvp(String avpName, AvpSet set) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpName); if(avpRep != null) { return getAvp(avpRep.getCode(), avpRep.getVendorId(), set); } return null; }
public static Object[] getAvpsAsCustom(int avpCode, long vendorId, AvpSet set, Class clazz) { try { AvpSet avpSet = set.getAvps(avpCode, vendorId); Object array = Array.newInstance(clazz, avpSet.size()); int i = 0; AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); Constructor c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); for(Avp avp : avpSet) { Array.set(array, i++, c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData())); } return (Object[]) array; } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Custom (Class '" + clazz.getName() + "').", e); } return (Object[]) Array.newInstance(clazz, 0); } }
public static Object[] getAvpsAsCustom(int avpCode, long vendorId, AvpSet set, Class clazz) { try { AvpSet avpSet = set.getAvps(avpCode, vendorId); Object array = Array.newInstance(clazz, avpSet.size()); int i = 0; AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); Constructor c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); for(Avp avp : avpSet) { Array.set(array, i++, c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData())); } return (Object[]) array; } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Custom (Class '" + clazz.getName() + "').", e); } return (Object[]) Array.newInstance(clazz, 0); } }
protected Object getAvp(String avpName) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpName); if(avpRep != null) { return getAvp(avpRep.getCode(), avpRep.getVendorId()); } return null; }
protected Object getAvp(String avpName) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpName); if(avpRep != null) { return getAvp(avpRep.getCode(), avpRep.getVendorId()); } return null; }