/* @if extendServerImport
172337
function extendServerImport(url, cb) {
		if (/^http(s)?\:/.test(url)) {
			return require("request")(url, function(error, response, body) {
				if (error) {
					return cb(error);
				}
				return cb(null, evaluateModule(url, body, response.headers["content-type"]));
			});
		}
		if (/\.(js|json)$/.test(url)) {
			return cb(null, require(url));
		} else {
			return require("fs").readFile(require("path").join(__dirname, url), function(err, result) {
				if (err) {
					cb(err);
				} else {
					cb(null, result.toString());
				}
			});
		}
	}
357827
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlAnnotationType == null) {
			this.container = script;
			this.sarlAnnotationType = SarlFactory.eINSTANCE.createSarlAnnotationType();
			script.getXtendTypes().add(this.sarlAnnotationType);
			this.sarlAnnotationType.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlAnnotationType.setName(name);
			}
		}
	}
1163347
@OverrideOnDemand
  protected boolean linkNeedsContextPath (@Nullable final String sHref)
  {
    if (sHref == null)
      return false;

    // If prefix is defined and already present no need to change something
    // Or if the server prefix path is just "/" and the links starts with "/"
    // it's also fine
    if (sHref.startsWith (m_sServerPrefixPath))
      return false;

    // javascript: and mailto: are handled by URLProtocolRegistry
    if (URLProtocolRegistry.getInstance ().hasKnownProtocol (sHref) || sHref.startsWith ("#"))
      return false;

    // Prefix is needed
    return true;
  }
763675
function validateObjectLimits( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
    {
        $options =& $persistentData['object_options'];

        $options['include_classes'] = $http->hasPostVariable( 'IncludeClasses' ) ? $http->postVariable( 'IncludeClasses' ) : false;
        $options['include_templates'] = $http->hasPostVariable( 'IncludeTemplates' ) ? $http->postVariable( 'IncludeTemplates' ) : false;
        $options['site_access_array'] = $http->postVariable( 'SiteAccesses' );
        $options['versions'] = $http->postVariable( 'VersionExport' );
        $options['language_array'] = $http->postVariable( 'Languages' );
        $options['node_assignment'] = $http->postVariable( 'NodeAssignment' );
        $options['related_objects'] = $http->postVariable( 'RelatedObjects' );
        $options['minimal_template_set'] = $http->hasPostVariable( 'MinimalTemplateSet' ) ? $http->postVariable( 'MinimalTemplateSet' ) : false;

        $result = true;
        if ( count( $persistentData['object_options']['language_array'] ) == 0 )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'You must choose one or more languages.' ) );
            $result = false;
        }

        if ( $persistentData['object_options']['include_templates'] &&
             count( $persistentData['object_options']['site_access_array'] ) == 0 )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'You must choose one or more site access.' ) );
            $result = false;
        }

        return $result;
    }
1186608
@ConditionalOnClass(value = {PcapIf.class, PcapAddr.class, SockAddr.class, DeviceNotFoundException.class})
    //@ConditionalOnBean(StringBuilder.class)
    @Bean(PCAP_IF_BEAN_NAME)
    public PcapIf pcapIf(@Qualifier(ERRBUF_BEAN_NAME) StringBuilder errbuf) throws DeviceNotFoundException {
        List<PcapIf> alldevsp = new ArrayList<PcapIf>();
        if (PcapFindAllDevs(alldevsp, errbuf) != OK) {
            throw new NativeException(errbuf.toString());
        }
        String source = properties.getSource();
        if (source == null || source.isEmpty()) {
            for (PcapIf dev : alldevsp) {
                for (PcapAddr addr : dev.getAddresses()) {
                    if (addr.getAddr().getSaFamily() == SockAddr.Family.AF_INET && addr.getAddr().getData() != null) {
                        Inet4Address d = Inet4Address.valueOf(addr.getAddr().getData());
                        if (!d.equals(Inet4Address.LOCALHOST) && !d.equals(Inet4Address.ZERO)) {
                            if (LOGGER.isDebugEnabled()) {
                                LOGGER.debug("Device: {}.", dev);
                            }
                            return dev;
                        }
                    }
                }
            }
        } else {
            for (PcapIf dev : alldevsp) {
                if (dev.getName().equals(source)) {
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("Device: {}.", dev);
                    }
                    return dev;
                }
            }
        }
        for (PcapIf dev : alldevsp) {
            if (dev.isLoopback()) {
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn("No device connected to the network. Auto selected {}.", dev.getName());
                }
                return dev;
            }
        }
        throw new DeviceNotFoundException();
    }
1156975
private boolean extendsServiceClient(DetailAST packageDefinitionToken) {
        String packageName = FullIdent.createFullIdent(packageDefinitionToken.findFirstToken(TokenTypes.DOT)).getText();
        if (packageName.startsWith("com.microsoft")) {
            return false;
        }

        DetailAST classDefinitionToken = packageDefinitionToken.findFirstToken(TokenTypes.CLASS_DEF);
        if (classDefinitionToken == null) {
            return false;
        }

        String className = classDefinitionToken.findFirstToken(TokenTypes.IDENT).getText();
        try {
            Class<?> clazz = Class.forName(packageName + "." + className);

            return this.serviceClientClass.isAssignableFrom(clazz);
        } catch (ClassNotFoundException ex) {
            log(classDefinitionToken, String.format(FAILED_TO_LOAD_MESSAGE, className));
            return false;
        }
    }
670112
function (tryReload, options) {                                        // 139
  tryReload = tryReload || function () {};                                                 // 140
  options = options || {};                                                                 // 141
                                                                                           // 142
  var migrationData = {};                                                                  // 143
  var remaining = _.clone(providers);                                                      // 144
  var allReady = true;                                                                     // 145
  while (remaining.length) {                                                               // 146
    var p = remaining.shift();                                                             // 147
    var status = p.callback(tryReload, options);                                           // 148
    if (!status[0])                                                                        // 149
      allReady = false;                                                                    // 150
    if (status.length > 1 && p.name)                                                       // 151
      migrationData[p.name] = status[1];                                                   // 152
  };                                                                                       // 153
  if (allReady || options.immediateMigration)                                              // 154
    return migrationData;                                                                  // 155
  else                                                                                     // 156
    return null;                                                                           // 157
}
401367
SamlPortConfigBuilder setSchemeAndPortIfAbsent(ServerPort serverPort) {
        requireNonNull(serverPort, "serverPort");
        if (serverPort.hasHttps()) {
            setSchemeIfAbsent(SessionProtocol.HTTPS);
        } else if (serverPort.hasHttp()) {
            setSchemeIfAbsent(SessionProtocol.HTTP);
        } else {
            throw new IllegalArgumentException("unexpected session protocol: " + serverPort.protocols());
        }

        // Do not set a port if the port number is 0 which means that the port will be automatically chosen.
        final int port = serverPort.localAddress().getPort();
        if (isValidPort(port)) {
            setPortIfAbsent(port);
        }
        return this;
    }
650949
protected function checkAndSetServerOptions()
    {

        // Specific query port defined
        if (array_key_exists(self::SERVER_OPTIONS_QUERY_PORT, $this->options)) {
            $this->port_query = (int)$this->options[self::SERVER_OPTIONS_QUERY_PORT];
        } else {
            // Do math based on the protocol class
            $this->port_query = $this->protocol->findQueryPort($this->port_client);
        }
    }
1066056
public void customizeVueObserverPrototype(VueObserver vueObserver) {
    vueObserveArrayFunction = vueObserver.getObserveArray();
    vueWalkFunction = vueObserver.getWalk();

    vueObserver.setWalk(toObserve -> {
      if (observeJavaObject(toObserve)) {
        return;
      }

      vueWalkFunction.call(this, toObserve);
    });
  }
122446
@Override
    public boolean regiserService(NaviRpcExporter exporter) {
        Class<?> interf = exporter.getServiceInterface();
        Object bean = exporter.getServiceBean();
        List<AppIdToken> appIdTokens = getAuthIfPossible(bean);
        String interfSimpleName = interf.getSimpleName();
        try {
            exporters.put(exporter.getName(), exporter);
            if (interf.isAssignableFrom(bean.getClass())) {
                Method[] ms = ReflectionUtil.getAllInstanceMethods(bean.getClass());
                for (Method m : ms) {
                    if (methodResolver.isSupport(m)) {
                        MethodWrapper methodWrapper = new MethodWrapper(interf.getName(),
                                m.getName(), MethodUtil.getArgsTypeName(m));
                        MethodWrapper defaultMethodWrapper = new MethodWrapper(interf.getName(),
                                m.getName(), StringUtil.EMPTY);
                        String key = methodWrapper.toString();
                        MethodDescriptor<String> desc = new MethodDescriptor<String>();
                        desc.setServiceId(key).setMethod(m).setTarget(bean)
                                .setArgumentClass(m.getParameterTypes())
                                .setReturnClass(m.getReturnType()).setInterfClass(interf).setAppIdTokens(appIdTokens);
                        serviceRegistry.addServiceDescriptor(key, desc);
                        serviceRegistry.addServiceDescriptor(defaultMethodWrapper.toString(), desc);
                        if (LOG.isDebugEnabled()) {
                            LOG.debug(String.format(
                                    "Register service key=[%s], %s %s#%s(%s) successfully", key, m
                                            .getReturnType().getSimpleName(), interf.getName(), m
                                            .getName(), StringUtil.toString4Array(m
                                            .getParameterTypes())));
                        }
                    }
                }
                LOG.info("Find rpc service configured, interface is "
                        + interfSimpleName + " , implementation is "
                        + AopUtils.getTargetClass(bean).getName());
                return true;
            } else {
                LOG.error("The interface " + interfSimpleName + " is not compatible with the bean "
                        + bean.getClass().getName());
            }
        } catch (Exception e) {
            LOG.error(
                    "The interface " + interfSimpleName + " is configured wrongly."
                            + e.getMessage(), e);
        }
        return false;
    }
629499
public void typeCheck(AFromModuleImports ifm, ModuleEnvironment env)
			throws AnalysisException
	{
		TypeCheckVisitor tc = new TypeCheckVisitor();
		TypeCheckInfo question = new TypeCheckInfo(af, env, null, null);

		for (List<PImport> ofType : ifm.getSignatures())
		{
			for (PImport imp : ofType)
			{
				imp.apply(tc, question);
			}
		}

	}
144777
JsonObject toDockerPortBindingsJson() {
        Map<String, Integer> portMap = getContainerPortToHostPortMap();
        if (!portMap.isEmpty()) {
            JsonObject portBindings = new JsonObject();
            Map<String, String> bindToMap = getBindToHostMap();

            for (Map.Entry<String, Integer> entry : portMap.entrySet()) {
                String containerPortSpec = entry.getKey();
                Integer hostPort = entry.getValue();

                JsonObject o = new JsonObject();
                o.addProperty("HostPort", hostPort != null ? hostPort.toString() : "");

                if (bindToMap.containsKey(containerPortSpec)) {
                    o.addProperty("HostIp", bindToMap.get(containerPortSpec));
                }

                JsonArray array = new JsonArray();
                array.add(o);

                portBindings.add(containerPortSpec, array);
            }
            return portBindings;
        } else {
            return null;
        }
    }
346799
public static boolean isServiceExported(Configuration configuration, int port, String serviceName) {
        if (serviceName == null)
            return false;
        try {
            final Registry registry = RegistryFinder.getInstance().getRegistry(configuration, port);
            String[] list = registry.list();

            if (list != null) {
                for (int i = 0; i < list.length; i++) {
                    if (serviceName.equals(list[i]))
                        return true;
                }
            }
        } catch (RemoteException ex) {
            return false;
        } catch (Exception e) {
            return false;
        }
        return false;
    }
522168
public static boolean isSupportedJDKType(TypeName typeName) {
		if (typeName.isPrimitive()) {
			return getPrimitiveTransform(typeName) != null;
		}

		String name = typeName.toString();

		if (name.startsWith("java.lang")) {
			return getLanguageTransform(typeName) != null;
		}

		if (name.startsWith("java.util")) {
			return getUtilTransform(typeName) != null;
		}

		if (name.startsWith("java.math")) {
			return getMathTransform(typeName) != null;
		}

		if (name.startsWith("java.net")) {
			return getNetTransform(typeName) != null;
		}

		if (name.startsWith("java.sql")) {
			return getSqlTransform(typeName) != null;
		}

		return false;
	}
423924
public static boolean shouldBeExported(String packageName) {
        boolean service = packageName.endsWith(".service");
        service = service
                || packageName.contains(".service.")
                || packageName.endsWith(".services")
                || packageName.contains(".services.");

        boolean api = packageName.endsWith(".api");
        api = api
                || packageName.contains(".api.")
                || packageName.endsWith(".apis")
                || packageName.contains(".apis.");

        boolean model = packageName.endsWith(".model");
        model = model
                || packageName.contains(".model.")
                || packageName.endsWith(".models")
                || packageName.contains(".models.");

        boolean entity = packageName.endsWith(".entity");
        entity = entity
                || packageName.contains(".entity.")
                || packageName.endsWith(".entities")
                || packageName.contains(".entities.");

        return !packageName.isEmpty() && !packageName.equals(".") && (service || api || model || entity);
    }
499454
function evaluateModule(id, input, type) {
		if (/javascript/.test(type)) {
			var fn = new Function("module", "exports", input);
			var moduleExports = {};
			var moduleObject = { exports: moduleExports };
			fn(moduleObject, moduleExports);
			return moduleObject.exports;
		}
		/* @if jsonLoader  */
		if (/json/.test(type)) {
			return JSON.parse(input);
		}
		/* @end */

		return input;
	}